Skip to content

Commit a5a59af

Browse files
Copilotfelickz
andauthored
Add get_secret_scanning_scan_history_progress.py script
Implements the paradigm from Get-GHSecretScanningHistoryProgress.ps1 in Python. Adds: - Enterprise/org/repo resolution with GraphQL for enterprise orgs - Concurrent scan history API calls via ThreadPoolExecutor - Summary progress bars for backfill/incremental/pattern_update scans - Detailed markdown table output option - Error reporting for repos with disabled secret scanning Also adds list_org_repos, list_enterprise_orgs, and get_secret_scanning_scan_history methods to githubapi.py. Agent-Logs-Url: https://github.com/advanced-security/ghas-api-python-scripts/sessions/f6a777a1-48ca-4999-ba66-76934aa82818 Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 97521a8 commit a5a59af

File tree

3 files changed

+531
-0
lines changed

3 files changed

+531
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,49 @@ This is a set of scripts that use these APIs to access and manage alerts. The sc
2424

2525
A note on common arguments: generally, the date in `--since` can be specified as `YYYY-MM-DD` or as `Nd` where `N` is the number of days ago. Full ISO formats are also supported. If a timezone is not specified, the date is assumed to be in UTC (`Z` timezone).
2626

27+
### Get secret scanning scan history progress
28+
29+
This script retrieves the secret scanning scan history for repositories across an Enterprise, organization, or single repo. It queries the `GET /repos/{owner}/{repo}/secret-scanning/scan-history` endpoint for each repo concurrently and displays a summary with progress bars showing backfill, incremental, pattern update, and custom pattern scan completion status. Optionally outputs a detailed markdown table.
30+
31+
```text
32+
usage: get_secret_scanning_scan_history_progress.py [-h] (--enterprise ENTERPRISE | --org ORG | --repo REPO)
33+
[--detailed] [--concurrency CONCURRENCY] [--hostname HOSTNAME]
34+
[--ca-cert-bundle CA_CERT_BUNDLE] [--no-verify-tls] [--quiet]
35+
[--debug]
36+
37+
options:
38+
-h, --help show this help message and exit
39+
--enterprise ENTERPRISE
40+
GitHub Enterprise slug. Lists all orgs, then all repos per org.
41+
--org ORG GitHub Organization name. Lists all repos in the org.
42+
--repo REPO A single repository in owner/repo format.
43+
--detailed Show full markdown table with per-repo scan details instead of summary progress bars.
44+
--concurrency CONCURRENCY
45+
Number of concurrent API requests (default: 10).
46+
--hostname HOSTNAME GitHub Enterprise hostname (defaults to github.com)
47+
--ca-cert-bundle CA_CERT_BUNDLE, -C CA_CERT_BUNDLE
48+
Path to CA certificate bundle in PEM format (e.g. for self-signed server certificates)
49+
--no-verify-tls Do not verify TLS connection certificates (warning: insecure)
50+
--quiet, -q Suppress non-error log messages
51+
--debug, -d Enable debug logging
52+
```
53+
54+
Examples:
55+
56+
```bash
57+
# Single repo
58+
GITHUB_TOKEN=$(gh auth token) python3 get_secret_scanning_scan_history_progress.py --repo octocat/Hello-World
59+
60+
# Organization
61+
GITHUB_TOKEN=$(gh auth token) python3 get_secret_scanning_scan_history_progress.py --org my-org
62+
63+
# Enterprise (requires read:enterprise scope)
64+
GITHUB_TOKEN=$(gh auth token) python3 get_secret_scanning_scan_history_progress.py --enterprise my-enterprise
65+
66+
# With detailed markdown table
67+
GITHUB_TOKEN=$(gh auth token) python3 get_secret_scanning_scan_history_progress.py --org my-org --detailed
68+
```
69+
2770
### List secret scanning alerts
2871

2972
This script retrieves secret scanning alerts from GitHub repositories, organizations, or Enterprises and outputs them in CSV or JSON format. It supports filtering by state, date, and push protection bypass status. Use this to audit, analyze, or export secret scanning data for compliance or security purposes.

0 commit comments

Comments
 (0)