Add repo secret scanning command
This commit is contained in:
parent
5aeb953362
commit
88e7ccd214
|
|
@ -149,6 +149,9 @@ on first. This command is report-only.
|
||||||
`security-trivy`
|
`security-trivy`
|
||||||
: Run only Trivy filesystem and IaC/config scans.
|
: Run only Trivy filesystem and IaC/config scans.
|
||||||
|
|
||||||
|
`security-secrets`
|
||||||
|
: Run only gitleaks secret scanning against this repo.
|
||||||
|
|
||||||
`security-nuclei`
|
`security-nuclei`
|
||||||
: Run low-rate nuclei HTTP exposure scans against public targets.
|
: Run low-rate nuclei HTTP exposure scans against public targets.
|
||||||
|
|
||||||
|
|
|
||||||
10
jeannie
10
jeannie
|
|
@ -5790,6 +5790,11 @@ security_trivy() {
|
||||||
"${REPO_ROOT}/scripts/security-scan" trivy
|
"${REPO_ROOT}/scripts/security-scan" trivy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
security_secrets() {
|
||||||
|
require_debian_server "security-secrets"
|
||||||
|
"${REPO_ROOT}/scripts/security-scan" secrets
|
||||||
|
}
|
||||||
|
|
||||||
security_nuclei() {
|
security_nuclei() {
|
||||||
require_debian_server "security-nuclei"
|
require_debian_server "security-nuclei"
|
||||||
"${REPO_ROOT}/scripts/security-scan" nuclei
|
"${REPO_ROOT}/scripts/security-scan" nuclei
|
||||||
|
|
@ -5919,6 +5924,9 @@ case "${1:-}" in
|
||||||
security-trivy)
|
security-trivy)
|
||||||
security_trivy
|
security_trivy
|
||||||
;;
|
;;
|
||||||
|
security-secrets)
|
||||||
|
security_secrets
|
||||||
|
;;
|
||||||
security-nuclei)
|
security-nuclei)
|
||||||
security_nuclei
|
security_nuclei
|
||||||
;;
|
;;
|
||||||
|
|
@ -5936,7 +5944,7 @@ case "${1:-}" in
|
||||||
echo "Log: ${JEANNIE_LOG_FILE}"
|
echo "Log: ${JEANNIE_LOG_FILE}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {up|plan [all|provisioning|cluster|platform|apps|edge]|rebuild-cluster|stop-cluster|start-cluster|status|apps|website-translation-model|website-ollama-listen|ollama-setup|deploy-gitea|rpi-services|bootstrap-gitea-repo|backup-gitea|drill-gitea-restore|install-gitea-runner|move-prometheus-stack-workers|doctor-versions|doctor-edge|doctor-gitea|doctor-rpi|doctor-cluster|preflight|doctor-preapply|inventory-check|state-backup|fix-debian-docker-root|secrets-init|secrets-check|tailnet-policy-check|ai-index|ai-check|security-scan|security-prepare|security-zap|security-k8s|security-host|security-trivy|security-nuclei|security-web|openwrt|nuke}"
|
echo "Usage: $0 {up|plan [all|provisioning|cluster|platform|apps|edge]|rebuild-cluster|stop-cluster|start-cluster|status|apps|website-translation-model|website-ollama-listen|ollama-setup|deploy-gitea|rpi-services|bootstrap-gitea-repo|backup-gitea|drill-gitea-restore|install-gitea-runner|move-prometheus-stack-workers|doctor-versions|doctor-edge|doctor-gitea|doctor-rpi|doctor-cluster|preflight|doctor-preapply|inventory-check|state-backup|fix-debian-docker-root|secrets-init|secrets-check|tailnet-policy-check|ai-index|ai-check|security-scan|security-prepare|security-zap|security-k8s|security-host|security-trivy|security-secrets|security-nuclei|security-web|openwrt|nuke}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ TRIVY_IMAGE="${TRIVY_IMAGE:-aquasec/trivy:latest}"
|
||||||
ZAP_IMAGE="${ZAP_IMAGE:-ghcr.io/zaproxy/zaproxy:stable}"
|
ZAP_IMAGE="${ZAP_IMAGE:-ghcr.io/zaproxy/zaproxy:stable}"
|
||||||
KUBE_BENCH_IMAGE="${KUBE_BENCH_IMAGE:-aquasec/kube-bench:latest}"
|
KUBE_BENCH_IMAGE="${KUBE_BENCH_IMAGE:-aquasec/kube-bench:latest}"
|
||||||
NUCLEI_IMAGE="${NUCLEI_IMAGE:-projectdiscovery/nuclei:latest}"
|
NUCLEI_IMAGE="${NUCLEI_IMAGE:-projectdiscovery/nuclei:latest}"
|
||||||
|
GITLEAKS_IMAGE="${GITLEAKS_IMAGE:-ghcr.io/gitleaks/gitleaks:latest}"
|
||||||
|
|
||||||
truthy() {
|
truthy() {
|
||||||
case "${1,,}" in
|
case "${1,,}" in
|
||||||
|
|
@ -23,7 +24,7 @@ truthy() {
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Usage: scripts/security-scan {all|prepare|trivy|zap|kube-bench|nuclei|host|web}
|
Usage: scripts/security-scan {all|prepare|trivy|zap|kube-bench|nuclei|host|web|secrets}
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
SECURITY_REPORT_DIR Report output directory.
|
SECURITY_REPORT_DIR Report output directory.
|
||||||
|
|
@ -57,6 +58,7 @@ prepare_security_scans() {
|
||||||
"${ZAP_IMAGE}"
|
"${ZAP_IMAGE}"
|
||||||
"${KUBE_BENCH_IMAGE}"
|
"${KUBE_BENCH_IMAGE}"
|
||||||
"${NUCLEI_IMAGE}"
|
"${NUCLEI_IMAGE}"
|
||||||
|
"${GITLEAKS_IMAGE}"
|
||||||
)
|
)
|
||||||
|
|
||||||
ensure_report_dir
|
ensure_report_dir
|
||||||
|
|
@ -109,6 +111,35 @@ run_trivy() {
|
||||||
echo "Trivy reports written to ${SECURITY_REPORT_DIR}"
|
echo "Trivy reports written to ${SECURITY_REPORT_DIR}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_gitleaks() {
|
||||||
|
local stamp
|
||||||
|
local report_file
|
||||||
|
stamp="$(timestamp)"
|
||||||
|
ensure_report_dir
|
||||||
|
report_file="${SECURITY_REPORT_DIR}/gitleaks-${stamp}.json"
|
||||||
|
|
||||||
|
echo "Running gitleaks secret scan against this repo..."
|
||||||
|
if command -v gitleaks >/dev/null 2>&1; then
|
||||||
|
gitleaks detect \
|
||||||
|
--source "${REPO_ROOT}" \
|
||||||
|
--report-format json \
|
||||||
|
--report-path "${report_file}" \
|
||||||
|
--redact
|
||||||
|
else
|
||||||
|
require_docker
|
||||||
|
docker run --rm \
|
||||||
|
-v "${REPO_ROOT}:/repo:ro" \
|
||||||
|
-v "${SECURITY_REPORT_DIR}:/reports:rw" \
|
||||||
|
"${GITLEAKS_IMAGE}" detect \
|
||||||
|
--source /repo \
|
||||||
|
--report-format json \
|
||||||
|
--report-path "/reports/gitleaks-${stamp}.json" \
|
||||||
|
--redact
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "gitleaks report: ${report_file}"
|
||||||
|
}
|
||||||
|
|
||||||
scan_targets() {
|
scan_targets() {
|
||||||
local target_override="$1"
|
local target_override="$1"
|
||||||
|
|
||||||
|
|
@ -483,6 +514,7 @@ EOF
|
||||||
case "${1:-all}" in
|
case "${1:-all}" in
|
||||||
all)
|
all)
|
||||||
run_trivy
|
run_trivy
|
||||||
|
run_gitleaks
|
||||||
run_zap
|
run_zap
|
||||||
;;
|
;;
|
||||||
prepare)
|
prepare)
|
||||||
|
|
@ -491,6 +523,9 @@ case "${1:-all}" in
|
||||||
trivy)
|
trivy)
|
||||||
run_trivy
|
run_trivy
|
||||||
;;
|
;;
|
||||||
|
secrets)
|
||||||
|
run_gitleaks
|
||||||
|
;;
|
||||||
zap)
|
zap)
|
||||||
run_zap
|
run_zap
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ Use Jeannie from the Debian homelab host:
|
||||||
The default `security-scan` runs:
|
The default `security-scan` runs:
|
||||||
|
|
||||||
- Trivy filesystem and IaC/config scans against this repo.
|
- Trivy filesystem and IaC/config scans against this repo.
|
||||||
|
- gitleaks secret scans against this repo.
|
||||||
- OWASP ZAP baseline passive scans against `security/targets.txt`.
|
- OWASP ZAP baseline passive scans against `security/targets.txt`.
|
||||||
|
|
||||||
The focused commands are:
|
The focused commands are:
|
||||||
|
|
@ -28,6 +29,7 @@ The focused commands are:
|
||||||
- `security-host`: Lynis host audit summary for Debian. This command is
|
- `security-host`: Lynis host audit summary for Debian. This command is
|
||||||
report-only and prints one highest-risk finding to focus on first.
|
report-only and prints one highest-risk finding to focus on first.
|
||||||
- `security-trivy`: Trivy repo and IaC/config scans only.
|
- `security-trivy`: Trivy repo and IaC/config scans only.
|
||||||
|
- `security-secrets`: gitleaks repo secret scan only.
|
||||||
- `security-nuclei`: low-rate nuclei HTTP exposure scans only.
|
- `security-nuclei`: low-rate nuclei HTTP exposure scans only.
|
||||||
- `security-web`: quick HTTPS, status, and defensive-header checks for owned
|
- `security-web`: quick HTTPS, status, and defensive-header checks for owned
|
||||||
web targets.
|
web targets.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue