Skip to content

Commit 153ab19

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

File tree

4 files changed

+103
-2
lines changed

4 files changed

+103
-2
lines changed

.github/workflows/expected-queries-runs.yml

Lines changed: 0 additions & 2 deletions
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:

.github/workflows/query-filters.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
- uses: ./../action/analyze
37+
with:
38+
output: ${{ runner.temp }}/results
39+
upload-database: false
40+
upload: false
41+
env:
42+
TEST_MODE: true
43+
- name: Check Sarif
44+
uses: ./../action/.github/check-sarif
45+
with:
46+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
47+
queries-run: js/zipslip
48+
queries-not-run: js/path-injection
49+
- name: Cleanup after test
50+
run: rm -rf "$RUNNER_TEMP/results"
51+
52+
# Test 2
53+
- uses: ./../action/init
54+
with:
55+
languages: javascript
56+
config-file: ./.github/codeql/codeql-config-query-filters2.yml
57+
tools: ${{ steps.prepare-test.outputs.tools-url }}
58+
- uses: ./../action/analyze
59+
with:
60+
output: ${{ runner.temp }}/results
61+
upload-database: false
62+
upload: false
63+
env:
64+
TEST_MODE: true
65+
- name: Check Sarif
66+
uses: ./../action/.github/check-sarif
67+
with:
68+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
69+
queries-run: js/zipslip,javascript/example/empty-or-one-block
70+
queries-not-run: js/path-injection
71+
- name: Cleanup after test
72+
run: rm -rf "$RUNNER_TEMP/results"
Lines changed: 10 additions & 0 deletions
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
Lines changed: 21 additions & 0 deletions
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)