-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (186 loc) · 7.72 KB
/
Copy pathsecurity-scan.yml
File metadata and controls
204 lines (186 loc) · 7.72 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Security Scan (Reusable)
on:
workflow_call:
inputs:
default_branch:
description: 'Default branch of the fork'
required: true
type: string
jobs:
find-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
pr_number: ${{ steps.find.outputs.pr_number }}
has_pr: ${{ steps.find.outputs.has_pr }}
steps:
- name: Checkout shared-workflows scripts
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
repository: tyler-technologies-oss/external-action-shared-workflows
ref: ${{ github.job_workflow_sha }}
sparse-checkout: scripts
path: .shared-workflows
- name: Find open sync PR
id: find
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
DEFAULT_BRANCH: ${{ inputs.default_branch }}
run: bash .shared-workflows/scripts/security-scan/find-sync-pr.sh
dependency-review:
needs: find-pr
if: needs.find-pr.outputs.has_pr == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout upstream-tracking
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: upstream-tracking
- name: Dependency review
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5
with:
base-ref: refs/heads/${{ inputs.default_branch }}
head-ref: refs/heads/upstream-tracking
fail-on-severity: high
comment-summary-in-pr: never
continue-on-error: true
diff-summary:
needs: find-pr
if: needs.find-pr.outputs.has_pr == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout fork
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
- name: Checkout shared-workflows scripts
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
repository: tyler-technologies-oss/external-action-shared-workflows
ref: ${{ github.job_workflow_sha }}
sparse-checkout: scripts
path: .shared-workflows
- name: Generate diff analysis
id: diff
env:
DEFAULT_BRANCH: ${{ inputs.default_branch }}
run: bash .shared-workflows/scripts/security-scan/generate-diff-analysis.sh
- name: Analyze composite action changes
id: composite
if: steps.diff.outputs.manifest_changes != 'None'
env:
BASE_SHA: ${{ steps.diff.outputs.base_sha }}
HEAD_SHA: ${{ steps.diff.outputs.head_sha }}
run: bash .shared-workflows/scripts/security-scan/analyze-composite-changes.sh
- name: Create security alert for composite action changes
if: |
steps.composite.outputs.has_composite_findings == 'true' && (
steps.composite.outputs.changed_refs != 'None' ||
contains(steps.composite.outputs.run_mod_summary, 'MODIFIED') ||
steps.composite.outputs.unpinned_refs != 'None' ||
steps.composite.outputs.using_change != 'None'
)
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
env:
PR_NUMBER: ${{ needs.find-pr.outputs.pr_number }}
CHANGED_REFS: ${{ steps.composite.outputs.changed_refs }}
RUN_MOD: ${{ steps.composite.outputs.run_mod_summary }}
UNPINNED: ${{ steps.composite.outputs.unpinned_refs }}
USING_CHANGE: ${{ steps.composite.outputs.using_change }}
ADDED_USES: ${{ steps.composite.outputs.added_uses }}
ADDED_RUNS: ${{ steps.composite.outputs.added_runs }}
with:
script: |
const fn = require('./.shared-workflows/scripts/security-scan/create-composite-alert.js');
await fn({ github, context });
- name: Post diff summary as PR comment
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
env:
PR_NUMBER: ${{ needs.find-pr.outputs.pr_number }}
FILES_CHANGED: ${{ steps.diff.outputs.files_changed }}
LINES_ADDED: ${{ steps.diff.outputs.lines_added }}
LINES_REMOVED: ${{ steps.diff.outputs.lines_removed }}
MANIFEST_CHANGES: ${{ steps.diff.outputs.manifest_changes }}
SCRIPT_CHANGES: ${{ steps.diff.outputs.script_changes }}
BINARY_CHANGES: ${{ steps.diff.outputs.binary_changes }}
HAS_COMPOSITE: ${{ steps.composite.outputs.has_composite_findings }}
COMPOSITE_USING: ${{ steps.composite.outputs.using_change }}
COMPOSITE_ADDED_USES: ${{ steps.composite.outputs.added_uses }}
COMPOSITE_REMOVED_USES: ${{ steps.composite.outputs.removed_uses }}
COMPOSITE_CHANGED_REFS: ${{ steps.composite.outputs.changed_refs }}
COMPOSITE_ADDED_RUNS: ${{ steps.composite.outputs.added_runs }}
COMPOSITE_RUN_MOD: ${{ steps.composite.outputs.run_mod_summary }}
COMPOSITE_UNPINNED: ${{ steps.composite.outputs.unpinned_refs }}
with:
script: |
const fn = require('./.shared-workflows/scripts/security-scan/post-diff-summary.js');
await fn({ github, context });
codeql:
needs: find-pr
if: needs.find-pr.outputs.has_pr == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
security-events: write
steps:
- name: Checkout upstream-tracking
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: upstream-tracking
- name: Get HEAD SHA
id: sha
run: echo "value=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Initialize CodeQL
id: codeql-init
uses: github/codeql-action/init@bb471cdcf4dda2c934c5b656f554d43c1434ed13 # v4
with:
languages: javascript-typescript
continue-on-error: true
- name: Autobuild
if: steps.codeql-init.outcome == 'success'
uses: github/codeql-action/autobuild@bb471cdcf4dda2c934c5b656f554d43c1434ed13 # v4
continue-on-error: true
- name: Run CodeQL analysis
if: steps.codeql-init.outcome == 'success'
uses: github/codeql-action/analyze@bb471cdcf4dda2c934c5b656f554d43c1434ed13 # v4
with:
category: "/language:javascript-typescript"
ref: refs/heads/upstream-tracking
sha: ${{ steps.sha.outputs.value }}
continue-on-error: true
report-status:
needs: [find-pr, dependency-review, diff-summary, codeql]
if: always() && needs.find-pr.outputs.has_pr == 'true'
runs-on: ubuntu-latest
permissions:
statuses: write
checks: write
pull-requests: read
steps:
- name: Checkout shared-workflows scripts
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
repository: tyler-technologies-oss/external-action-shared-workflows
ref: ${{ github.job_workflow_sha }}
sparse-checkout: scripts
path: .shared-workflows
- name: Report scan statuses on PR
env:
GH_TOKEN: ${{ github.token }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ needs.find-pr.outputs.pr_number }}
DEP_REVIEW_RESULT: ${{ needs.dependency-review.result }}
DIFF_SUMMARY_RESULT: ${{ needs.diff-summary.result }}
CODEQL_RESULT: ${{ needs.codeql.result }}
run: bash .shared-workflows/scripts/security-scan/report-scan-statuses.sh