Skip to content

Commit 44bf818

Browse files
committed
ATM: add PR check running the boosted queries
1 parent ce1092c commit 44bf818

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed
Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,79 @@
11
name: ATM Check Queries Run
22

3-
# This check is required, therefore we must run it on all PRs, even if only Markdown has changed.
3+
env:
4+
AZURE_STORAGE_URL: "https://atmcodeqldata.blob.core.windows.net"
5+
DB_NAME: "AmanSultanBaig/SignIn-SignUp-System-with-Nodejs"
6+
DB_PATH: test_db
7+
MODEL_BULDING_PACK_PATH: javascript/ql/experimental/adaptivethreatmodeling/modelbuilding
8+
QUERY_SUITE: javascript/ql/experimental/adaptivethreatmodeling/src/codeql-suites/javascript-atm-code-scanning.qls
9+
410
on:
11+
pull_request:
12+
paths:
13+
- "javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/codeql-pack.lock.yml"
14+
- "javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/qlpack.yml"
15+
- "javascript/experimental/adpativethreatmodeling/src/qlpack.yml"
16+
- "javascript/experimental/adpativethreatmodeling/src/codeql-pack.lock.yml"
517
workflow_dispatch:
618

719
jobs:
8-
hello-world:
20+
run-atm-queries:
921
runs-on: ubuntu-latest
1022

1123
steps:
12-
- name: foo
13-
run: echo "Hello world"
24+
- uses: actions/checkout@v3
25+
with:
26+
path: codeql-lib
27+
28+
- name: Install CodeQL CLI
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
gh extensions install github/gh-codeql
33+
gh codeql download
34+
35+
- name: Download model pack
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
STORAGE_SAS: ${{ secrets.AZURE_BLOB_STORAGE_ATMCODEQLDATA_SAS }}
39+
run: |
40+
echo "::group::Download ATM model pack"
41+
set -exu
42+
43+
# Get pack version and checksum
44+
pack_version=$(yq '.dependencies.codeql/javascript-experimental-atm-model' ./codeql-lib/${MODEL_BULDING_PACK_PATH}/qlpack.yml )
45+
model_checksum="${pack_version##*.}"
46+
echo "Will use pack model ${pack_version} with model checksum ${model_checksum}."
47+
48+
# Download the model to the package cache
49+
tmp_dir=$(mktemp -d)
50+
gh codeql pack download codeql/javascript-experimental-atm-model@${pack_version}
51+
52+
# Trust the model so that we can use it in the ATM boosted queries
53+
mkdir -p "$HOME/.config/codeql"
54+
echo "--insecurely-execute-ml-model-checksums ${model_checksum}" >> "$HOME/.config/codeql/config"
55+
echo "::endgroup::"
56+
57+
- name: Create test DB
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
run: |
61+
echo "::group::Create test database"
62+
gh repo clone ${DB_NAME} -- --depth 1
63+
gh codeql database create ${DB_PATH} --language javascript
64+
echo "::endgroup::"
65+
66+
- name: Run ATM query suite
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run: |
70+
echo "::group::Run boosted query suite"
71+
gh codeql database run-queries -vv -- ${DB_PATH} codeql-lib/${QUERY_SUITE}
72+
if [[ $? -ne 0 ]]; then
73+
echo "Failed to run the ATM query suite."
74+
exit 1
75+
else
76+
echo "Successfully run ATM query suite."
77+
fi
78+
echo "::endgroup::"
79+

0 commit comments

Comments
 (0)