Repository navigation
118 lines (108 loc) · 3.99 KB
/
Copy pathcodeql.yml
File metadata and controls
118 lines (108 loc) · 3.99 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Reusable workflow: CodeQL static analysis.
#
# Languages (JSON list): go, javascript-typescript, actions, python, java-kotlin, ...
# `actions` analyses the workflow files themselves (injection, untrusted checkout).
# Go is built with autobuild unless `go-build-command` is given.
#
# Free for public repositories; private repositories need GitHub Code Security.
# Required caller permissions: contents: read, security-events: write, actions: read
name: CodeQL
on:
workflow_call:
inputs:
languages:
type: string
default: '["actions"]'
queries:
description: Query suite (security-extended, security-and-quality, or empty for default).
type: string
default: security-extended
go-version-file:
description: go.mod used to set up Go (for the go language).
type: string
default: go.mod
go-build-command:
description: Manual build command for Go (e.g. "cd backend && go build ./..."). Empty = autobuild.
type: string
default: ""
config-file:
description: Optional CodeQL config file (paths-ignore, etc.).
type: string
default: ""
timeout-minutes:
type: number
default: 60
permissions: {}
jobs:
analyze:
name: analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
concurrency:
group: codeql-${{ github.workflow }}-${{ matrix.language }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
permissions:
contents: read
security-events: write
actions: read
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(inputs.languages) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
if: matrix.language == 'go'
with:
go-version-file: ${{ inputs.go-version-file }}
cache: false
- name: Build mode
id: mode
env:
LANGUAGE: ${{ matrix.language }}
GO_BUILD: ${{ inputs.go-build-command }}
run: |
case "$LANGUAGE" in
go) if [ -n "$GO_BUILD" ]; then m=manual; else m=autobuild; fi ;;
c-cpp|swift) m=autobuild ;;
*) m=none ;;
esac
echo "mode=$m" >> "$GITHUB_OUTPUT"
# Callers reference these workflows by the moving v1 tag on purpose, so
# actions/unpinned-tag would flag every caller. zizmor requires a SHA for
# every other action. `config` takes precedence over `config-file`, so the
# caller's file is merged in here.
- name: Config
id: config
env:
CONFIG_FILE: ${{ inputs.config-file }}
run: |
set -euo pipefail
filter='{"exclude": {"id": "actions/unpinned-tag"}}'
if [ -n "$CONFIG_FILE" ]; then
config="$(yq -o yaml ".\"query-filters\" += [$filter]" "$CONFIG_FILE")"
else
config="$(yq -n -o yaml ".\"query-filters\" = [$filter]")"
fi
echo "$config"
{
echo "config<<EOF_CODEQL_CONFIG"
echo "$config"
echo "EOF_CODEQL_CONFIG"
} >> "$GITHUB_OUTPUT"
- uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
languages: ${{ matrix.language }}
build-mode: ${{ steps.mode.outputs.mode }}
queries: ${{ inputs.queries }}
config: ${{ steps.config.outputs.config }}
- name: Build (manual)
if: steps.mode.outputs.mode == 'manual'
env:
GO_BUILD: ${{ inputs.go-build-command }}
run: bash -euo pipefail -c "$GO_BUILD"
- uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
category: /language:${{ matrix.language }}