Repository navigation
85 lines (81 loc) · 3.59 KB
/
Copy pathcodeql.yml
File metadata and controls
85 lines (81 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: CodeQL
# SOC 2: SAST (OA-C-24). Static analysis on push to main, a weekly schedule and
# manual dispatch. Not on pull requests: findings surface after merge. The merge
# queue is disabled, so merge_group does not run today.
on:
push:
branches: [main]
merge_group:
schedule:
- cron: "23 5 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
# Pushes to main share one group: one analysis runs at a time, and the newest
# waiting push replaces an older waiting one, since its tree contains the
# older one's code. Nothing is cancelled once it runs. Merge queue groups,
# schedules and manual dispatches each get a group of their own.
group: ${{ github.workflow }}-${{ (github.event_name == 'push' && github.ref) || github.run_id }}
cancel-in-progress: false
jobs:
analyze:
name: Analyze (${{ matrix.language }})
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read
strategy:
fail-fast: false
matrix:
# javascript-typescript covers packages/desktop and packages/flow/chrome_extension;
# rust covers the Tauri shell under packages/desktop.
language: ["python", "javascript-typescript", "rust"]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
# Pull requests and queue groups analyze a language only when they change
# its files. The job still runs and reports, so the required check never
# waits. Pushes to main and the weekly scan always analyze everything.
- name: Decide whether this change needs the analysis
id: scope
env:
EVENT_NAME: ${{ github.event_name }}
GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }}
LANGUAGE: ${{ matrix.language }}
run: |
set -euo pipefail
case "$EVENT_NAME" in
pull_request) base="HEAD^1" ;;
merge_group)
base="$GROUP_BASE_SHA"
git fetch --no-tags --depth=1 origin "$base" || { echo "run=true" >> "$GITHUB_OUTPUT"; exit 0; }
;;
*) echo "run=true" >> "$GITHUB_OUTPUT"; exit 0 ;;
esac
changed="$(git diff --name-only "$base" HEAD)"
case "$LANGUAGE" in
python) pattern='\.py$|^\.github/codeql/|^\.github/workflows/codeql\.yml$' ;;
# Desktop UI/shell plus the optional Flow Chrome extension (MV3 JS).
javascript-typescript) pattern='^packages/desktop/|^packages/flow/chrome_extension/|^\.github/codeql/|^\.github/workflows/codeql\.yml$' ;;
rust) pattern='^packages/desktop/|^\.github/codeql/|^\.github/workflows/codeql\.yml$' ;;
*) pattern='^packages/desktop/|^\.github/codeql/|^\.github/workflows/codeql\.yml$' ;;
esac
if grep -Eq "$pattern" <<<"$changed"; then run=true; else run=false; fi
echo "run=$run" | tee -a "$GITHUB_OUTPUT"
- name: Initialize CodeQL
if: steps.scope.outputs.run == 'true'
uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
languages: ${{ matrix.language }}
build-mode: none
config-file: ${{ matrix.language != 'python' && './.github/codeql/desktop.yml' || '' }}
- name: Perform CodeQL Analysis
if: steps.scope.outputs.run == 'true'
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
category: "/language:${{ matrix.language }}"