Skip to content

ci: post the CodeQL report to Discussions (#2030) - #2058

Merged
JarryShaw merged 1 commit into
mainfrom
ci/2030-codeql-report
Oct 22, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
ci/2030-codeql-report

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • ci — changes to CI configuration files and scripts

Description of your pull request and other information

The CodeQL part of #2030, per the owner's rulings there and on this PR: post the report whenever something is flagged.

  • codeql-analysis.yml: gains a discussion job after analyze that posts to codeql-analysis: CodeQL report. Scheduled runs post every run. Push runs follow the push rule, and pull requests never post. The job alone holds discussions: write and security-events: read; top-level permissions: {} is unchanged. Everything is continue-on-error, so reporting never turns CodeQL red.
  • New util/codeql_report.py: lists open CodeQL alerts by severity, through the code-scanning alerts API, and outputs status.
    • warning: analyze succeeded and an alert is open.
    • success: analyze succeeded and nothing is open.
    • Anything else: analyze's own result stands.
    • A failed read: gives one ::warning. The report says the alerts are unavailable, and the status stays analyze's result, so a failed read never claims success.
  • What gets posted: every run with open alerts posts. The first run back at zero posts once, then the thread goes quiet.
  • util/discussion_report.py: unchanged from main.
  • Tests: the new tests/project/test_codeql_report_2030.py (16 tests) fails on main and passes here. It runs each status case end to end through the real discussion_report.py. The discussion, cron, push-report, helper and Lint-pin tests plus the docs-claim tests all pass. actionlint 1.7.12 reports only the finding Lint already ignores.

@JarryShaw JarryShaw added enhancement Issues requesting a new capability (set by the feature request template) ci Pull requests that change CI or workflow configuration (ci: subject prefix) needs: decision Waiting on the maintainer to decide — not blocked by other work review: running A cross-review is in flight against the current head - no verdict yet labels Oct 22, 2026
@JarryShaw JarryShaw moved this to Needs decision in PyPCAPKit Oct 22, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

What about we post the CodeQL report summary every time if there's something being flagged out?

@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 08ade35cc (Sonnet cross-review). The push-run "post on any count change" question is still open for the owner.

  • Permissions and triggers: only discussion holds discussions: write and security-events: read, and analyze and the top-level permissions: {} are unchanged. The job never runs on pull_request, and continue-on-error is set on the job and both steps, so a reporting failure can't turn CodeQL red.
  • codeql_report.py: the endpoint and its parameters match the docs. The reviewer tested the pagination decoder on concatenated arrays, a single array, empty input and []\n[]. The severity falls back from security_severity_level to severity. A failed read gives one ::warning and exits 0.
  • --count: behaviour without it is unchanged. A human reply quoting a count marker is ignored, because both markers must be present.
  • Shell: the empty counted array expansion is safe under the runner's bash.
  • Tests: 200 passed across the new file and the discussion, cron, push-report, helper, Lint-pin and docs-claim tests.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 22, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Sorry, my verdict above went up over your comment. Recorded: post the CodeQL report whenever something is flagged. The rule becomes:

  • Warning: any open alert on a successful analyze is warning, so every push and scheduled run with open alerts posts, alerts listed by severity.
  • Back to green: once the count returns to zero, a single recovery post goes out, then silence.
  • Failure: a failed analyze posts as before.

That makes the rise/fall comparison and the --count marker unnecessary, so I'll take them out and leave discussion_report.py as it is on main. The rework is in progress.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed needs: decision Waiting on the maintainer to decide — not blocked by other work review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 22, 2026
@JarryShaw JarryShaw moved this from Needs decision to In review in PyPCAPKit Oct 22, 2026
- codeql-analysis.yml: a `discussion` job after `analyze`, the only job
  holding `security-events: read` (beside `discussions: write` and
  `contents: read`); top-level `permissions: {}` stays. Scheduled runs
  post every run, push runs follow the push rule, pull requests never
  post. Title `codeql-analysis: CodeQL report`; `REPORT_CATEGORY` env as
  the other workflows.
- util/codeql_report.py: reads the open CodeQL code-scanning alerts
  (REST, paginated) and writes the report by severity and the `status`
  output: `warning` while any alert is open on a successful `analyze`,
  `success` at none, `analyze`'s result otherwise. A failed read warns,
  marks the alerts unavailable and leaves `analyze`'s result.
- tests/project/test_codeql_report_2030.py pins the job, the status
  rule and the post sequence end to end; test_actions_helper_2047 lists
  the new script; workflows.rst documents it.

Related project tests pass; actionlint 1.7.12 is clean.
@JarryShaw
JarryShaw force-pushed the ci/2030-codeql-report branch from 08ade35 to df3e5b4 Compare October 22, 2026 22:49
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 22, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at df3e5b4f8 (Sonnet delta re-review).

  • util/discussion_report.py: byte-identical to main, with no --count or marker leftovers anywhere.
  • Status: analyze's result stands unless it succeeded. Then an open alert gives warning and none gives success. A failed read keeps analyze's result plus one ::warning and an "unavailable" note.
  • Empty report output: ${REPORT_STATUS:-$ANALYZE_RESULT} falls back when the report step leaves it empty, and a test covers that.
  • End-to-end tests: I checked these myself. TestEndToEnd copies the real discussion_report.py, codeql_report.py and _actions.py and runs them against a stand-in GitHub, so the push-rule outcomes are measured, not mocked.

170 passed across the CodeQL, discussion, cron, helper, Lint-pin and docs-claim tests.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 22, 2026
@JarryShaw
JarryShaw merged commit c98541f into main Oct 22, 2026
62 checks passed
@JarryShaw
JarryShaw deleted the ci/2030-codeql-report branch October 22, 2026 23:02
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 22, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 22, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that change CI or workflow configuration (ci: subject prefix) enhancement Issues requesting a new capability (set by the feature request template)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant