|
| 1 | +name: Security Scan Matrix |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * 0' # Run weekly on Sundays |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + security-events: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + gosec-matrix: |
| 17 | + name: Security Scan on Multiple Platforms |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false # Continue with other matrix jobs even if one fails |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 23 | + go-version: ['1.24'] |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Go ${{ matrix.go-version }} |
| 29 | + uses: actions/setup-go@v5 |
| 30 | + with: |
| 31 | + go-version: ${{ matrix.go-version }} |
| 32 | + check-latest: true |
| 33 | + |
| 34 | + - name: Verify dependencies |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + go mod download |
| 38 | + go mod tidy |
| 39 | + # Ensure go.sum exists |
| 40 | + if [ ! -f "go.sum" ]; then |
| 41 | + touch go.sum |
| 42 | + fi |
| 43 | +
|
| 44 | + # Use the gosec GitHub Action for Windows |
| 45 | + - name: Run gosec with GitHub Action (Windows) |
| 46 | + if: runner.os == 'Windows' |
| 47 | + uses: securego/gosec@v2.19.0 |
| 48 | + with: |
| 49 | + args: "-fmt sarif -out gosec-results.sarif ./stl" |
| 50 | + |
| 51 | + # Direct installation for Linux and macOS |
| 52 | + - name: Install and run gosec (Linux/macOS) |
| 53 | + if: runner.os != 'Windows' |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + # Direct installation of gosec |
| 57 | + go install github.com/securego/gosec/v2/cmd/gosec@latest |
| 58 | + # Verify gosec installation |
| 59 | + which gosec || echo "gosec not found in PATH" |
| 60 | + # Run gosec with full output |
| 61 | + gosec -fmt=json -out=gosec-results.json ./stl || echo "gosec JSON output failed" |
| 62 | + gosec -fmt=sarif -out=gosec-results.sarif ./stl || echo "gosec SARIF output failed" |
| 63 | + # Show results summary |
| 64 | + gosec ./stl || echo "gosec scan failed" |
| 65 | + |
| 66 | + - name: Upload gosec results |
| 67 | + uses: github/codeql-action/upload-sarif@v3 |
| 68 | + if: always() |
| 69 | + with: |
| 70 | + sarif_file: gosec-results.sarif |
| 71 | + category: gosec-${{ matrix.os }} |
0 commit comments