Skip to content

Commit 80ecdcd

Browse files
committed
Merge pull request #1098 from github/aeisenberg/remove-queries
Add capability to filter queries
2 parents ee4575b + 7c412c6 commit 80ecdcd

25 files changed

+826
-98
lines changed

.github/query-filter-test/action.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Query Filter Test
2+
description: Runs a test of query filters using the check SARIF action
3+
inputs:
4+
sarif-file:
5+
required: true
6+
description: The SARIF file to check
7+
8+
queries-run:
9+
required: true
10+
description: |
11+
Comma separated list of query ids that should be included in this SARIF file.
12+
13+
queries-not-run:
14+
required: true
15+
description: |
16+
Comma separated list of query ids that should NOT be included in this SARIF file.
17+
18+
config-file:
19+
required: true
20+
description: |
21+
The location of the codeql configuration file to use.
22+
23+
tools:
24+
required: true
25+
description: |
26+
The url of codeql to use.
27+
28+
runs:
29+
using: composite
30+
steps:
31+
- uses: ./../action/init
32+
with:
33+
languages: javascript
34+
config-file: ./.github/codeql/codeql-config-query-filters1.yml
35+
tools: ${{ inputs.tools }}
36+
db-location: ${{ runner.temp }}/query-filter-test
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: ${{ inputs.sarif-file }}
48+
queries-run: ${{ inputs.queries-run}}
49+
queries-not-run: ${{ inputs.queries-not-run}}
50+
- name: Cleanup after test
51+
shell: bash
52+
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP//query-filter-test"

.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: Check queries that ran
2-
env:
3-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42

53
on:
64
push:

.github/workflows/query-filters.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
- name: Check SARIF for default queries with Single include, Single exclude
31+
uses: ./../action/.github/query-filter-test
32+
with:
33+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
34+
queries-run: js/zipslip
35+
queries-not-run: js/path-injection
36+
config-file: ./.github/codeql/codeql-config-query-filters1.yml
37+
tools: ${{ steps.prepare-test.outputs.tools-url }}
38+
39+
- name: Check SARIF for query packs with Single include, Single exclude
40+
uses: ./../action/.github/query-filter-test
41+
with:
42+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
43+
queries-run: js/zipslip,javascript/example/empty-or-one-block
44+
queries-not-run: js/path-injection
45+
config-file: ./.github/codeql/codeql-config-query-filters2.yml
46+
tools: ${{ steps.prepare-test.outputs.tools-url }}
47+
48+
- name: Check SARIF for query packs and local queries with Single include, Single exclude
49+
uses: ./../action/.github/query-filter-test
50+
with:
51+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
52+
queries-run: js/zipslip,javascript/example/empty-or-one-block,inrepo-javascript-querypack/show-ifs
53+
queries-not-run: js/path-injection,complex-python-querypack/show-ifs,complex-python-querypack/foo/bar/show-ifs
54+
config-file: ./.github/codeql/codeql-config-query-filters3.yml
55+
tools: ${{ steps.prepare-test.outputs.tools-url }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [UNRELEASED]
44

5-
No user facing changes.
5+
- Add the ability to filter queries from a code scanning run by using the `query-filters` option in the code scanning configuration file. [#1098](https://github.com/github/codeql-action/pull/1098)
66

77
## 2.1.12 - 01 Jun 2022
88

lib/analyze.js

Lines changed: 54 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)