Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
Loading