Skip to content

Commit b0c630e

Browse files
committed
Add integration tests for query filters
1 parent 06e27d3 commit b0c630e

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed

Diff for: .github/workflows/expected-queries-runs.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
name: Expected queries runs
2-
env:
3-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42

53
on:
64
push:

Diff for: .github/workflows/query-filters.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Query filters tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- releases/v1
8+
- releases/v2
9+
pull_request:
10+
types:
11+
- opened
12+
- synchronize
13+
- reopened
14+
- ready_for_review
15+
workflow_dispatch: {}
16+
17+
jobs:
18+
expected-queries:
19+
timeout-minutes: 45
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
- name: Prepare test
25+
id: prepare-test
26+
uses: ./.github/prepare-test
27+
with:
28+
version: latest
29+
30+
# Test 1
31+
- uses: ./../action/init
32+
with:
33+
languages: javascript
34+
config-file: ./.github/codeql/codeql-config-query-filters1.yml
35+
tools: ${{ steps.prepare-test.outputs.tools-url }}
36+
db-location: ${{ runner.temp }}/test1
37+
- uses: ./../action/analyze
38+
with:
39+
output: ${{ runner.temp }}/results
40+
upload-database: false
41+
upload: false
42+
env:
43+
TEST_MODE: true
44+
- name: Check Sarif
45+
uses: ./../action/.github/check-sarif
46+
with:
47+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
48+
queries-run: js/zipslip
49+
queries-not-run: js/path-injection
50+
- name: Cleanup after test
51+
run: rm -rf "$RUNNER_TEMP/results"
52+
53+
# Test 2
54+
- uses: ./../action/init
55+
with:
56+
languages: javascript
57+
config-file: ./.github/codeql/codeql-config-query-filters2.yml
58+
tools: ${{ steps.prepare-test.outputs.tools-url }}
59+
db-location: ${{ runner.temp }}/test2
60+
- uses: ./../action/analyze
61+
with:
62+
output: ${{ runner.temp }}/results
63+
upload-database: false
64+
upload: false
65+
env:
66+
TEST_MODE: true
67+
- name: Check Sarif
68+
uses: ./../action/.github/check-sarif
69+
with:
70+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
71+
queries-run: js/zipslip,javascript/example/empty-or-one-block
72+
queries-not-run: js/path-injection
73+
- name: Cleanup after test
74+
run: rm -rf "$RUNNER_TEMP/results"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "CodeQL config 1"
2+
3+
query-filters:
4+
# This should run js/path-injection and js/zipslip
5+
- include:
6+
tags contain: external/cwe/cwe-022
7+
8+
# Removes out js/path-injection
9+
- exclude:
10+
id: js/path-injection
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "CodeQL config 2"
2+
3+
disable-default-queries: true
4+
5+
packs:
6+
javascript:
7+
- codeql/javascript-queries
8+
- dsp-testing/[email protected]
9+
10+
query-filters:
11+
# This should run js/path-injection and js/zipslip
12+
- include:
13+
tags contain: external/cwe/cwe-022
14+
15+
# Removes out js/path-injection
16+
- exclude:
17+
id: js/path-injection
18+
19+
# Query from extra pack
20+
- include:
21+
id: javascript/example/empty-or-one-block

0 commit comments

Comments
 (0)