SecOps #4
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: SecOps | |
on: | |
workflow_dispatch: | |
workflow_call: | |
schedule: | |
- cron: '34 8 * * 4' | |
jobs: | |
codeql-analyze: | |
permissions: | |
security-events: write | |
# only required for workflows in private repositories | |
# actions: read | |
# contents: read | |
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} | |
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [ 'go' ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: ${{ matrix.language }} | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v3 | |
- name: Perform CodeQL Analysis | |
id: analyze | |
uses: github/codeql-action/analyze@v3 | |
with: | |
category: "/language:${{matrix.language}}" | |
- name: Format and print GH step summary | |
if: always() | |
run: | | |
echo "| Key | Value |" >> $GITHUB_STEP_SUMMARY | |
echo "|:--|:--|" >> $GITHUB_STEP_SUMMARY | |
echo "| **codeql** | ${{ steps.analyze.outcome }} |" >> $GITHUB_STEP_SUMMARY | |
echo "| **codeql_verbosity** | $CODEQL_VERBOSITY |" >> $GITHUB_STEP_SUMMARY | |
trivy: | |
permissions: | |
contents: read | |
security-events: write | |
# private repos only | |
# actions: read | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout default branch | |
uses: actions/checkout@v4 | |
- name: Run Trivy vulnerability scanner in fs mode | |
id: trivy-scan | |
uses: aquasecurity/[email protected] | |
with: | |
scan-type: 'fs' | |
ignore-unfixed: true | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: 'trivy-results.sarif' | |
- name: Format and print GH step summary | |
if: always() | |
run: | | |
echo "| Key | Value |" >> $GITHUB_STEP_SUMMARY | |
echo "|:--|:--|" >> $GITHUB_STEP_SUMMARY | |
echo "| **trivy** | ${{ steps.trivy-scan.outcome }} |" >> $GITHUB_STEP_SUMMARY | |
echo "| **trivy_ignore_unfixed** | $TRIVY_IGNORE_UNFIXED |" >> $GITHUB_STEP_SUMMARY | |
echo "| **trivy_severity** | $TRIVY_SEVERITY |" >> $GITHUB_STEP_SUMMARY |