Skip to content

SAST

SAST #377

Workflow file for this run

name: 'SAST'
# Static Application Security Testing
on:
push:
branches:
- master
- release/*/*
pull_request:
branches: [master]
schedule:
- cron: '26 11 * * 0'
permissions:
actions: read # for github/codeql-action
contents: write # for actions/checkout to fetch code
pull-requests: write # Needed for dorny/paths-filter
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
jobs:
paths:
name: Check changed paths
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
if: github.event_name != 'schedule'
id: changes
with:
filters: |
packages:
- '**/package.json'
outputs:
changed: ${{ steps.changes.outputs.packages == 'true' }}
trivy:
name: Trivy
runs-on: ubuntu-latest
needs: paths
if: always() && (github.event_name == 'push' || github.event_name == 'schedule' || needs.paths.outputs.changed == 'true')
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .trivy_cache
key: ${{ runner.os }}-trivy-v1
- uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
format: github.event_name == 'pull_request' && 'table' || 'sarif'
output: github.event_name == 'pull_request' && 'trivy-results.sarif' || ''
exit-code: '1'
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
cache-dir: .trivy_cache
- name: Upload scan results to GitHub
if: github.event_name != 'pull_request' && failure()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
semgrep:
name: Semgrep
runs-on: ubuntu-latest
container:
# A Docker image with Semgrep installed. Do not change this.
image: semgrep/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
- run: semgrep ci
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
- name: Annotate
if: github.event_name == 'pull_request' && failure()
run: jq -r '.results[] | "::error file=\(.path),line=\(.start.line),lineEnd=\(.end.line),col=\(.start.col),endColumn=\(.end.col),title=[\(.extra.severity)]\(.check_id)::\(.extra.message)"' semgrep.json
- name: Upload scan results to GitHub
if: github.event_name != 'pull_request' && failure()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'semgrep.sarif'
codeql:
name: CodeQL
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'javascript'
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
job_success:
name: SAST Safe
runs-on: ubuntu-latest
needs:
- trivy
- semgrep
- codeql
# This is needed to make sure this job always runs even if others got skipped
if: always()
timeout-minutes: 3
steps:
- working-directory: ${{ github.workspace }}
run: |-
[ "${{ contains(needs.*.result, 'failure') }}" = "false" ]