Harden alert lifecycle: TLS verification, cleared-issue detection, pagination - #2
Open
ethangardner wants to merge 1 commit into
Open
Harden alert lifecycle: TLS verification, cleared-issue detection, pagination#2ethangardner wants to merge 1 commit into
ethangardner wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two correctness/security issues found in review of #1 and hardens two related edge cases, all in the alert action's core logic (
scripts/snapshot.py,scripts/issues.py,scripts/site_scanning_alerts.py), plus new test coverage for the previously-untested issue lifecycle.Why
This Action fetches remote data and auto-opens/comments on issues unattended on a daily cron across every consuming repo, so correctness and network-security issues here have real blast radius: wrong data in → spam or missed issues out.
Changes
snapshot.py). The snapshot fetch previously usedssl._create_unverified_context()for every request, including the defaultapi.gsa.govURL and any override supplied via thesnapshot_url/previous_snapshot_urlinputs. With verification off, anyone on-path could serve spoofed CSV content that gets parsed straight into GitHub issues — e.g. serving a "clean" snapshot to mask a real outage, or garbage data to spam every watched domain as broken. Now uses the default verifiedurlopencontext.issues.py,site_scanning_alerts.py).handle_alert_lifecyclepreviously inferred whether alerts had cleared by searching the rendered markdown body for the literal phrases"have returned to normal"/"operating as expected"— a hidden coupling to wording chosen inrules.pythat nothing enforced and nothing tested. A future wording tweak there would have silently broken the clear-detection path, leaving a resolved alert issue open forever.handle_alert_lifecyclenow takes an explicitis_clear: boolargument; callers passlen(all_alerts) == 0.find_open_issue(issues.py). The open-issue search previously read only the first 100 open issues for the label. If a label is ever shared with >100 other open issues, the real alert issue could sit past page 1 and the action would create a duplicate issue every run instead of updating the existing one. It now walks pages until a short page confirms there are no more.issues.py). When a condition cleared, an issue existed, butcomment_on_clearwasfalse, the function returnedissue_url: Noneeven though an open issue does exist — which the entrypoint then reports asN/A, reading as "no issue" when one is actually open. It now returns the existing issue's URL in that case.tests/test_issues.py): the full create/no-op/comment/cleared decision matrix forhandle_alert_lifecycle(previously untested — only fingerprint helpers and client init had coverage), plus tests for the new pagination behavior.Testing
python3 -m unittest discover tests -v— 42 tests pass (6 new lifecycle tests, 2 new pagination tests).