Commit Graph

30 Commits

Author SHA1 Message Date
Ryan Smith
0462ed7b4c Explicitly ignore errors in WS handlers 2025-04-05 14:27:00 -07:00
Ryan Smith
35c0eb06f8 Move log-related handlers to separate file 2025-04-03 10:52:05 -07:00
Ryan Smith
6ba9f0acf5 Add ability to view the running configuration
This change adds a /config handler for displaying the Deceptifeed configuration. An icon is added to the nav bar for accessing the page.

- Add config.html template for displaying the Deceptifeed configuration.
- Add config.html supporting styles to style.css.
- Add /config http handler to render the config.html template.
- Add icon to nav bar for accessing /config page.
2025-03-27 13:26:52 -07:00
Ryan Smith
4fd048c287 Remove feature for custom threat file
This change removes the `CustomThreatsPath` setting from the threat feed configuration. The default configuration files are updated with this setting removed.
2025-03-26 18:23:37 -07:00
Ryan Smith
60ab753c42 Remove threat score feature, replace with observation count
This change removes the 'threat score' feature which allowed users to configure each honeypot server with a variable 'score' when updating the threat feed.

It is replaced with a fixed observation count that is incremented by 1 for each honeypot interaction.

The field `threat_score` has been replaced with `observations` in all API call parameters and threat feed data.

The `threat_score` field in the CSV file has been renamed to `observations`. Existing threat feed CSV files will be automatically updated on the next threat feed save.
2025-03-20 09:20:15 -07:00
Ryan Smith
f72cf4ddba Use centralized stylesheet
This change removes the CSS sections from HTML templates and switches to using a single stylesheet at /css/style.css.
2025-03-19 19:55:14 -07:00
Ryan Smith
97cddb8cfe Ensure log files are read in a consistent order
Use a slice instead of a map to track unique paths to ensure log files are read in the correct order.
2025-03-18 07:26:27 -07:00
Ryan Smith
182262d474 Add ability to view honeypot logs from the threat feed server 2025-03-17 14:08:13 -07:00
Ryan Smith
70e8180b2b Add custom 404 page 2025-03-09 12:35:10 -07:00
Ryan Smith
1bde74187f Add nav bar and visual tweaks to management pages
- Add a horizontal navigation bar to the top of all management pages.
- Tweaks to colors and styling of management pages.
- Rename the endpoint '/threatfeed' to '/webfeed'.
- Rename the file 'htmlfeed.html' to 'webfeed.html'.
2025-03-09 10:08:05 -07:00
Ryan Smith
96b5be5758 Minor visual and structural revisions
- Remove the `/feed` endpoint, as this is already handled by `/plain`.
- Rename `/html` endpoint to `/threatfeed`.
- Add a `/docs` endpoint for displaying information on accessing the threat feed.
- Make the Deceptifeed logo smaller on HTML pages.
- Revise the layout of the initial homepage. Endpoint docs are now moved and linked to /docs.
- Remove `/html` from the list of threat feed endpoints in the docs, as it doesn't belong here (there is a link to the html threat feed on the home page).
2025-03-07 13:34:41 -08:00
Ryan Smith
99b9760830 Update threat feed server to receive full app config
This change updates the threat feed server so that the entire application config is passed in to the threat feed server. This allows the threat feed server to access its own configuration as well as the settings for each honeypot server and any other application-wide settings.
2024-12-30 10:39:01 -08:00
Ryan Smith
b47d5278f4 Consilidate STIX endpoints to /stix
This change removes the /stix/indicators and /stix/observables endpoints and replaces them with a single /stix endpoint. The /stix endpoint returns the threat feed as STIX indicators.
2024-12-26 10:16:04 -08:00
Ryan Smith
505e1fa2e0 Add sightings TAXII collection
- Add `sightings` TAXII collection to represent IP addresses observed interacting with Deceptifeed as STIX sightings
- Rename collection aliases `deceptifeed-indicators` and `deceptifeed-observables` to `indicators` and `observables`.
- Add `convertToSightings` method for converting the threat feed to STIX sightings.
- Set a confidence score of 100 to STIX indicators.
- Rename label `honeypot` to `honeypot-interaction` on STIX indicators.
2024-12-26 10:05:55 -08:00
Ryan Smith
f5561776a7 Add error check in handleHome
This change adds a missing error check to the template .Execute call in `handleHome`.
2024-12-05 16:48:00 -08:00
Ryan Smith
f6a4f1ff5f Add default landing page and revise routes
This change adds a default landing page that is served when accessing the threat feed root URL. The landing page provides information about accessing the threat feed.

Move the template from handleHTML to the templates directory and embed using embed.FS.

Several changes to HTTP routes:
- Delete `/csv/ips` route and handler.
- Delete `/json/ips` route and handler.
- Rename `/stix2` route to `/stix/indicators`.
- Rename `/stix2/ips` route to `/stix/observables`.
- Change default route `/` to return 404 Not Found.
- Move plain text feed to `/feed` and `/plain` routes.
2024-11-26 08:59:29 -08:00
Ryan Smith
19b61b90e7 Set default sort method for html route 2024-11-25 12:56:35 -08:00
Ryan Smith
c952356879 Add support for serving the threat feed as a web page
- Add new route `/html` and associated handler for serving the threat feed as a web page for viewing in a browser.
- Revise sorting methods to apply a secondary sort by IP adddress when the values for the requested sort method are equal.
2024-11-21 17:48:55 -08:00
Ryan Smith
0db1b81617 Refactor threat feed data structure
- Add a `feedEntry` struct to represent threat feed data as it is being served to clients. The threat feed is now served as a slice of feedEntries. Previously, the threat feed was built using a slice of net.IPs. The new struct avoids additional map lookups when formatting the feed and faster sorting operations.
- Rename `IoC` struct to `IOC` and make fields non-exportable.
- Revise HTTP handlers to format/encode the feed results using the new structs.
2024-11-21 14:17:57 -08:00
Ryan Smith
0421fd66ba Add sort direction option
- Add `sortDirection` type to represent sort directions.
- Add sortDirection argument to applySort function.
- Add `direction` HTTP query parameter for setting the sort direction option.
2024-11-21 08:38:17 -08:00
Ryan Smith
64cd270d9b Add sort and filter query parameters to all endpoints
- Add `sort` query parameter to sort the threat feed by IP (default), last seen date, added date, or by threat score.
- Add `last_seen_hours` query parameter to have the threat feed only return IPs that have been seen within the specified number of hours.

Examples:

`http://127.0.0.1:9000/json?sort=added`

`http://127.0.0.1:9000/?sort=ip&last_seen_hours=24`
2024-11-20 13:12:19 -08:00
Ryan Smith
b7ed763661 Refactor feed operations
- Add parseParams function to parse HTTP query parameters.
- Switch from functional options to an options struct for prepareFeed.
- Define a `feed` type for []net.IP.
- Add `applySort` method for sorting the feed.
- Change `convertToObservables` and `convertToIndicators` from functions to methods.
- Optimize exclude list processing.
  - parseExcludeList now determines and tracks whether each entry is a single IP or a CIDR block and now returns both a map of single IPs and a slice of CIDR blocks.
  - prepareFeed now calls parseExcludeList prior to iterating over iocData.
  - Delete the filterIPs function. All filtering logic is applied while iterating over iocData rather than afterwards.
2024-11-20 08:31:20 -08:00
Ryan Smith
6d98f7c4d2 Remove JSON formatting for TAXII output
This changes removes JSON formatting (beautifier) for TAXII output to minimize the response size.
2024-11-17 18:13:51 -08:00
Ryan Smith
b68ad408ce Add filtering and pagination to TAXII server
This change adds filtering and pagination when requesting objects from collections.

- Add `more` and `next` properties to the TAXII `envelope` resource.
- Add support for the `limit` URL query parameter to limit the maximum number of objects returned.
- Add full support for pagination. This includes:
  - Sett the `X-TAXII-Date-Added-First` and `X-TAXII-Date-Added-Last` headers with the timestamps of the first and last objects from the results.
  - Set the `more` property in the response to indicate whether there are more items remaining.
  - Set the `next` property in the response with the next page number if there are more items remaining.

Other changes:
- Modiy the threat feed `last seen` sort to sort by IP when the dates are equal.
2024-11-17 12:40:22 -08:00
Ryan Smith
e442edf0aa Add support for serving the threat feed over TAXII 2.1
This change adds support for serving the threat feed over TAXII 2.1. The TAXII API is not yet fully implemented, but should work with most threat intelligence platforms.

Missing TAXII features:
- Mising `limit` query parameter.
- Missing `match` query parameter.
- Pagination is not supported.
- Missing `X-TAXII` headers.
- {api-root}/collections/{id}/manifest/
- {api-root}/collections/{id}/objects/{object-id}/
- {api-root}/collections/{id}/objects/{object-id}/versions/

- Add `internal\taxi\taxi.go` with struct definitions and helpers for TAXII resources.
- Move threat feed parsing functions from `handler.go` to `feed.go`.
- Add option functions for `prepareFeed` to allow sorting by last seen date and to filter by last seen date.
- Default timestamps to time.Now when initially loading feed data.
2024-11-16 21:51:43 -08:00
Ryan Smith
c9d1b06680 Optimize IP sort function
Switch to `slices.SortFunc` instead of `sort.Slice` when sorting IP addresses in the feed.
2024-11-16 15:23:36 -08:00
Ryan Smith
51a0447e7d Refactor STIX functions
- Add new `stix` package for STIX-specific types and functions.
- Use `stix` package to decalre STIX types, rather than using local function declarations.
- Add function to return the Deceptifeed application represented as a STIX Identity object. Indicators and observables now reference this identity as the creator.
- Move `threatfeed\util.go` to `stix\uuid.go`.
- Move STIX conversions to dedicated functions to simplify HTTP handlers.
2024-11-16 11:37:44 -08:00
Ryan Smith
0ffbfae468 Switch to STIX namespace for deterministic IDs
This change switches to using the STIX namespace for generating deterministic identifiers for STIX Domain Objects (SDOs). While the STIX specification states SDOs must not use the STIX namespace, some applications (OpenCTI) do so. This update improves compatibility with OpenCTI by adopting the same behavior.
2024-11-15 15:19:22 -08:00
Ryan Smith
b7a9eaced2 Add support for serving the threat feed in STIX 2.1 format
This change adds support for serving the threat feed in a STIX 2.1 format using the `/stix2` and `/stix2/ips` routes.

- Add `handleSTIX2` function for the `/stix2` route. This returns the detailed threat feed structured as a STIX bundle containing *Indicator* objects for each IP address in the feed.
- Add `handleSTIX2Simple` handler for the `/stix2/ips` route. This returns the simplified threat feed structured as a STIX bundle with each IP address included as a STIX Cyber-observable Object (SCO).
- Add `util.go` with helper functions for creating STIX 2.1 identifiers. This includes a `newUUIDv5` function, a `newUUIDv4` function, and a `namespace` type.
2024-11-13 14:53:18 -08:00
Ryan Smith
8b49b6f042 Split threat feed code into separate files
- Rename database.go to data.go.
- Move data-related global vars from threatfeed.go to data.go.
- Split out functions from threatfeed.go into seperate files:
  - Move HTTP server functions to server.go.
  - Move HTTP handler functions to handler.go.
  - Move HTTP middleware functions to middleware.go.
- Rename hasMapChanged to dataChanged.
2024-11-13 11:28:36 -08:00