github-security-report 0.26.0__tar.gz → 0.27.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {github_security_report-0.26.0 → github_security_report-0.27.0}/PKG-INFO +59 -30
- {github_security_report-0.26.0 → github_security_report-0.27.0}/README.md +57 -28
- {github_security_report-0.26.0 → github_security_report-0.27.0}/pyproject.toml +2 -2
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/_version.py +2 -2
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/classify.py +5 -3
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/boundary.py +24 -5
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/modes.py +33 -1
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/preflight.py +22 -4
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/preflight_messages.py +31 -12
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/serialise.py +3 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/__init__.py +2 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/alerts.py +12 -5
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/batch_errors.py +2 -2
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/errors.py +47 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/failures.py +78 -2
- github_security_report-0.27.0/src/github_security_report/client/retry.py +57 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/transport.py +30 -42
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/slack.py +2 -1
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/aggregate.py +2 -1
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/signals.py +29 -2
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/summary.py +25 -1
- {github_security_report-0.26.0 → github_security_report-0.27.0}/.gitignore +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/LICENSE +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/LICENSES/Apache-2.0.txt +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/scripts/README.md +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/authors.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/categories/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/categories/keys.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/categories/signals.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/categories/tables.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/__main__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/app.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/config_cmd.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/config_source.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/options.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/outputs.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/progress.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/publish.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/remediation.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/cli/summary.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/accounting.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/analyses.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/bodies.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/codeql_parsers.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/copilot.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/endpoints.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/events.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/org_reads.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/paging.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/parsers.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/queries.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/reads.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/repo_parser.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/reviews.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/workflow_runs.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/client/writes.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/code_quality.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/codeql/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/codeql/cleanup.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/codeql/facts.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/codeql/tables.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/codeql.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/context.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/exclusions.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/extras.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/graph.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/org.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/protocols.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/repo.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/run_sync.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/scoping.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/collect/workflow_runs.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/blocks.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/dictionary.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/errors.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/key_notes.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/loader.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/models.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/order.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/schema.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/config/workflow_runs.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/fuzz.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/gating.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/gitctx.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/issue_presentation.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/issues.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/layout.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/malware.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/matching.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/models.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/ordering.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/posture/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/posture/enablement.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/posture/facts.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/posture/quality.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/posture/releases.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/pulls/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/pulls/columns.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/pulls/counting.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/pulls/presentation.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/pulls/table.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/py.typed +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/ranking.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/remediate/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/remediate/codeql.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/remediate/model.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/html.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/markdown.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/slack_limits.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/slack_text.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/terminal.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/render/terminal_notices.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/display.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/exclusions.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/report/tables.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/rulesets.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/runner.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/scope.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/secret_patterns.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/severity.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/templates/index.html.j2 +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/templates/report.html.j2 +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/__init__.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/aggregate.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/models.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/store.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/store_codec.py +0 -0
- {github_security_report-0.26.0 → github_security_report-0.27.0}/src/github_security_report/workflow_runs/tables.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: github-security-report
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.0
|
|
4
4
|
Summary: Security and quality reporting across GitHub organisations
|
|
5
5
|
Project-URL: Homepage, https://github.com/lfreleng-actions/github-security-report-action
|
|
6
6
|
Project-URL: Repository, https://github.com/lfreleng-actions/github-security-report-action
|
|
@@ -37,7 +37,7 @@ Requires-Dist: pytest-cov==7.1.0; extra == 'dev'
|
|
|
37
37
|
Requires-Dist: pytest==9.2.0; extra == 'dev'
|
|
38
38
|
Requires-Dist: respx==0.23.1; extra == 'dev'
|
|
39
39
|
Requires-Dist: ruff==0.17.5; extra == 'dev'
|
|
40
|
-
Requires-Dist: syrupy==7.0.
|
|
40
|
+
Requires-Dist: syrupy==7.0.2; extra == 'dev'
|
|
41
41
|
Requires-Dist: types-jsonschema==4.26.0.20261006; extra == 'dev'
|
|
42
42
|
Requires-Dist: types-pyyaml==6.0.12.20250915; extra == 'dev'
|
|
43
43
|
Description-Content-Type: text/markdown
|
|
@@ -72,7 +72,15 @@ states and rendered worst-first:
|
|
|
72
72
|
- **Clean** — enabled with zero findings (a count beneath the table).
|
|
73
73
|
- **Not enabled** — supported but switched off (a counted "disabled" footer
|
|
74
74
|
line, with the affected repositories named).
|
|
75
|
-
- **Unknown** — indeterminate
|
|
75
|
+
- **Unknown** — indeterminate, counted separately. The terminal, Markdown
|
|
76
|
+
and HTML reports name the reasons beside the count, for example
|
|
77
|
+
`3 Unknown (2 insufficient permission, 1 alert data incomplete)`:
|
|
78
|
+
- `insufficient permission` — the token cannot read the signal (`403`).
|
|
79
|
+
- `indeterminate` — a read that settles enablement failed.
|
|
80
|
+
- `alert data unavailable` — the alert read failed with nothing collected.
|
|
81
|
+
- `alert data incomplete` — the alert read failed part-way.
|
|
82
|
+
- `languages unreadable` — fuzzing could not read the languages.
|
|
83
|
+
- `no reason recorded` — the classifier gave none.
|
|
76
84
|
|
|
77
85
|
Every category renders the same **standardised summary footer** beneath its
|
|
78
86
|
table: remediation-first count lines (failures, disabled, unknown, then the
|
|
@@ -291,8 +299,8 @@ token (default `GITHUB_TOKEN`): its rate limit, and its read of every
|
|
|
291
299
|
organisation's listing. For a classic PAT the same check warns about a missing
|
|
292
300
|
scope from the table below and about a token that expires within seven days.
|
|
293
301
|
The rate-limit, scope and expiry checks are best effort: when `GET /rate_limit`
|
|
294
|
-
times out, fails to connect, answers anything but `200
|
|
295
|
-
body the tool cannot read, they are skipped for that token (logged at DEBUG)
|
|
302
|
+
times out, fails to connect, answers anything but `200`, `401` or a refusal
|
|
303
|
+
for a spent rate limit, or sends a body the tool cannot read, they are skipped for that token (logged at DEBUG)
|
|
296
304
|
and the run goes on to the listing checks. A passing pre-flight therefore does
|
|
297
305
|
not prove that every token's budget was checked.
|
|
298
306
|
|
|
@@ -421,16 +429,16 @@ read as not enabled rather than unknown.
|
|
|
421
429
|
analyses answers with invalid JSON or a non-array body, each is unknown,
|
|
422
430
|
except one a ruleset enforces, whose alert read is then skipped so that it
|
|
423
431
|
reads as clean. A `404` reads as code scanning **disabled**, and a tool missing from
|
|
424
|
-
the analyses reads **not enabled**,
|
|
425
|
-
|
|
432
|
+
the analyses reads **not enabled**, unless its filtered probe fails with an
|
|
433
|
+
HTTP error, which leaves it **unknown** as well.
|
|
426
434
|
Neither applies to a tool a ruleset enforces: it counts as enabled, and
|
|
427
435
|
after a `404` its alert read is skipped, so it reads as clean rather than
|
|
428
436
|
disabled. For a tool detected in the analyses or enforced by a ruleset,
|
|
429
437
|
an alert at or above the category's cutoff makes the repository an
|
|
430
438
|
offender even when the alert read did not finish; otherwise an unfinished
|
|
431
|
-
alert read is **unknown**, never clean. A tool left undetected
|
|
432
|
-
|
|
433
|
-
its alerts do not fail the gate.
|
|
439
|
+
alert read is **unknown**, never clean. A tool left undetected reads **not
|
|
440
|
+
enabled**, or **unknown** when its probe failed, whatever alerts were
|
|
441
|
+
collected, so its alerts do not fail the gate.
|
|
434
442
|
- Scorecard prefers its external score from scorecard.dev, read without the
|
|
435
443
|
token, so it can be classified, clean included, while the analyses are
|
|
436
444
|
unreadable. Without that score it falls back to its code-scanning alerts
|
|
@@ -615,9 +623,9 @@ maps to `codeql` covers it. The analysis check reads analyses on every branch,
|
|
|
615
623
|
not only the default branch, so a repository whose only CodeQL analysis came
|
|
616
624
|
from a feature branch reads as enabled and is not a target, though its default
|
|
617
625
|
branch has none. The check reads the newest 100 analyses, and when CodeQL is
|
|
618
|
-
not among them, a probe filtered to CodeQL; if that probe fails
|
|
619
|
-
|
|
620
|
-
|
|
626
|
+
not among them, a probe filtered to CodeQL; if that probe fails, CodeQL reads
|
|
627
|
+
as unknown for the run, so the repository is not a target whether or not it
|
|
628
|
+
has older CodeQL analyses. Any other CodeQL pipeline that has
|
|
621
629
|
not yet uploaded an analysis leaves the repository a `codeql` target: a
|
|
622
630
|
repository-local workflow, a required workflow the mapping does not name, one
|
|
623
631
|
whose ruleset the token cannot read, or an external pipeline that uploads with
|
|
@@ -1890,9 +1898,11 @@ flight when the first failure arrives were issued at the old size, so on a
|
|
|
1890
1898
|
slow day up to four oversized batches, rather than one, may fail before the
|
|
1891
1899
|
smaller size takes effect; that bounded cost buys the overlap. Only a
|
|
1892
1900
|
single-repository query GitHub still cannot answer, or a failure that a
|
|
1893
|
-
smaller query could not fix (a `403
|
|
1894
|
-
`
|
|
1895
|
-
|
|
1901
|
+
smaller query could not fix (a `403` or a `500`/`503` outage rather than a
|
|
1902
|
+
`502`/`504` timeout), aborts the run with exit code `3`, and the queries
|
|
1903
|
+
still in flight are cancelled first. An exhausted GraphQL rate limit is not
|
|
1904
|
+
retried smaller either: it aborts the run with exit code `6` (see
|
|
1905
|
+
[Exit codes](#exit-codes)).
|
|
1896
1906
|
|
|
1897
1907
|
The value can be set three ways, in this order of precedence:
|
|
1898
1908
|
|
|
@@ -2359,14 +2369,31 @@ API in the same way.
|
|
|
2359
2369
|
| `3` | The GitHub API was unusable after the retry budget (see below). |
|
|
2360
2370
|
| `4` | GitHub rejected the credentials (HTTP 401). |
|
|
2361
2371
|
| `5` | A repository listing answered `403` or `404`, with no rate limit. |
|
|
2362
|
-
| `6` | A
|
|
2372
|
+
| `6` | A rate limit with nothing left stopped the run (causes below). |
|
|
2363
2373
|
|
|
2364
|
-
Code `6` has
|
|
2374
|
+
Code `6` has five causes, and a rate-limited `403` is one of them, not `5`:
|
|
2365
2375
|
|
|
2366
2376
|
- a core or GraphQL budget already spent when the run started;
|
|
2367
2377
|
- a rate-limited listing, including a `403` whose message names a secondary
|
|
2368
2378
|
rate limit;
|
|
2369
|
-
- a listing page that spent the last request
|
|
2379
|
+
- a listing page that spent the last request;
|
|
2380
|
+
- a read refused mid-run because the primary budget is spent (a `403` or
|
|
2381
|
+
`429` with `x-ratelimit-remaining: 0`) and the reset is further away than
|
|
2382
|
+
the retry budget allows;
|
|
2383
|
+
- a GraphQL prefetch refused because a GraphQL rate limit is spent.
|
|
2384
|
+
|
|
2385
|
+
A read refused mid-run waits for the reset, and retries, only when the
|
|
2386
|
+
later of `x-ratelimit-reset` and any `Retry-After`, plus a second, fits in
|
|
2387
|
+
what is left of that request's retry budget. Otherwise the run stops at
|
|
2388
|
+
once: retrying on the ordinary schedule cannot outlast the reset, and
|
|
2389
|
+
GitHub warns that continuing to send requests while rate limited may get an
|
|
2390
|
+
integration banned. With no `x-ratelimit-reset`, the read is retried on the
|
|
2391
|
+
ordinary schedule and the run stops when that is spent. The message names
|
|
2392
|
+
the rate-limit resource, the endpoint, and when the budget resets in UTC
|
|
2393
|
+
with the minutes to wait. A secondary rate limit (no
|
|
2394
|
+
`x-ratelimit-remaining: 0`) that outlives the retry budget still degrades
|
|
2395
|
+
that one read to unknown, and a `remediate` write refused for a spent budget
|
|
2396
|
+
still reports that target's failure rather than stopping the run.
|
|
2370
2397
|
|
|
2371
2398
|
Codes `3` to `6` are **aborts, not reports**: nothing is written and no Pages
|
|
2372
2399
|
artifact is produced. That is deliberate. A token that has expired, been revoked
|
|
@@ -2379,11 +2406,12 @@ cannot read, or a rate limit with nothing left, would produce the same report,
|
|
|
2379
2406
|
so they stop the run too.
|
|
2380
2407
|
|
|
2381
2408
|
For `remediate`, "nothing is written" holds only when the pre-flight stops the
|
|
2382
|
-
run (any `5
|
|
2383
|
-
the pre-flight passes, `remediate` collects and
|
|
2384
|
-
time, so a `3` or `
|
|
2385
|
-
writes have been applied. Check
|
|
2386
|
-
re-run enables only what it finds
|
|
2409
|
+
run (any `5`, a `6` from the pre-flight, and a `3` or `4` raised before
|
|
2410
|
+
collection starts). After the pre-flight passes, `remediate` collects and
|
|
2411
|
+
writes one organisation at a time, so a `3`, `4` or `6` from a later
|
|
2412
|
+
organisation comes after the earlier ones' writes have been applied. Check
|
|
2413
|
+
what the run printed before re-running; a re-run enables only what it finds
|
|
2414
|
+
still off.
|
|
2387
2415
|
|
|
2388
2416
|
Org-mode `report` and `remediate` check for these before they collect
|
|
2389
2417
|
anything, for every configured organisation before the first. `report` reads
|
|
@@ -2395,7 +2423,8 @@ budget (exit `6`, naming the resource and when it resets); and one
|
|
|
2395
2423
|
single-repository page of each organisation's listing finds a `403` or `404`
|
|
2396
2424
|
(exit `5`). The `/rate_limit` probe is best effort: it is made once with a
|
|
2397
2425
|
short timeout, and when it times out, cannot connect, answers anything but
|
|
2398
|
-
`200
|
|
2426
|
+
`200`, `401` or a refusal for a spent rate limit (exit `6`), or sends an
|
|
2427
|
+
unreadable body, its budget, scope and expiry
|
|
2399
2428
|
checks are skipped for that token (logged at DEBUG) and the run carries on.
|
|
2400
2429
|
The code `5` message names the organisation and what to check:
|
|
2401
2430
|
its name, a classic PAT's SSO authorisation for it, or a fine-grained PAT's
|
|
@@ -2407,16 +2436,16 @@ advises waiting at least a minute. One that still fails after the retry
|
|
|
2407
2436
|
budget, or whose page holds an entry that is not a repository, exits `3`. A
|
|
2408
2437
|
token GitHub rejects exits `4`, and the message says which token. A run that
|
|
2409
2438
|
passes prints nothing new. A listing whose *later* page fails mid-run still
|
|
2410
|
-
produces a report marked incomplete
|
|
2439
|
+
produces a report marked incomplete, unless a spent rate limit refused it
|
|
2440
|
+
(exit `6`).
|
|
2411
2441
|
|
|
2412
2442
|
Code `3` covers a GitHub API that could not be reached at all, and a GraphQL
|
|
2413
2443
|
prefetch that failed as a whole: either a size-shaped failure (`502`/`504`
|
|
2414
2444
|
timeout, `200` with no data, resource limits exceeded) that persisted even
|
|
2415
2445
|
after the batch had been halved down to one repository, or a failure that
|
|
2416
|
-
halving could not have fixed (`403`,
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
later, wait for the rate-limit budget to reset, or check the token's
|
|
2446
|
+
halving could not have fixed (`403`, a `500`/`503` outage), which aborts at
|
|
2447
|
+
once. The message reports the status or cause and ends with the matching
|
|
2448
|
+
next step — a smaller `--graph-batch`, retry later, or check the token's
|
|
2420
2449
|
permissions — so read it rather than assuming "retry later" (see
|
|
2421
2450
|
[GraphQL prefetch batch size](#graphql-prefetch-batch-size)).
|
|
2422
2451
|
|
|
@@ -28,7 +28,15 @@ states and rendered worst-first:
|
|
|
28
28
|
- **Clean** — enabled with zero findings (a count beneath the table).
|
|
29
29
|
- **Not enabled** — supported but switched off (a counted "disabled" footer
|
|
30
30
|
line, with the affected repositories named).
|
|
31
|
-
- **Unknown** — indeterminate
|
|
31
|
+
- **Unknown** — indeterminate, counted separately. The terminal, Markdown
|
|
32
|
+
and HTML reports name the reasons beside the count, for example
|
|
33
|
+
`3 Unknown (2 insufficient permission, 1 alert data incomplete)`:
|
|
34
|
+
- `insufficient permission` — the token cannot read the signal (`403`).
|
|
35
|
+
- `indeterminate` — a read that settles enablement failed.
|
|
36
|
+
- `alert data unavailable` — the alert read failed with nothing collected.
|
|
37
|
+
- `alert data incomplete` — the alert read failed part-way.
|
|
38
|
+
- `languages unreadable` — fuzzing could not read the languages.
|
|
39
|
+
- `no reason recorded` — the classifier gave none.
|
|
32
40
|
|
|
33
41
|
Every category renders the same **standardised summary footer** beneath its
|
|
34
42
|
table: remediation-first count lines (failures, disabled, unknown, then the
|
|
@@ -247,8 +255,8 @@ token (default `GITHUB_TOKEN`): its rate limit, and its read of every
|
|
|
247
255
|
organisation's listing. For a classic PAT the same check warns about a missing
|
|
248
256
|
scope from the table below and about a token that expires within seven days.
|
|
249
257
|
The rate-limit, scope and expiry checks are best effort: when `GET /rate_limit`
|
|
250
|
-
times out, fails to connect, answers anything but `200
|
|
251
|
-
body the tool cannot read, they are skipped for that token (logged at DEBUG)
|
|
258
|
+
times out, fails to connect, answers anything but `200`, `401` or a refusal
|
|
259
|
+
for a spent rate limit, or sends a body the tool cannot read, they are skipped for that token (logged at DEBUG)
|
|
252
260
|
and the run goes on to the listing checks. A passing pre-flight therefore does
|
|
253
261
|
not prove that every token's budget was checked.
|
|
254
262
|
|
|
@@ -377,16 +385,16 @@ read as not enabled rather than unknown.
|
|
|
377
385
|
analyses answers with invalid JSON or a non-array body, each is unknown,
|
|
378
386
|
except one a ruleset enforces, whose alert read is then skipped so that it
|
|
379
387
|
reads as clean. A `404` reads as code scanning **disabled**, and a tool missing from
|
|
380
|
-
the analyses reads **not enabled**,
|
|
381
|
-
|
|
388
|
+
the analyses reads **not enabled**, unless its filtered probe fails with an
|
|
389
|
+
HTTP error, which leaves it **unknown** as well.
|
|
382
390
|
Neither applies to a tool a ruleset enforces: it counts as enabled, and
|
|
383
391
|
after a `404` its alert read is skipped, so it reads as clean rather than
|
|
384
392
|
disabled. For a tool detected in the analyses or enforced by a ruleset,
|
|
385
393
|
an alert at or above the category's cutoff makes the repository an
|
|
386
394
|
offender even when the alert read did not finish; otherwise an unfinished
|
|
387
|
-
alert read is **unknown**, never clean. A tool left undetected
|
|
388
|
-
|
|
389
|
-
its alerts do not fail the gate.
|
|
395
|
+
alert read is **unknown**, never clean. A tool left undetected reads **not
|
|
396
|
+
enabled**, or **unknown** when its probe failed, whatever alerts were
|
|
397
|
+
collected, so its alerts do not fail the gate.
|
|
390
398
|
- Scorecard prefers its external score from scorecard.dev, read without the
|
|
391
399
|
token, so it can be classified, clean included, while the analyses are
|
|
392
400
|
unreadable. Without that score it falls back to its code-scanning alerts
|
|
@@ -571,9 +579,9 @@ maps to `codeql` covers it. The analysis check reads analyses on every branch,
|
|
|
571
579
|
not only the default branch, so a repository whose only CodeQL analysis came
|
|
572
580
|
from a feature branch reads as enabled and is not a target, though its default
|
|
573
581
|
branch has none. The check reads the newest 100 analyses, and when CodeQL is
|
|
574
|
-
not among them, a probe filtered to CodeQL; if that probe fails
|
|
575
|
-
|
|
576
|
-
|
|
582
|
+
not among them, a probe filtered to CodeQL; if that probe fails, CodeQL reads
|
|
583
|
+
as unknown for the run, so the repository is not a target whether or not it
|
|
584
|
+
has older CodeQL analyses. Any other CodeQL pipeline that has
|
|
577
585
|
not yet uploaded an analysis leaves the repository a `codeql` target: a
|
|
578
586
|
repository-local workflow, a required workflow the mapping does not name, one
|
|
579
587
|
whose ruleset the token cannot read, or an external pipeline that uploads with
|
|
@@ -1846,9 +1854,11 @@ flight when the first failure arrives were issued at the old size, so on a
|
|
|
1846
1854
|
slow day up to four oversized batches, rather than one, may fail before the
|
|
1847
1855
|
smaller size takes effect; that bounded cost buys the overlap. Only a
|
|
1848
1856
|
single-repository query GitHub still cannot answer, or a failure that a
|
|
1849
|
-
smaller query could not fix (a `403
|
|
1850
|
-
`
|
|
1851
|
-
|
|
1857
|
+
smaller query could not fix (a `403` or a `500`/`503` outage rather than a
|
|
1858
|
+
`502`/`504` timeout), aborts the run with exit code `3`, and the queries
|
|
1859
|
+
still in flight are cancelled first. An exhausted GraphQL rate limit is not
|
|
1860
|
+
retried smaller either: it aborts the run with exit code `6` (see
|
|
1861
|
+
[Exit codes](#exit-codes)).
|
|
1852
1862
|
|
|
1853
1863
|
The value can be set three ways, in this order of precedence:
|
|
1854
1864
|
|
|
@@ -2315,14 +2325,31 @@ API in the same way.
|
|
|
2315
2325
|
| `3` | The GitHub API was unusable after the retry budget (see below). |
|
|
2316
2326
|
| `4` | GitHub rejected the credentials (HTTP 401). |
|
|
2317
2327
|
| `5` | A repository listing answered `403` or `404`, with no rate limit. |
|
|
2318
|
-
| `6` | A
|
|
2328
|
+
| `6` | A rate limit with nothing left stopped the run (causes below). |
|
|
2319
2329
|
|
|
2320
|
-
Code `6` has
|
|
2330
|
+
Code `6` has five causes, and a rate-limited `403` is one of them, not `5`:
|
|
2321
2331
|
|
|
2322
2332
|
- a core or GraphQL budget already spent when the run started;
|
|
2323
2333
|
- a rate-limited listing, including a `403` whose message names a secondary
|
|
2324
2334
|
rate limit;
|
|
2325
|
-
- a listing page that spent the last request
|
|
2335
|
+
- a listing page that spent the last request;
|
|
2336
|
+
- a read refused mid-run because the primary budget is spent (a `403` or
|
|
2337
|
+
`429` with `x-ratelimit-remaining: 0`) and the reset is further away than
|
|
2338
|
+
the retry budget allows;
|
|
2339
|
+
- a GraphQL prefetch refused because a GraphQL rate limit is spent.
|
|
2340
|
+
|
|
2341
|
+
A read refused mid-run waits for the reset, and retries, only when the
|
|
2342
|
+
later of `x-ratelimit-reset` and any `Retry-After`, plus a second, fits in
|
|
2343
|
+
what is left of that request's retry budget. Otherwise the run stops at
|
|
2344
|
+
once: retrying on the ordinary schedule cannot outlast the reset, and
|
|
2345
|
+
GitHub warns that continuing to send requests while rate limited may get an
|
|
2346
|
+
integration banned. With no `x-ratelimit-reset`, the read is retried on the
|
|
2347
|
+
ordinary schedule and the run stops when that is spent. The message names
|
|
2348
|
+
the rate-limit resource, the endpoint, and when the budget resets in UTC
|
|
2349
|
+
with the minutes to wait. A secondary rate limit (no
|
|
2350
|
+
`x-ratelimit-remaining: 0`) that outlives the retry budget still degrades
|
|
2351
|
+
that one read to unknown, and a `remediate` write refused for a spent budget
|
|
2352
|
+
still reports that target's failure rather than stopping the run.
|
|
2326
2353
|
|
|
2327
2354
|
Codes `3` to `6` are **aborts, not reports**: nothing is written and no Pages
|
|
2328
2355
|
artifact is produced. That is deliberate. A token that has expired, been revoked
|
|
@@ -2335,11 +2362,12 @@ cannot read, or a rate limit with nothing left, would produce the same report,
|
|
|
2335
2362
|
so they stop the run too.
|
|
2336
2363
|
|
|
2337
2364
|
For `remediate`, "nothing is written" holds only when the pre-flight stops the
|
|
2338
|
-
run (any `5
|
|
2339
|
-
the pre-flight passes, `remediate` collects and
|
|
2340
|
-
time, so a `3` or `
|
|
2341
|
-
writes have been applied. Check
|
|
2342
|
-
re-run enables only what it finds
|
|
2365
|
+
run (any `5`, a `6` from the pre-flight, and a `3` or `4` raised before
|
|
2366
|
+
collection starts). After the pre-flight passes, `remediate` collects and
|
|
2367
|
+
writes one organisation at a time, so a `3`, `4` or `6` from a later
|
|
2368
|
+
organisation comes after the earlier ones' writes have been applied. Check
|
|
2369
|
+
what the run printed before re-running; a re-run enables only what it finds
|
|
2370
|
+
still off.
|
|
2343
2371
|
|
|
2344
2372
|
Org-mode `report` and `remediate` check for these before they collect
|
|
2345
2373
|
anything, for every configured organisation before the first. `report` reads
|
|
@@ -2351,7 +2379,8 @@ budget (exit `6`, naming the resource and when it resets); and one
|
|
|
2351
2379
|
single-repository page of each organisation's listing finds a `403` or `404`
|
|
2352
2380
|
(exit `5`). The `/rate_limit` probe is best effort: it is made once with a
|
|
2353
2381
|
short timeout, and when it times out, cannot connect, answers anything but
|
|
2354
|
-
`200
|
|
2382
|
+
`200`, `401` or a refusal for a spent rate limit (exit `6`), or sends an
|
|
2383
|
+
unreadable body, its budget, scope and expiry
|
|
2355
2384
|
checks are skipped for that token (logged at DEBUG) and the run carries on.
|
|
2356
2385
|
The code `5` message names the organisation and what to check:
|
|
2357
2386
|
its name, a classic PAT's SSO authorisation for it, or a fine-grained PAT's
|
|
@@ -2363,16 +2392,16 @@ advises waiting at least a minute. One that still fails after the retry
|
|
|
2363
2392
|
budget, or whose page holds an entry that is not a repository, exits `3`. A
|
|
2364
2393
|
token GitHub rejects exits `4`, and the message says which token. A run that
|
|
2365
2394
|
passes prints nothing new. A listing whose *later* page fails mid-run still
|
|
2366
|
-
produces a report marked incomplete
|
|
2395
|
+
produces a report marked incomplete, unless a spent rate limit refused it
|
|
2396
|
+
(exit `6`).
|
|
2367
2397
|
|
|
2368
2398
|
Code `3` covers a GitHub API that could not be reached at all, and a GraphQL
|
|
2369
2399
|
prefetch that failed as a whole: either a size-shaped failure (`502`/`504`
|
|
2370
2400
|
timeout, `200` with no data, resource limits exceeded) that persisted even
|
|
2371
2401
|
after the batch had been halved down to one repository, or a failure that
|
|
2372
|
-
halving could not have fixed (`403`,
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
later, wait for the rate-limit budget to reset, or check the token's
|
|
2402
|
+
halving could not have fixed (`403`, a `500`/`503` outage), which aborts at
|
|
2403
|
+
once. The message reports the status or cause and ends with the matching
|
|
2404
|
+
next step — a smaller `--graph-batch`, retry later, or check the token's
|
|
2376
2405
|
permissions — so read it rather than assuming "retry later" (see
|
|
2377
2406
|
[GraphQL prefetch batch size](#graphql-prefetch-batch-size)).
|
|
2378
2407
|
|
|
@@ -63,7 +63,7 @@ dev = [
|
|
|
63
63
|
"pytest-asyncio==1.5.0",
|
|
64
64
|
"pytest-cov==7.1.0",
|
|
65
65
|
"respx==0.23.1",
|
|
66
|
-
"syrupy==7.0.
|
|
66
|
+
"syrupy==7.0.2",
|
|
67
67
|
"mypy==2.4.1",
|
|
68
68
|
"ruff==0.17.5",
|
|
69
69
|
"types-jsonschema==4.26.0.20261006",
|
|
@@ -95,7 +95,7 @@ dev = [
|
|
|
95
95
|
"pytest-asyncio==1.5.0",
|
|
96
96
|
"pytest-cov==7.1.0",
|
|
97
97
|
"respx==0.23.1",
|
|
98
|
-
"syrupy==7.0.
|
|
98
|
+
"syrupy==7.0.2",
|
|
99
99
|
"mypy==2.4.1",
|
|
100
100
|
"ruff==0.17.5",
|
|
101
101
|
"types-jsonschema==4.26.0.20261006",
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.
|
|
22
|
-
__version_tuple__ = version_tuple = (0,
|
|
21
|
+
__version__ = version = '0.27.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 27, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -13,7 +13,7 @@ Pure, transport-free logic encoding every Phase 0 finding
|
|
|
13
13
|
- secret scanning 404 = disabled, 200 [] = enabled-clean;
|
|
14
14
|
- Dependabot ``hasVulnerabilityAlertsEnabled == false`` = disabled;
|
|
15
15
|
- Scorecard prefers the external aggregate score, else code-scanning findings;
|
|
16
|
-
- 403 / indeterminate ->
|
|
16
|
+
- 403 / indeterminate, or a failed tool probe -> unknown, never clean or nag;
|
|
17
17
|
- a repository holding no fuzzable language is not applicable to fuzzing,
|
|
18
18
|
never nagged (ADR-0009);
|
|
19
19
|
- an alert read that failed (even part-way, keeping the alerts it had
|
|
@@ -170,6 +170,8 @@ def _code_scanning_tool_signal(
|
|
|
170
170
|
facts.code_scanning_status == 200 and tool_name in facts.code_scanning_tools
|
|
171
171
|
)
|
|
172
172
|
if not enabled:
|
|
173
|
+
if tool_name in facts.code_scanning_unread: # a failed probe: no evidence
|
|
174
|
+
return RepoSignal(repo, signal, RepoState.UNKNOWN, detail="indeterminate")
|
|
173
175
|
detail = (
|
|
174
176
|
"code scanning disabled"
|
|
175
177
|
if facts.code_scanning_status == 404
|
|
@@ -314,12 +316,12 @@ def classify_scorecard(
|
|
|
314
316
|
# An indeterminate external request (a 403 forbidden/blocked, a 5xx
|
|
315
317
|
# including the synthetic 503 a transport failure produces, or a forbidden
|
|
316
318
|
# code-scanning probe) is unknown, not a definitive nag. Only a clean 404
|
|
317
|
-
# with no code-scanning Scorecard data means "no results". A
|
|
319
|
+
# with no code-scanning Scorecard data means "no results". A failed
|
|
318
320
|
# Scorecard probe settles nothing either, as for the other tools.
|
|
319
321
|
if (
|
|
320
322
|
facts.code_scanning_status == 403
|
|
321
323
|
or facts.scorecard_status not in (200, 404)
|
|
322
|
-
or CODE_SCANNING_TOOLS[SignalType.SCORECARD] in facts.
|
|
324
|
+
or CODE_SCANNING_TOOLS[SignalType.SCORECARD] in facts.code_scanning_unread
|
|
323
325
|
):
|
|
324
326
|
return RepoSignal(
|
|
325
327
|
repo, SignalType.SCORECARD, RepoState.UNKNOWN, detail="indeterminate"
|
|
@@ -25,8 +25,18 @@ from rich.console import Console
|
|
|
25
25
|
|
|
26
26
|
from github_security_report import gitctx, runner
|
|
27
27
|
from github_security_report.categories import CategoryKey
|
|
28
|
-
from github_security_report.cli.modes import
|
|
29
|
-
|
|
28
|
+
from github_security_report.cli.modes import (
|
|
29
|
+
_abort_auth,
|
|
30
|
+
_abort_graph_rate_limit,
|
|
31
|
+
_abort_network,
|
|
32
|
+
_abort_rate_limit,
|
|
33
|
+
)
|
|
34
|
+
from github_security_report.client import (
|
|
35
|
+
AuthError,
|
|
36
|
+
GraphBatchError,
|
|
37
|
+
NetworkError,
|
|
38
|
+
RateLimitError,
|
|
39
|
+
)
|
|
30
40
|
from github_security_report.config import Config
|
|
31
41
|
from github_security_report.matching import compile_patterns
|
|
32
42
|
|
|
@@ -224,13 +234,22 @@ def resolve_mode(
|
|
|
224
234
|
def run_guarded(console: Console, coro: Coroutine[Any, Any, int]) -> int:
|
|
225
235
|
"""Run a mode coroutine, turning credential and network failures into exits.
|
|
226
236
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
"retry later" without
|
|
237
|
+
Every mode needs the same handlers, and they distinguish the causes by
|
|
238
|
+
exit code so an automated caller can tell "rotate the token" (4) from
|
|
239
|
+
"wait for the rate limit to reset" (6) and "retry later" (3) without
|
|
240
|
+
parsing the message. A spent rate limit exits 6 whichever API reported
|
|
241
|
+
it: a REST read refused by its budget, or a GraphQL prefetch refused by
|
|
242
|
+
a GraphQL rate limit.
|
|
230
243
|
"""
|
|
231
244
|
try:
|
|
232
245
|
return asyncio.run(coro)
|
|
233
246
|
except AuthError as exc:
|
|
234
247
|
_abort_auth(console, exc)
|
|
248
|
+
except RateLimitError as exc:
|
|
249
|
+
_abort_rate_limit(console, exc)
|
|
250
|
+
except GraphBatchError as exc:
|
|
251
|
+
if exc.rate_limited:
|
|
252
|
+
_abort_graph_rate_limit(console, exc)
|
|
253
|
+
_abort_network(console, exc)
|
|
235
254
|
except NetworkError as exc:
|
|
236
255
|
_abort_network(console, exc)
|
|
@@ -41,9 +41,16 @@ from github_security_report.cli.outputs import (
|
|
|
41
41
|
show,
|
|
42
42
|
windows,
|
|
43
43
|
)
|
|
44
|
+
from github_security_report.cli.preflight_messages import spent_budget_message
|
|
44
45
|
from github_security_report.cli.progress import make_tracker
|
|
45
46
|
from github_security_report.cli.summary import RunSummary, print_run_summary
|
|
46
|
-
from github_security_report.client import
|
|
47
|
+
from github_security_report.client import (
|
|
48
|
+
AuthError,
|
|
49
|
+
GitHubClient,
|
|
50
|
+
GraphBatchError,
|
|
51
|
+
NetworkError,
|
|
52
|
+
RateLimitError,
|
|
53
|
+
)
|
|
47
54
|
from github_security_report.collect.context import CollectExtras
|
|
48
55
|
from github_security_report.collect.workflow_runs import (
|
|
49
56
|
attach_workflow_failures,
|
|
@@ -145,6 +152,29 @@ def _abort_auth(console: Console, exc: AuthError) -> NoReturn:
|
|
|
145
152
|
raise typer.Exit(4)
|
|
146
153
|
|
|
147
154
|
|
|
155
|
+
def _abort_rate_limit(console: Console, exc: RateLimitError) -> NoReturn:
|
|
156
|
+
"""Abort the run on a read refused because a rate limit is spent.
|
|
157
|
+
|
|
158
|
+
Exits with the pre-flight's rate-limit code (6), mid-run as before it:
|
|
159
|
+
every later read would be refused the same way, and a report made of
|
|
160
|
+
unknowns would be published over the last good one.
|
|
161
|
+
"""
|
|
162
|
+
message = spent_budget_message(exc, dt.datetime.now(dt.UTC))
|
|
163
|
+
console.print(message, style="red", markup=False)
|
|
164
|
+
raise typer.Exit(preflight.EXIT_RATE_LIMITED)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _abort_graph_rate_limit(console: Console, exc: GraphBatchError) -> NoReturn:
|
|
168
|
+
"""Abort on a GraphQL prefetch refused for a spent GraphQL rate limit.
|
|
169
|
+
|
|
170
|
+
The message is the batch error's own; only the exit code (6) differs from
|
|
171
|
+
any other failed prefetch (3), so a rate limit reads the same whichever
|
|
172
|
+
API reported it.
|
|
173
|
+
"""
|
|
174
|
+
console.print(str(exc), style="red", markup=False)
|
|
175
|
+
raise typer.Exit(preflight.EXIT_RATE_LIMITED)
|
|
176
|
+
|
|
177
|
+
|
|
148
178
|
async def _collect_reports(
|
|
149
179
|
cfg: Config,
|
|
150
180
|
*,
|
|
@@ -392,7 +422,9 @@ from github_security_report.cli.remediation import ( # noqa: E402
|
|
|
392
422
|
|
|
393
423
|
__all__ = [
|
|
394
424
|
"_abort_auth",
|
|
425
|
+
"_abort_graph_rate_limit",
|
|
395
426
|
"_abort_network",
|
|
427
|
+
"_abort_rate_limit",
|
|
396
428
|
"_check_selection",
|
|
397
429
|
"_collect_reports",
|
|
398
430
|
"_load_config",
|
|
@@ -37,8 +37,14 @@ from github_security_report.cli.preflight_messages import (
|
|
|
37
37
|
network_message,
|
|
38
38
|
rate_limit_message,
|
|
39
39
|
reset_text,
|
|
40
|
+
spent_budget_headers,
|
|
41
|
+
)
|
|
42
|
+
from github_security_report.client import (
|
|
43
|
+
AuthError,
|
|
44
|
+
GitHubClient,
|
|
45
|
+
NetworkError,
|
|
46
|
+
RateLimitError,
|
|
40
47
|
)
|
|
41
|
-
from github_security_report.client import AuthError, GitHubClient, NetworkError
|
|
42
48
|
from github_security_report.client.bodies import _read_body
|
|
43
49
|
from github_security_report.client.repo_parser import _parse_repo_or_none
|
|
44
50
|
from github_security_report.client.transport import Transport
|
|
@@ -205,7 +211,8 @@ async def probe_token(
|
|
|
205
211
|
) -> None:
|
|
206
212
|
"""Read what ``GET /rate_limit`` says about a token, warning or aborting.
|
|
207
213
|
|
|
208
|
-
A ``401`` raises :class:`AuthError` from the transport, as for any read
|
|
214
|
+
A ``401`` raises :class:`AuthError` from the transport, as for any read,
|
|
215
|
+
and a spent budget :class:`RateLimitError` (exit ``6``).
|
|
209
216
|
Anything else the probe cannot use skips its checks, logged at DEBUG: the
|
|
210
217
|
probe's own failure never stops a run. GitHub Enterprise Server answers
|
|
211
218
|
``404`` here when rate limiting is off. It is made once, never retried, and
|
|
@@ -217,7 +224,7 @@ async def probe_token(
|
|
|
217
224
|
resp = await client._request(
|
|
218
225
|
"GET", url, quiet=True, max_retries=0, timeout=PROBE_TIMEOUT_SECONDS
|
|
219
226
|
)
|
|
220
|
-
except AuthError:
|
|
227
|
+
except (AuthError, RateLimitError):
|
|
221
228
|
raise
|
|
222
229
|
except (NetworkError, TimeoutError) as exc:
|
|
223
230
|
log.debug("token probe skipped: %s", str(exc) or "no answer in time")
|
|
@@ -337,7 +344,18 @@ async def check_listing(client: Transport, org: str) -> None:
|
|
|
337
344
|
request of the rate limit leaves the collection nothing to read with.
|
|
338
345
|
"""
|
|
339
346
|
url = f"{client._api_url}/orgs/{org}/repos"
|
|
340
|
-
|
|
347
|
+
try:
|
|
348
|
+
resp = await client._request("GET", url, params={"type": "all", "per_page": 1})
|
|
349
|
+
except RateLimitError as exc:
|
|
350
|
+
raise PreflightAbort(
|
|
351
|
+
rate_limit_message(
|
|
352
|
+
org,
|
|
353
|
+
f"answered HTTP {exc.status} after the retry budget",
|
|
354
|
+
url,
|
|
355
|
+
spent_budget_headers(exc),
|
|
356
|
+
),
|
|
357
|
+
EXIT_RATE_LIMITED,
|
|
358
|
+
) from exc
|
|
341
359
|
status = resp.status_code
|
|
342
360
|
headers = resp.headers
|
|
343
361
|
if status == 200:
|
|
@@ -14,6 +14,8 @@ import math
|
|
|
14
14
|
|
|
15
15
|
import httpx
|
|
16
16
|
|
|
17
|
+
from github_security_report.client.errors import RateLimitError
|
|
18
|
+
from github_security_report.client.failures import _unusable_delta_seconds
|
|
17
19
|
from github_security_report.client.parsers import _parse_retry_after
|
|
18
20
|
|
|
19
21
|
|
|
@@ -68,6 +70,35 @@ def rate_limit_message(org: str, what: str, url: str, headers: httpx.Headers) ->
|
|
|
68
70
|
return "\n".join(lines)
|
|
69
71
|
|
|
70
72
|
|
|
73
|
+
def spent_budget_headers(exc: RateLimitError) -> httpx.Headers:
|
|
74
|
+
"""The rate-limit headers a :class:`RateLimitError` was raised from.
|
|
75
|
+
|
|
76
|
+
Rebuilt from what the error carries, so :func:`wait_text` words the wait
|
|
77
|
+
as it would have from the response itself.
|
|
78
|
+
"""
|
|
79
|
+
headers = httpx.Headers({"x-ratelimit-remaining": "0"})
|
|
80
|
+
if exc.reset is not None:
|
|
81
|
+
headers["x-ratelimit-reset"] = str(exc.reset)
|
|
82
|
+
if exc.retry_after is not None:
|
|
83
|
+
headers["retry-after"] = str(math.ceil(exc.retry_after))
|
|
84
|
+
return headers
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def spent_budget_message(exc: RateLimitError, now: dt.datetime) -> str:
|
|
88
|
+
"""The abort for a read refused mid-run because a budget is spent."""
|
|
89
|
+
resource = f"the {exc.resource}" if exc.resource else "a primary"
|
|
90
|
+
return "\n".join(
|
|
91
|
+
[
|
|
92
|
+
f"Rate limit exhausted: GitHub refused a read because {resource} "
|
|
93
|
+
"rate limit has no requests left; the run stopped because the "
|
|
94
|
+
"remaining reads would all be reported as unknown.",
|
|
95
|
+
f" endpoint={exc.method} {exc.url}",
|
|
96
|
+
f" {wait_text(spent_budget_headers(exc), now)}",
|
|
97
|
+
" Wait for the rate limit to reset, or run with a different token.",
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
71
102
|
def wait_text(headers: httpx.Headers, now: dt.datetime) -> str:
|
|
72
103
|
"""How long a rate-limited response says to wait.
|
|
73
104
|
|
|
@@ -128,18 +159,6 @@ def _retry_after_at(
|
|
|
128
159
|
return None
|
|
129
160
|
|
|
130
161
|
|
|
131
|
-
def _unusable_delta_seconds(raw: str | None) -> bool:
|
|
132
|
-
"""Whether ``raw`` is a number no retry can wait for: negative or not finite.
|
|
133
|
-
|
|
134
|
-
A value that is not a number (absent, or an HTTP-date) is left to the parser.
|
|
135
|
-
"""
|
|
136
|
-
try:
|
|
137
|
-
value = float(raw or "")
|
|
138
|
-
except ValueError:
|
|
139
|
-
return False
|
|
140
|
-
return not 0 <= value < math.inf
|
|
141
|
-
|
|
142
|
-
|
|
143
162
|
def listing_message(org: str, status: int, url: str, sso: str | None) -> str:
|
|
144
163
|
lines = [
|
|
145
164
|
f"Repository listing unreadable: GitHub answered HTTP {status} for "
|
|
@@ -132,6 +132,9 @@ def _org_to_dict(org: OrgReport, hidden: Collection[CategoryKey] = ()) -> dict:
|
|
|
132
132
|
"clean_count": s.clean_count,
|
|
133
133
|
"nag": [r.full_name for r in s.nag_repos],
|
|
134
134
|
"unknown_count": s.unknown_count,
|
|
135
|
+
# Each reason recorded for the unknown repositories, with how
|
|
136
|
+
# many give it, largest first; {} when none.
|
|
137
|
+
"unknown_reasons": dict(s.unknown_reasons),
|
|
135
138
|
"not_applicable_count": s.not_applicable_count,
|
|
136
139
|
# True when organisation feature gating skipped this signal
|
|
137
140
|
# (no supporting workflows found), so nothing was collected.
|