diff --git a/scripts/ci.sh b/scripts/ci.sh index 00fda5a..71c6648 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -6,6 +6,10 @@ set -euo pipefail +# Keep in step with .github/workflows/ci.yml — a local run that uses a +# different gosec can pass while CI fails. +GOSEC_VERSION="v2.28.0" + # Add Go bin to PATH export PATH="$PATH:$(go env GOPATH)/bin" @@ -91,25 +95,18 @@ fi # Step 6: Run gosec print_step "Running security scan (gosec)" -if command -v gosec &> /dev/null; then - # Run gosec with same config as CI - if gosec -fmt json -out gosec-report.json -stdout -verbose=text -severity medium ./...; then - print_success "Security scan passed" - rm -f gosec-report.json - else - print_error "Security scan failed" - FAILED=1 - fi +# Match .github/workflows/ci.yml exactly: pinned version, no severity filter. +# A -severity medium filter would hide LOW findings that fail in CI, and a +# different gosec can differ on which rules exist at all. `go run` with the +# pinned version is used even when a gosec is already on PATH, because that +# one may be any version. +if go run "github.com/securego/gosec/v2/cmd/gosec@$GOSEC_VERSION" \ + -fmt json -out gosec-report.json -stdout -verbose=text ./...; then + print_success "Security scan passed" + rm -f gosec-report.json else - echo "gosec not installed, installing..." - go install github.com/securego/gosec/v2/cmd/gosec@latest - if gosec -fmt json -out gosec-report.json -stdout -verbose=text -severity medium ./...; then - print_success "Security scan passed" - rm -f gosec-report.json - else - print_error "Security scan failed" - FAILED=1 - fi + print_error "Security scan failed" + FAILED=1 fi # Step 7: Check for unchecked errors