|
| 1 | +# https://github.com/Checkmarx/kics |
| 2 | +# https://github.com/Checkmarx/kics/blob/master/docs/integrations_ghactions.md |
| 3 | +# https://github.com/Checkmarx/kics-github-action |
| 4 | + |
| 5 | +name: IaC Scanning with Checkmarx KICS |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + schedule: |
| 13 | + - cron: '15 03 * * 5' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read # for actions/checkout to fetch code |
| 17 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 18 | + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 19 | + |
| 20 | +jobs: |
| 21 | + kics-scan: |
| 22 | + name: Run KICS scan |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Mkdir results-dir |
| 30 | + # make sure results dir is created |
| 31 | + run: mkdir -p results-dir |
| 32 | + |
| 33 | + - name: Run kics Scan |
| 34 | + uses: checkmarx/kics-github-action@v2.1.7 |
| 35 | + with: |
| 36 | + path: 'terraform' |
| 37 | + # when provided with a directory on output_path |
| 38 | + # it will generate the specified reports file named 'results.{extension}' |
| 39 | + # in this example it will generate: |
| 40 | + # - results-dir/results.json |
| 41 | + # - results-dir/results.sarif |
| 42 | + ignore_on_exit: results |
| 43 | + output_path: results-dir |
| 44 | + platform_type: terraform |
| 45 | + output_formats: 'json,sarif' |
| 46 | + enable_comments: true |
| 47 | + |
| 48 | + - name: Show results |
| 49 | + run: | |
| 50 | + cat results-dir/results.sarif |
| 51 | + cat results-dir/results.json |
| 52 | +
|
| 53 | + - name: Upload SARIF file to GitHub Security tab |
| 54 | + uses: github/codeql-action/upload-sarif@v3 |
| 55 | + with: |
| 56 | + sarif_file: results-dir/results.sarif |
0 commit comments