mirror of
https://github.com/securego/gosec.git
synced 2026-06-20 00:15:59 +02:00
Use pull_request_target event so the GOOGLE_API_KEY secret is available when PRs come from forks. Checkout the PR head SHA explicitly since pull_request_target defaults to the base branch. Guard other jobs to skip on pull_request_target to avoid duplicate runs. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
125 lines
3.7 KiB
YAML
125 lines
3.7 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
pull_request_target:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
test:
|
|
if: github.event_name != 'pull_request_target'
|
|
strategy:
|
|
matrix:
|
|
version:
|
|
- go-version: "1.25.8"
|
|
golangci: "latest"
|
|
- go-version: "1.26.1"
|
|
golangci: "latest"
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GO111MODULE: on
|
|
steps:
|
|
- name: Setup go ${{ matrix.version.go-version }}
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ matrix.version.go-version }}
|
|
- name: Checkout Source
|
|
uses: actions/checkout@v6
|
|
- uses: actions/cache@v5
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: lint
|
|
uses: golangci/golangci-lint-action@v9
|
|
with:
|
|
version: ${{ matrix.version.golangci }}
|
|
- name: Run Gosec Security Scanner
|
|
uses: securego/gosec@master
|
|
with:
|
|
args: '-exclude-dir=testdata ./...'
|
|
- name: Run Tests
|
|
run: make test
|
|
- name: Perf Diff
|
|
run: make perf-diff
|
|
taint-perf-guard:
|
|
if: github.event_name != 'pull_request_target'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GO111MODULE: on
|
|
BENCH_COUNT: "5"
|
|
steps:
|
|
- name: Setup go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26.1"
|
|
- name: Checkout Source
|
|
uses: actions/checkout@v6
|
|
- uses: actions/cache@v5
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Check taint benchmark regression
|
|
run: bash tools/check_taint_benchmark.sh
|
|
barry-ai-security-review:
|
|
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
security-events: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Checkout Source
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Run Barry AI Security Review
|
|
id: barry
|
|
uses: ccojocar/barry@main
|
|
continue-on-error: true
|
|
with:
|
|
google-api-key: ${{ secrets.GOOGLE_API_KEY }}
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
false-positive-filtering-instructions: .github/barry/custom-gosec-false-positive-filter
|
|
custom-security-scan-instructions: .github/barry/custom-gosec-security-scan-instructions
|
|
validator-model: gemini-3-flash-preview
|
|
autofix-model: gemini-3-flash-preview
|
|
output-format: sarif
|
|
- name: Upload SARIF to GitHub Security Center
|
|
uses: github/codeql-action/upload-sarif@v4
|
|
if: steps.barry.outcome == 'success'
|
|
with:
|
|
sarif_file: ${{ github.workspace }}/barry-results.sarif
|
|
coverage:
|
|
if: github.event_name != 'pull_request_target'
|
|
needs: [test, taint-perf-guard]
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GO111MODULE: on
|
|
steps:
|
|
- name: Setup go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26.1"
|
|
- name: Checkout Source
|
|
uses: actions/checkout@v6
|
|
- uses: actions/cache@v5
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Create Test Coverage
|
|
run: make test-coverage
|
|
- name: Upload Test Coverage
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: true
|