github-actions

SAST Reusable Workflow

Reusable workflows must be kept in the .github/workflows directory, find the SAST reusable workflow at the link below:

The workflow also utilises GitHub Policy as Code for CodeQL scans, to allow teams to break builds where security issues are over SLA, to highlight where malicious typosquatting packages have been accidentally included in the build, and to raise Dependabot, CodeQL, Secret Scanning and Licensing issues in the pipeline.

Policy information can be found at .github/policy-as-code:

[!WARNING] DfE do not currently pay for GitHub Advanced Security, so this workflow runs CodeQL for SAST scans if the repository is public (as it’s free for public repos). Otherwise, we will utilise semgrep open source SAST. The policy as code feature will also only work for CodeQL scans.

Purpose

  1. Provide DfE services with an easy to use workflow for static code analysis, to improve the security and quality of code.
  2. To provide the ability to (optionally) stop deployments if security issues are found to be over SLA and to highlight issues in the pipeline found for CodeQL, Dependabot and GitHub Secret Scanning (only works for public repos).

Input Parameters

Secrets

[!IMPORTANT] In order for the compliance job to run, you must provide the CODEQL_AUTHENTICATION_PRIVATE_KEY and CODEQL_APP_ID secrets, they have been made available as organisation secrets, so you simply need to reference it in your workflow job.

Examples

.NET

jobs:
  run-codeql:
    uses: DFE-Digital/github-actions/.github/workflows/reusable-workflow-sast.yml@master
    with:
      language: 'csharp' 
      dotnet_project_locations: '["./"]' 
      dotnet_version: '6.0.*' 
      policy_action: 'break'
      nuget-source-url: 'https://nuget.pkg.github.com/DfE-Digital/index.json' # only required if you're using a private nuget source
    secrets:
      CODEQL_AUTHENTICATION_PRIVATE_KEY: $ 
      CODEQL_APP_ID: $
      NUGET_AUTH_TOKEN: $ # if private


Ruby

jobs:
  run-codeql:
    uses: DFE-Digital/github-actions/.github/workflows/reusable-workflow-sast.yml@master
    with:
      language: 'ruby' 
      policy_action: 'break'
      queries: 'security-extended'
    secrets:
      CODEQL_AUTHENTICATION_PRIVATE_KEY: $