Skip to content

chore(deps): update github actions #974

chore(deps): update github actions

chore(deps): update github actions #974

Workflow file for this run

name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "23 6 * * 1"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: javascript-typescript
build-mode: none
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Initialize CodeQL
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: ./.github/codeql/codeql-config.yml
queries: security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
with:
category: /language:${{ matrix.language }}
output: sarif-results
- name: Gate on high/critical severity
env:
LANG_CATEGORY: ${{ matrix.language }}
run: |
set -euo pipefail
shopt -s nullglob
read -r -d '' JQ_FILTER <<'JQ' || true
.runs[] as $run
| $run.results[]
| . as $r
| [ $run.tool.driver.rules[] | select(.id == $r.ruleId) ][0] as $rule
| (
($r.properties["security-severity"] // $rule.properties["security-severity"] // "0")
| tonumber
) as $sev
| select($sev >= 7.0)
| [
$r.ruleId,
($sev | tostring),
($r.locations[0].physicalLocation.artifactLocation.uri // "unknown"),
($r.locations[0].physicalLocation.region.startLine // 0 | tostring),
($r.message.text | gsub("[\n\t]"; " "))
] | @tsv
JQ
total=0
for f in sarif-results/*.sarif; do
mapfile -t findings < <(jq -r "$JQ_FILTER" "$f")
if [ "${#findings[@]}" -gt 0 ]; then
echo "::group::$(basename "$f") — ${#findings[@]} high/critical finding(s)"
for line in "${findings[@]}"; do
IFS=$'\t' read -r rule sev uri lineno msg <<<"$line"
echo " [$rule severity=$sev] $uri:$lineno — $msg"
done
echo "::endgroup::"
total=$((total + ${#findings[@]}))
fi
done
if [ "$total" -gt 0 ]; then
echo "::error::${total} high/critical severity CodeQL finding(s) in ${LANG_CATEGORY}. Fix them, or dismiss with justification in the Security tab if a false positive."
exit 1
fi
echo "No high/critical CodeQL findings in ${LANG_CATEGORY}."