Skip to content

feat(ignore): adding event logger for ignored comments#178

Open
billxinli wants to merge 1 commit intomainfrom
feat/ignore-events
Open

feat(ignore): adding event logger for ignored comments#178
billxinli wants to merge 1 commit intomainfrom
feat/ignore-events

Conversation

@billxinli
Copy link
Copy Markdown

@billxinli billxinli commented Apr 2, 2026

  • Emits events to POST /v0/orgs/{slug}/telemetry when users suppress alerts via @SocketSecurity ignore PR/MR comments
  • Uses eyes emoji reaction as a dedup marker — only unprocessed comments (without eyes) trigger events; after sending, the eyes reaction is added
  • Per-comment iteration ensures the correct comment author is recorded as sender_name/sender_id
  • RBAC: only authorized users (write/admin on GitHub, Developer+ on GitLab) can suppress alerts and trigger events. Unauthorized users get a -1 reaction.
  • Supports both GitHub (inline reactions.eyes from API response) and GitLab (lazy has_eyes_reaction() API call per comment, best-effort post_eyes_reaction() via Award Emoji API)
  • Events are sent one at a time (fire-and-forget per event, continues on failure)
  • Comment flow uses artifact_input (raw user text) since the ignore command is user input and may not be a valid PURL
  • Push flow uses artifact_purl from actual alert objects with alert_action derived from the alert's resolved policy action
  • Fixes pre-existing case-sensitivity bug in get_ignore_options@socketSecurity ignore (lowercase s) now works

Changes

socketsecurity/core/cli_client.py

  • Added post_telemetry_events() — sends events individually to POST /v0/orgs/{slug}/telemetry

socketsecurity/core/scm/github.py

  • Added is_commenter_authorized() — checks collaborator permission level (admin/write)
  • Added post_eyes_reaction() — posts eyes reaction to mark comments as processed
  • Added post_negative_reaction() — posts -1 reaction for unauthorized users
  • Updated handle_ignore_reactions() — only adds +1 for authorized users, -1 for unauthorized

socketsecurity/core/scm/gitlab.py

  • Added is_commenter_authorized() — checks project member access level (Developer+)
  • Added has_eyes_reaction() — best-effort check for eyes award emoji on MR notes
  • Added post_eyes_reaction() — best-effort add eyes award emoji with Content-Type: application/json

socketsecurity/core/scm_comments.py

  • Made get_ignore_options() case-insensitive (fixes @socketSecurity vs @SocketSecurity)

socketsecurity/socketcli.py

  • Added _is_commenter_authorized() — checks user permissions with caching per user
  • Added _is_unprocessed() — checks inline reactions.eyes, falls back to scm.has_eyes_reaction(), then checks authorization
  • Added _filter_authorized_ignore_comments() — filters ignore comments to authorized users only, applied before suppression and telemetry in both flows
  • Comment flow: emits events per unprocessed ignore comment with author attribution
  • Push flow: matches ignored alerts back to individual comments, derives alert_action from alert's resolved policy flags

Tests

  • tests/unit/test_client.py — 2 tests: individual event sending, continues on failure
  • tests/unit/test_ignore_telemetry_filtering.py — 17 tests: eyes filtering, SCM fallback, commenter authorization (RBAC), authorized comment filtering, event payload shape

Event attributes

{
  "event_kind": "user-action",
  "client_action": "ignore",
  "alert_action": "error",
  "event_id": "<uuid>",
  "event_sender_created_at": "<iso8601>",
  "vcs_provider": "github|gitlab",
  "owner": "<repo_owner>",
  "repo": "<owner/repo>",
  "pr_number": 123,
  "ignore_all": true|false,
  "sender_name": "<comment_author_login>",
  "sender_id": "<comment_author_id>",
  "artifact_input": "<raw_user_text>" (comment flow),
  "artifact_purl": "<valid_purl>" (push flow)
}

Public Changelog

N/A

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.2.81.dev1

Docker image: socketdev/cli:pr-178

@billxinli billxinli force-pushed the feat/ignore-events branch from 0e20dd0 to 09e3172 Compare April 2, 2026 20:37
@billxinli billxinli marked this pull request as ready for review April 3, 2026 16:15
@billxinli billxinli requested a review from a team as a code owner April 3, 2026 16:15
@billxinli
Copy link
Copy Markdown
Author

bugbot run

Copy link
Copy Markdown

@bmeck bmeck left a comment

Choose a reason for hiding this comment

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

seems ok, would slightly pref v1 events but this is fine since v1 would be a slightly bigger change

now = datetime.now(timezone.utc).isoformat()
shared_fields = {
"event_kind": "user-action",
"client_action": "ignore_alerts",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

action fields should match ResolvedIssueAction, and this is missing the current action from policy (alert_action)

enum ResolvedIssueActionEnum {
  error = 'error',
  warn = 'warn',
  monitor = 'monitor',
  ignore = 'ignore',
}

@billxinli billxinli force-pushed the feat/ignore-events branch 4 times, most recently from 6dff16c to aebda0d Compare April 8, 2026 02:42
@billxinli billxinli force-pushed the feat/ignore-events branch from aebda0d to 29e2c61 Compare April 8, 2026 03:35
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.

2 participants