Files
wekan/releases/sec/download-github-security.sh
T
Lauri Ojansivu 801f8956fe releases/sec: download a GitHub organization's Security and quality alerts with gh.
releases/sec/download-github-security.sh ORGANIZATION saves, for every
repository of the organization (or the ones named with --repo), its
Dependabot, code scanning, secret scanning and security advisory alerts
to .tools/log/sec/<organization>/<repository>/<YYYY-MM-DD_HH-MM-SS>/,
a directory per kind: alerts.json, a file per alert, an open code
scanning alert's instances, and SUMMARY.md with every open alert and its
link. It runs the GitHub CLI outside the editor's sandbox, where gh and
its login are, so the alerts can then be read and fixed from the files
inside it. A kind GitHub does not answer - not enabled, or not visible
to the account - gets status.txt with the reason and the run goes on;
archived repositories and forks are skipped unless asked for; the secret
a secret scanning alert found is redacted unless --include-secret-values
is given. A name that is not a GitHub name is refused before it becomes
a path or an API address. .tools/ keeps the downloads out of git.

tests/securityDownloadScript.test.cjs runs it against a stand-in gh: the
layout, both pages of a paginated answer, the summary, a disabled kind,
the redaction everywhere in the download and, as negatives, bad names,
no gh and gh signed out writing nothing. buildScriptParity knows why
build.sh has no menu entry for it.

Thanks to xet7 !
2026-11-11 04:25:18 +02:00

23 lines
904 B
Bash
Executable File

#!/usr/bin/env bash
# Download a GitHub organization's "Security and quality" alerts - Dependabot,
# code scanning, secret scanning and security advisories - per repository, to
# .tools/log/sec/<organization>/<repository>/<YYYY-MM-DD_HH-MM-SS>/.
#
# releases/sec/download-github-security.sh wekan
# releases/sec/download-github-security.sh wekan --repo wekan --state open
# releases/sec/download-github-security.sh --help
#
# Run it outside the editor's Flatpak sandbox, where the GitHub CLI (gh) and
# its login are: `gh auth login` first, with an account that may read the
# organization's security alerts. See releases/sec/README.md.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if ! command -v python3 >/dev/null 2>&1; then
echo "python3 is needed to run $here/download_github_security.py" >&2
exit 2
fi
exec python3 -I "$here/download_github_security.py" "$@"