Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: github/codeql-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.12
Choose a base ref
...
head repository: github/codeql-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.13
Choose a head ref

Commits on May 27, 2022

  1. Copy the full SHA
    bfe9d7d View commit details

Commits on May 31, 2022

  1. Make the linter happy.

    MathiasVP committed May 31, 2022
    Copy the full SHA
    16c620d View commit details

Commits on Jun 1, 2022

  1. Update changelog and version after v2.1.12

    github-actions[bot] committed Jun 1, 2022
    Copy the full SHA
    57096f1 View commit details
  2. Update checked-in dependencies

    github-actions[bot] committed Jun 1, 2022
    Copy the full SHA
    632cc8e View commit details
  3. Merge pull request #1089 from github/mergeback/v2.1.12-to-main-27ea8f8f

    Mergeback v2.1.12 refs/heads/releases/v2 into main
    aeisenberg authored Jun 1, 2022
    Copy the full SHA
    69e0990 View commit details

Commits on Jun 3, 2022

  1. Copy the full SHA
    1b5ea4a View commit details
  2. Merge pull request #1085 from github/swift-support

    Add Swift as a possible traced language
    aeisenberg authored Jun 3, 2022
    Copy the full SHA
    ccf479d View commit details

Commits on Jun 13, 2022

  1. Avoid use of rmdir

    This is a deprecated method on node v16.
    aeisenberg authored Jun 13, 2022
    Copy the full SHA
    f7c46e5 View commit details

Commits on Jun 14, 2022

  1. Merge pull request #1095 from github/aeisenberg/use-del

    Avoid use of rmdir
    aeisenberg authored Jun 14, 2022
    Copy the full SHA
    29a2159 View commit details
  2. Add typings for js-yaml

    aeisenberg committed Jun 14, 2022
    Copy the full SHA
    0efcf74 View commit details
  3. Add the check-sarif action

    Allows us to analyze and then check that certain queries were included
    in the analysis and others were not.
    aeisenberg committed Jun 14, 2022
    Copy the full SHA
    bcb7fad View commit details
  4. Add capability to filter queries

    This change adds a `query-filters` property to the codeql-config file.
    
    This property is an array of `exclude`/`include` entries for a query
    suite. These filters are appended to the generated query suite files
    and used to filter queries after they are selected.
    
    A related change is that now, all pack references are run in a single
    query suite, which has the query filters appended to them.
    aeisenberg committed Jun 14, 2022
    Copy the full SHA
    40b2800 View commit details
  5. Copy the full SHA
    06e27d3 View commit details
  6. Copy the full SHA
    eec34d5 View commit details

Commits on Jun 15, 2022

  1. Copy the full SHA
    81b419c View commit details
  2. add ml query pack 0.3.0

    TomBolton committed Jun 15, 2022
    Copy the full SHA
    0ece1d1 View commit details
  3. fix lint errors

    TomBolton committed Jun 15, 2022
    Copy the full SHA
    79d8e4a View commit details
  4. Copy the full SHA
    f8f4c0b View commit details
  5. Copy the full SHA
    a568674 View commit details
  6. Copy the full SHA
    a27dc4f View commit details
  7. Merge pull request #1087 from github/tombolton/update-ml-pack

    Run ML-powered query pack `~0.3.0` on v2.9.3+ of the CLI
    TomBolton authored Jun 15, 2022
    Copy the full SHA
    df05122 View commit details
  8. Update changelog

    aeisenberg committed Jun 15, 2022
    Copy the full SHA
    428caf0 View commit details
  9. Clarify variable names in new action

    Also simplify some computations.
    aeisenberg committed Jun 15, 2022
    Copy the full SHA
    4918636 View commit details
  10. Apply suggestions from code review

    Co-authored-by: Henry Mercer <henrymercer@github.com>
    aeisenberg and henrymercer authored Jun 15, 2022
    Copy the full SHA
    6834383 View commit details
  11. Extract query-filters test into a composite action

    Removes duplicated yaml.
    
    Also add some better typings.
    aeisenberg committed Jun 15, 2022
    Copy the full SHA
    59ca9b5 View commit details

Commits on Jun 16, 2022

  1. Copy the full SHA
    97f9db4 View commit details
  2. Copy the full SHA
    777b778 View commit details
  3. Copy the full SHA
    6db77ee View commit details
  4. Copy the full SHA
    d7459f0 View commit details
  5. Merge pull request #1086 from github/update-supported-enterprise-serv…

    …er-versions
    
    Update supported GitHub Enterprise Server versions.
    henrymercer authored Jun 16, 2022
    Copy the full SHA
    d2ab7a2 View commit details
  6. Copy the full SHA
    ee4575b View commit details
  7. Copy the full SHA
    7c412c6 View commit details
  8. Merge pull request #1098 from github/aeisenberg/remove-queries

    Add capability to filter queries
    aeisenberg committed Jun 16, 2022
    Copy the full SHA
    80ecdcd View commit details
  9. Merge pull request #1096 from github/aeisenberg/check-sarif-action

    Add the check-sarif action
    aeisenberg authored Jun 16, 2022
    Copy the full SHA
    2e80c74 View commit details

Commits on Jun 17, 2022

  1. Fix input to action

    aeisenberg committed Jun 17, 2022
    1
    Copy the full SHA
    c7785f6 View commit details
  2. Copy the full SHA
    2e111b2 View commit details
  3. Ensure there are no duplicates when sending up required checks

    This breaks the API. Also, fix the checks that had duplicate names.
    aeisenberg committed Jun 17, 2022
    Copy the full SHA
    7adb33d View commit details
  4. Merge pull request #1103 from github/aeisenberg/fix-required-checks-s…

    …cript
    
    Ensure there are no duplicates when sending up required checks
    aeisenberg authored Jun 17, 2022
    Copy the full SHA
    30fe0a5 View commit details

Commits on Jun 20, 2022

  1. Copy the full SHA
    ccf5d70 View commit details
  2. Merge pull request #1100 from github/edoardo/2.9.4-bump

    Update default CodeQL version to 2.9.4
    edoardopirovano authored Jun 20, 2022
    Copy the full SHA
    31367d4 View commit details

Commits on Jun 21, 2022

  1. Update changelog for v2.1.13

    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    8bd4419 View commit details
  2. Merge pull request #1107 from github/update-v2.1.13-31367d4e

    Merge main into releases/v2
    edoardopirovano authored Jun 21, 2022
    Copy the full SHA
    d00e8c0 View commit details
  3. Revert "Update version and changelog for v1.1.12"

    This reverts commit 24d91cb.
    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    9d650fd View commit details
  4. Revert "Update checked-in dependencies"

    This reverts commit 6efabfe.
    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    3b2cf89 View commit details
  5. Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.13…

    …-d00e8c09
    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    4d013d7 View commit details
  6. Update version and changelog for v1.1.13

    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    e47f040 View commit details
  7. Update checked-in dependencies

    github-actions[bot] committed Jun 21, 2022
    Copy the full SHA
    c053e94 View commit details
  8. Merge pull request #1109 from github/update-v1.1.13-d00e8c09

    Merge releases/v2 into releases/v1
    edoardopirovano authored Jun 21, 2022
    Copy the full SHA
    614d63a View commit details
Showing with 1,280 additions and 138 deletions.
  1. +20 −0 .github/check-sarif/action.yml
  2. +43 −0 .github/check-sarif/index.js
  3. +52 −0 .github/query-filter-test/action.yml
  4. +47 −0 .github/workflows/expected-queries-runs.yml
  5. +56 −0 .github/workflows/query-filters.yml
  6. +1 −1 .github/workflows/script/update-required-checks.sh
  7. +5 −0 CHANGELOG.md
  8. +1 −1 lib/actions-util.js.map
  9. +1 −1 lib/actions-util.test.js.map
  10. +59 −19 lib/analyze.js
  11. +1 −1 lib/analyze.js.map
  12. +132 −0 lib/analyze.test.js
  13. +1 −1 lib/analyze.test.js.map
  14. +1 −1 lib/api-compatibility.json
  15. +19 −12 lib/config-utils.js
  16. +1 −1 lib/config-utils.js.map
  17. +46 −0 lib/config-utils.test.js
  18. +1 −1 lib/config-utils.test.js.map
  19. +1 −1 lib/defaults.json
  20. +2 −1 lib/languages.js
  21. +1 −1 lib/languages.js.map
  22. +17 −7 lib/util.js
  23. +1 −1 lib/util.js.map
  24. +3 −3 lib/util.test.js
  25. +1 −1 lib/util.test.js.map
  26. +7 −1 node_modules/.package-lock.json
  27. +21 −0 node_modules/@types/js-yaml/LICENSE
  28. +16 −0 node_modules/@types/js-yaml/README.md
  29. +2 −0 node_modules/@types/js-yaml/index.d.mts
  30. +154 −0 node_modules/@types/js-yaml/index.d.ts
  31. +53 −0 node_modules/@types/js-yaml/package.json
  32. +15 −2 package-lock.json
  33. +2 −1 package.json
  34. +12 −12 src/actions-util.test.ts
  35. +2 −2 src/actions-util.ts
  36. +165 −2 src/analyze.test.ts
  37. +88 −32 src/analyze.ts
  38. +1 −1 src/api-compatibility.json
  39. +74 −0 src/config-utils.test.ts
  40. +63 −17 src/config-utils.ts
  41. +1 −1 src/defaults.json
  42. +2 −1 src/languages.ts
  43. +3 −3 src/util.test.ts
  44. +20 −9 src/util.ts
  45. +10 −0 tests/multi-language-repo/.github/codeql/codeql-config-query-filters1.yml
  46. +21 −0 tests/multi-language-repo/.github/codeql/codeql-config-query-filters2.yml
  47. +35 −0 tests/multi-language-repo/.github/codeql/codeql-config-query-filters3.yml
20 changes: 20 additions & 0 deletions .github/check-sarif/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check SARIF
description: Checks a SARIF file to see if certain queries were run and others were not run.
inputs:
sarif-file:
required: true
description: The SARIF file to check

queries-run:
required: true
description: |
Comma separated list of query ids that should be included in this SARIF file.
queries-not-run:
required: true
description: |
Comma separated list of query ids that should NOT be included in this SARIF file.
runs:
using: node12
main: index.js
43 changes: 43 additions & 0 deletions .github/check-sarif/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict'

const core = require('@actions/core')
const fs = require('fs')

const sarif = JSON.parse(fs.readFileSync(core.getInput('sarif-file'), 'utf8'))
const rules = sarif.runs[0].tool.extensions.flatMap(ext => ext.rules || [])
const ruleIds = rules.map(rule => rule.id)

// Check that all the expected queries ran
const expectedQueriesRun = getQueryIdsInput('queries-run')
const queriesThatShouldHaveRunButDidNot = expectedQueriesRun.filter(queryId => !ruleIds.includes(queryId))

if (queriesThatShouldHaveRunButDidNot.length > 0) {
core.setFailed(`The following queries were expected to run but did not: ${queriesThatShouldHaveRunButDidNot.join(', ')}`)
}

// Check that all the unexpected queries did not run
const expectedQueriesNotRun = getQueryIdsInput('queries-not-run')

const queriesThatShouldNotHaveRunButDid = expectedQueriesNotRun.filter(queryId => ruleIds.includes(queryId))

if (queriesThatShouldNotHaveRunButDid.length > 0) {
core.setFailed(`The following queries were NOT expected to have run but did: ${queriesThatShouldNotHaveRunButDid.join(', ')}`)
}


core.startGroup('All queries run')
rules.forEach(rule => {
core.info(`${rule.id}: ${(rule.properties && rule.properties.name) || rule.name}`)
})
core.endGroup()

core.startGroup('Full SARIF')
core.info(JSON.stringify(sarif, null, 2))
core.endGroup()

function getQueryIdsInput(name) {
return core.getInput(name)
.split(',')
.map(q => q.trim())
.filter(q => q.length > 0)
}
52 changes: 52 additions & 0 deletions .github/query-filter-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Query Filter Test
description: Runs a test of query filters using the check SARIF action
inputs:
sarif-file:
required: true
description: The SARIF file to check

queries-run:
required: true
description: |
Comma separated list of query ids that should be included in this SARIF file.
queries-not-run:
required: true
description: |
Comma separated list of query ids that should NOT be included in this SARIF file.
config-file:
required: true
description: |
The location of the codeql configuration file to use.
tools:
required: true
description: |
The url of codeql to use.
runs:
using: composite
steps:
- uses: ./../action/init
with:
languages: javascript
config-file: ${{ inputs.config-file }}
tools: ${{ inputs.tools }}
db-location: ${{ runner.temp }}/query-filter-test
- 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: ${{ inputs.sarif-file }}
queries-run: ${{ inputs.queries-run}}
queries-not-run: ${{ inputs.queries-not-run}}
- name: Cleanup after test
shell: bash
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP//query-filter-test"
47 changes: 47 additions & 0 deletions .github/workflows/expected-queries-runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Check queries that ran

on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}

jobs:
expected-queries:
name: Expected Queries Tests
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
- uses: ./../action/init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
- 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/incomplete-hostname-regexp,js/path-injection
queries-not-run: foo,bar
56 changes: 56 additions & 0 deletions .github/workflows/query-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Query filters tests

on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}

jobs:
query-filters:
name: Query Filters Tests
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

- name: Check SARIF for default queries with Single include, Single exclude
uses: ./../action/.github/query-filter-test
with:
sarif-file: ${{ runner.temp }}/results/javascript.sarif
queries-run: js/zipslip
queries-not-run: js/path-injection
config-file: ./.github/codeql/codeql-config-query-filters1.yml
tools: ${{ steps.prepare-test.outputs.tools-url }}

- name: Check SARIF for query packs with Single include, Single exclude
uses: ./../action/.github/query-filter-test
with:
sarif-file: ${{ runner.temp }}/results/javascript.sarif
queries-run: js/zipslip,javascript/example/empty-or-one-block
queries-not-run: js/path-injection
config-file: ./.github/codeql/codeql-config-query-filters2.yml
tools: ${{ steps.prepare-test.outputs.tools-url }}

- name: Check SARIF for query packs and local queries with Single include, Single exclude
uses: ./../action/.github/query-filter-test
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
config-file: ./.github/codeql/codeql-config-query-filters3.yml
tools: ${{ steps.prepare-test.outputs.tools-url }}
2 changes: 1 addition & 1 deletion .github/workflows/script/update-required-checks.sh
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ fi
echo "Getting checks for $GITHUB_SHA"

# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
CHECKS="$(gh api repos/github/codeql-action/commits/${GITHUB_SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") | not)] | sort')"
CHECKS="$(gh api repos/github/codeql-action/commits/${GITHUB_SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") | not)] | unique | sort')"

echo "$CHECKS" | jq

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CodeQL Action Changelog

## 1.1.13 - 21 Jun 2022

- 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)
- Update default CodeQL bundle version to 2.9.4. [#1100](https://github.com/github/codeql-action/pull/1100)

## 1.1.12 - 01 Jun 2022

- Update default CodeQL bundle version to 2.9.3. [#1084](https://github.com/github/codeql-action/pull/1084)
Loading