-
Notifications
You must be signed in to change notification settings - Fork 376
Add the check-sarif action #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bcb7fad
Add the check-sarif action
aeisenberg 40b2800
Add capability to filter queries
aeisenberg 06e27d3
Merge branch 'aeisenberg/js-yaml-typings' into aeisenberg/remove-queries
aeisenberg eec34d5
Add integration tests for query filters
aeisenberg 428caf0
Update changelog
aeisenberg 4918636
Clarify variable names in new action
aeisenberg 6834383
Apply suggestions from code review
aeisenberg 59ca9b5
Extract query-filters test into a composite action
aeisenberg 777b778
Spelling, capitalization, and better descriptions
aeisenberg 6db77ee
Merge remote-tracking branch 'upstream/main' into aeisenberg/remove-q…
aeisenberg d7459f0
Merge branch 'aeisenberg/check-sarif-action' into aeisenberg/remove-q…
aeisenberg ee4575b
Merge branch 'main' into aeisenberg/check-sarif-action
aeisenberg 7c412c6
Merge branch 'aeisenberg/check-sarif-action' into aeisenberg/remove-q…
aeisenberg 80ecdcd
Merge pull request #1098 from github/aeisenberg/remove-queries
aeisenberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add integration tests for query filters
- Loading branch information
commit eec34d5f052688f5fa2a4c9a6dc7485600cb5784
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
name: Expected queries runs | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
on: | ||
push: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Query filters tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- releases/v1 | ||
- releases/v2 | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
expected-queries: | ||
timeout-minutes: 45 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
- name: Prepare test | ||
id: prepare-test | ||
uses: ./.github/prepare-test | ||
with: | ||
version: latest | ||
|
||
# Test 1 | ||
- uses: ./../action/init | ||
with: | ||
languages: javascript | ||
config-file: ./.github/codeql/codeql-config-query-filters1.yml | ||
tools: ${{ steps.prepare-test.outputs.tools-url }} | ||
db-location: ${{ runner.temp }}/test1 | ||
- uses: ./../action/analyze | ||
with: | ||
output: ${{ runner.temp }}/results | ||
upload-database: false | ||
upload: false | ||
env: | ||
TEST_MODE: true | ||
- name: Check Sarif | ||
uses: ./../action/.github/check-sarif | ||
with: | ||
sarif-file: ${{ runner.temp }}/results/javascript.sarif | ||
queries-run: js/zipslip | ||
queries-not-run: js/path-injection | ||
- name: Cleanup after test | ||
run: rm -rf "$RUNNER_TEMP/results" | ||
|
||
# Test 2 | ||
- uses: ./../action/init | ||
with: | ||
languages: javascript | ||
config-file: ./.github/codeql/codeql-config-query-filters2.yml | ||
tools: ${{ steps.prepare-test.outputs.tools-url }} | ||
db-location: ${{ runner.temp }}/test2 | ||
- uses: ./../action/analyze | ||
with: | ||
output: ${{ runner.temp }}/results | ||
upload-database: false | ||
upload: false | ||
env: | ||
TEST_MODE: true | ||
- name: Check Sarif | ||
uses: ./../action/.github/check-sarif | ||
with: | ||
sarif-file: ${{ runner.temp }}/results/javascript.sarif | ||
queries-run: js/zipslip,javascript/example/empty-or-one-block | ||
queries-not-run: js/path-injection | ||
- name: Cleanup after test | ||
run: rm -rf "$RUNNER_TEMP/results" | ||
|
||
# Test 3 | ||
- uses: ./../action/init | ||
with: | ||
languages: javascript | ||
config-file: ./.github/codeql/codeql-config-query-filters3.yml | ||
tools: ${{ steps.prepare-test.outputs.tools-url }} | ||
db-location: ${{ runner.temp }}/test3 | ||
- uses: ./../action/analyze | ||
with: | ||
output: ${{ runner.temp }}/results | ||
upload-database: false | ||
upload: false | ||
env: | ||
TEST_MODE: true | ||
- name: Check Sarif | ||
uses: ./../action/.github/check-sarif | ||
with: | ||
sarif-file: ${{ runner.temp }}/results/javascript.sarif | ||
queries-run: js/zipslip,javascript/example/empty-or-one-block,inrepo-javascript-querypack/show-ifs | ||
queries-not-run: js/path-injection,complex-python-querypack/show-ifs,complex-python-querypack/foo/bar/show-ifs | ||
- name: Cleanup after test | ||
run: rm -rf "$RUNNER_TEMP/results" |
10 changes: 10 additions & 0 deletions
10
tests/multi-language-repo/.github/codeql/codeql-config-query-filters1.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "CodeQL config 1" | ||
|
||
query-filters: | ||
# This should run js/path-injection and js/zipslip | ||
- include: | ||
tags contain: external/cwe/cwe-022 | ||
|
||
# Removes out js/path-injection | ||
- exclude: | ||
id: js/path-injection |
21 changes: 21 additions & 0 deletions
21
tests/multi-language-repo/.github/codeql/codeql-config-query-filters2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "CodeQL config 2" | ||
|
||
disable-default-queries: true | ||
|
||
packs: | ||
javascript: | ||
- codeql/javascript-queries | ||
- dsp-testing/codeql-pack1@1.0.0 | ||
|
||
query-filters: | ||
# This should run js/path-injection and js/zipslip | ||
- include: | ||
tags contain: external/cwe/cwe-022 | ||
|
||
# Removes out js/path-injection | ||
- exclude: | ||
id: js/path-injection | ||
|
||
# Query from extra pack | ||
- include: | ||
id: javascript/example/empty-or-one-block |
35 changes: 35 additions & 0 deletions
35
tests/multi-language-repo/.github/codeql/codeql-config-query-filters3.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "CodeQL config 3" | ||
|
||
disable-default-queries: true | ||
|
||
queries: | ||
# Local query | ||
- name: Run an extra local query | ||
uses: ./codeql-qlpacks/javascript-qlpack/show_ifs.ql | ||
|
||
# These queries are ignored | ||
- name: Ignored queries | ||
uses: ./codeql-qlpacks/complex-python-qlpack/rootAndBar.qls | ||
|
||
|
||
packs: | ||
javascript: | ||
- codeql/javascript-queries | ||
- dsp-testing/codeql-pack1@1.0.0 | ||
|
||
query-filters: | ||
# This should run js/path-injection and js/zipslip | ||
- include: | ||
tags contain: external/cwe/cwe-022 | ||
|
||
# Removes out js/path-injection | ||
- exclude: | ||
id: js/path-injection | ||
|
||
# Query from extra pack | ||
- include: | ||
id: javascript/example/empty-or-one-block | ||
|
||
# Local query | ||
- include: | ||
id: inrepo-javascript-querypack/show-ifs |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.