ci-security-scanner-checks #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci-security-scanner-checks | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" | |
permissions: | |
contents: read | |
jobs: | |
trivy_scan: | |
name: trivy-scans | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@d2a392a13760cb64cb6bbd31d4bed2a7d9a5298d # master | |
with: | |
scan-type: 'fs' | |
scan-ref: '.' | |
format: 'sarif' | |
severity: 'CRITICAL,HIGH' | |
output: 'trivy-results.sarif' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 | |
with: | |
sarif_file: 'trivy-results.sarif' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
snyk_scan: | |
name: snyk-scans | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: snyk/actions/setup@cdb760004ba9ea4d525f2e043745dfe85bb9077e # master | |
- name: Get Go Version | |
run: | | |
#!/bin/bash | |
GOVERSION=$({ [ -f .go-version ] && cat .go-version; }) | |
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GOVERSION }} | |
- name: Run Snyk to check for vulnerabilities | |
uses: snyk/actions/golang@cdb760004ba9ea4d525f2e043745dfe85bb9077e # master | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_AUTH_TOKEN }} | |
with: | |
args: --sarif-file-output=snyk-results.sarif | |
- name: Upload result to GitHub Code Scanning | |
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 | |
with: | |
sarif_file: 'snyk-results.sarif' | |
nancy_check: | |
name: nancy-check | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Go Version | |
run: | | |
#!/bin/bash | |
GOVERSION=$({ [ -f .go-version ] && cat .go-version; }) | |
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GOVERSION }} | |
- name: WriteGoList | |
run: go list -json -m all > go.list | |
- name: Nancy | |
uses: sonatype-nexus-community/nancy-github-action@395e2fb168f674f96502e5652103d112899ea369 # main | |
with: | |
nancyVersion: "v1.0.46" | |
nancyCommand: sleuth --loud | |
ossf_scan: | |
name: openssf-scorecard | |
runs-on: ubuntu-20.04 | |
permissions: | |
security-events: write | |
id-token: write | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Run analysis | |
uses: ossf/scorecard-action@72803a12483ed6f4f7c34f804818169f50162e37 # main | |
with: | |
results_file: 'ossf-results.sarif' | |
results_format: sarif | |
publish_results: true | |
- name: Upload artifact | |
uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # main | |
with: | |
name: 'OSSF Sarif file' | |
path: 'ossf-results.sarif' | |
retention-days: 5 | |
- name: Upload result to GitHub Code Scanning | |
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 | |
with: | |
sarif_file: 'ossf-results.sarif' |