Skip to content

Conversation

@RagingRedRiot
Copy link
Contributor

@RagingRedRiot RagingRedRiot commented Nov 5, 2025

Description of the change

New Cynet Adapter. Pulls logs from the Bulk Alerts API.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

BHISSOC/tracking#22


Note

Adds a Cynet adapter that authenticates and ingests alerts from the Bulk Alerts API with pagination, dedupe, retries, and USP shipping; wired into configs and runner.

  • Adapters:
    • New cynet adapter (cynet/client.go):
      • CynetAdapter + CynetConfig with site, credentials, and URL.
      • Auth via POST /api/account/token; fetch alerts from GET /api/alerts/bulk.
      • Pagination (Limit/Offset) and incremental LastSeen since tracking.
      • Dedup via FNV hash with timed cleanup; tag events with event-type.
      • Robust HTTP handling: token refresh on 401, 429 backoff, 5xx retries, controlled shutdown after consecutive failures.
      • Ships events to USP with backpressure handling.
  • Integration:
    • Register cynet in containers/conf/all.go (GeneralConfigs.Cynet).
    • Wire into containers/general/tool.go imports and runAdapter (method == "cynet") with logging-applied ClientOptions.

Written by Cursor Bugbot for commit 6586c58. This will update automatically on new commits. Configure here.

@maximelb
Copy link
Contributor

/gcbrun

Copy link
Contributor

@maximelb maximelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review - see inline suggestions

- Fix cleanupDedupe: queryInterval was adding nanoseconds instead of seconds
- Fix resource leak: close response body immediately instead of deferred in retry loop
- Add mutex for accessToken to prevent race condition
- Move cleanupDedupe call outside pagination loop (once per fetch cycle)
- Create fresh context per retry attempt instead of sharing one
- Fix formatting alignment in all.go

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.


if syncTime.After(latestTime) {
latestTime = syncTime
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: All-duplicate responses cause timestamp to never advance

When all entities in a response are already in alertsDedupe, the continue on line 538 skips the latestTime = syncTime update, leaving latestTime at zero. This causes latestTimestamp.After(a.since) to be false, so a.since never advances. Combined with the 120-second dedup cleanup window, alerts could be re-processed as new after their dedupe entries are removed, resulting in duplicate events being sent downstream.

Additional Locations (1)

Fix in Cursor Fix in Web

amrik-lc
amrik-lc previously approved these changes Dec 11, 2025
When parsing SyncTimeUtc fails, syncTime was falling back to a.since.
This caused latestTimestamp.After(a.since) to be false, so a.since
never advanced and the adapter would re-fetch the same time window
indefinitely.

Fix by using time.Now().UTC() as the fallback to ensure progress.
Use OnWarning instead of OnError since this is a non-fatal condition.

Also changed default lookback from 24 hours to zero (current time).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@maximelb
Copy link
Contributor

/gcbrun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants