Skip to content

Commit f8fb807

Browse files
committed
feat(ci): enhance build workflow to include submodule checkout and CodeQL analysis for multiple projects
1 parent 7dbab8d commit f8fb807

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
steps:
2020
- name: "Checkout"
2121
uses: actions/checkout@v5
22+
with:
23+
submodules: true
2224

2325
- name: "Check for changes"
2426
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
@@ -67,6 +69,81 @@ jobs:
6769
run: |
6870
./scripts/run-tests.sh "ql/test/${{ matrix.test-folders }}"
6971
72+
scanning:
73+
runs-on: ubuntu-latest
74+
needs: [tests]
75+
76+
strategy:
77+
matrix:
78+
project: ["hashicorp/terraform-guides", "akamai/terraform-examples", "aws-samples/aws-sam-terraform-examples"]
79+
80+
steps:
81+
- name: "Checkout"
82+
uses: actions/checkout@v5
83+
with:
84+
submodules: true
85+
86+
- name: "Checkout"
87+
uses: actions/checkout@v5
88+
with:
89+
repository: ${{ matrix.project }}
90+
path: project
91+
92+
- name: "Check for changes"
93+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
94+
id: extractor-changes
95+
with:
96+
filters: |
97+
src:
98+
- 'extractor/**'
99+
- 'rust-toolchain.toml'
100+
- 'Cargo.*'
101+
102+
- name: "Download Extracter"
103+
if: steps.extractor-changes.outputs.src == 'false'
104+
env:
105+
GH_TOKEN: ${{ github.token }}
106+
run: |
107+
set -e
108+
gh release list -L 1 -R "advanced-security/codeql-extractor-iac"
109+
110+
gh release download \
111+
-R "advanced-security/codeql-extractor-iac" \
112+
--clobber \
113+
--pattern 'extractor-iac.tar.gz'
114+
115+
tar -zxf extractor-iac.tar.gz
116+
117+
- uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable
118+
if: steps.extractor-changes.outputs.src == 'true'
119+
120+
- name: "Build Extractor"
121+
if: steps.extractor-changes.outputs.src == 'true'
122+
env:
123+
GH_TOKEN: ${{ github.token }}
124+
run: |
125+
set -e
126+
gh extensions install github/gh-codeql
127+
gh codeql set-version latest
128+
129+
./scripts/create-extractor-pack.sh
130+
131+
gh codeql resolve languages --format=json --search-path ./extractor-pack
132+
133+
- name: "Run CodeQL Analysis"
134+
env:
135+
GH_TOKEN: ${{ github.token }}
136+
PROJECT_REPO: ${{ matrix.project }}
137+
run: |
138+
set -e
139+
gh extensions install github/gh-codeql
140+
gh codeql set-version latest
141+
142+
gh codeql database create iac-db --language=hcl --source-root=./project --search-path ./extractor-pack
143+
144+
gh codeql database analyze iac-db "codeql-queries/iac-queries" --format=sarifv2.1.0 --output="iac-${PROJECT_REPO}.sarif"
145+
146+
70147
docs:
71148
runs-on: ubuntu-latest
72149
steps:

0 commit comments

Comments
 (0)