forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (155 loc) · 5.56 KB
/
codeql.yml
File metadata and controls
166 lines (155 loc) · 5.56 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: "CodeQL"
on:
schedule:
- cron: '27 21 * * *' # At 21:27 every day
jobs:
analyze:
name: Analyze
runs-on: kibana
permissions:
actions: read
contents: read
security-events: write
if: github.repository == 'elastic/kibana' # Hack: Do not run on forks
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
branch: [ 'main', '8.19' ]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ matrix.branch }}
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
# TODO: Possibly required to follow all call paths, however, when enabled, the step below runs out of memory.
# Possible workarounds: Apply for access to the GitHub beta where we can use beefier machines, or run it ourselves on Buildkite
# - name: yarn kbn bootstrap
# run: |
# mkdir ~/.npm-global
# npm config set prefix '~/.npm-global'
# export PATH=~/.npm-global/bin:$PATH
# yarn kbn bootstrap --no-validate --no-vscode
- name: Set sha and branch
run: |
echo "CHECKOUT_REF=$(git symbolic-ref HEAD)" >> "$GITHUB_ENV"
echo "CHECKOUT_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
id: analyze
env:
NODE_OPTIONS: "--max-old-space-size=8192"
CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES: true
with:
category: "/language:${{matrix.language}}"
ref: ${{ env.CHECKOUT_REF }}
sha: ${{ env.CHECKOUT_SHA }}
output: sarif-results
- name: Dismiss alerts
id: dismiss-alerts
continue-on-error: true
uses: advanced-security/dismiss-alerts@046d6b48d2e43cf563f96f67332c47c432eff83e # 2.0.2
env:
GITHUB_TOKEN: ${{secrets.KIBANAMACHINE_TOKEN}}
with:
sarif-id: ${{ steps.analyze.outputs.sarif-id }}
sarif-file: sarif-results/${{ matrix.language }}.sarif
- name: Notify Slack on suppression failure
if: steps.dismiss-alerts.outcome == 'failure'
continue-on-error: true
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.CODE_SCANNING_SLACK_TOKEN }}
payload: |
channel: ${{ secrets.CODE_SCANNING_SLACK_CHANNEL_ID }}
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":warning: CodeQL alerts suppression step failed for ${{ github.repository }}."
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Workflow Run"
},
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
alert:
name: Alert
runs-on: ubuntu-latest
needs: analyze
if: ${{ github.repository == 'elastic/kibana' && success() }} # Hack: Do not run on forks
steps:
- name: Checkout kibana-operations
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: 'elastic/kibana-operations'
ref: main
path: ./kibana-operations
token: ${{secrets.KIBANAMACHINE_TOKEN}}
persist-credentials: false
- name: CodeQL alert
working-directory: ./kibana-operations/triage
env:
GITHUB_TOKEN: ${{secrets.KIBANAMACHINE_TOKEN}}
GITHUB_REPO: kibana
SLACK_TOKEN: ${{secrets.CODE_SCANNING_SLACK_TOKEN}}
SLACK_CHANNEL: ${{secrets.CODE_SCANNING_SLACK_CHANNEL_ID}}
CODE_SCANNING_ES_HOST: ${{secrets.CODE_SCANNING_ES_HOST}}
CODE_SCANNING_ES_API_KEY: ${{secrets.CODE_SCANNING_ES_API_KEY}}
CODE_SCANNING_INDEX_NAME: appex-codeql-alerts
CODE_SCANNING_BRANCHES: main,8.19
run: |
npm ci --omit=dev
node codeql-alert
notify_on_failure:
name: Failure notification
runs-on: ubuntu-latest
needs: analyze
if: failure()
steps:
- name: Send notification to slack
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.CODE_SCANNING_SLACK_TOKEN }}
payload: |
channel: ${{ secrets.CODE_SCANNING_SLACK_CHANNEL_ID }}
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":broken_heart: CodeQL analysis failed for ${{ github.repository }}."
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Workflow Run"
},
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]