Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e577cf

Browse files
committed
Add new packs input to init action
This input allows users to specify which packs to run. It works in unison with the packs block of the config file and it is similar to how `queries` works. They both use `+` in the same way. Note that the `#TODO` in the pr check is still around, but the CLI is available. I will remove the TODO in the next commit.
1 parent 7729b51 commit 6e577cf

18 files changed

Lines changed: 535 additions & 59 deletions

.github/workflows/pr-checks.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
fi
102102
103103
# Packaging test that runs against a javascript database
104-
test-packaging-javascript:
104+
test-packaging-javascript-config:
105105
needs: [check-js, check-node-modules]
106106
runs-on: ubuntu-latest
107107

@@ -143,6 +143,50 @@ jobs:
143143
exit 1
144144
fi
145145
146+
# tests that we can run packages through actions inputs
147+
test-packaging-javascript-inputs:
148+
needs: [check-js, check-node-modules]
149+
runs-on: ubuntu-latest
150+
151+
steps:
152+
- uses: actions/checkout@v2
153+
- name: Move codeql-action
154+
shell: bash
155+
run: |
156+
mkdir ../action
157+
mv * .github ../action/
158+
mv ../action/tests/multi-language-repo/{*,.github} .
159+
mv ../action/.github/workflows .github
160+
- uses: ./../action/init
161+
with:
162+
config-file: ".github/codeql/codeql-config-packaging2.yml"
163+
languages: javascript
164+
packs: dsp-testing/[email protected], dsp-testing/codeql-pack2
165+
# TODO: this can be removed when cli v2.5.6 is released and available in the tool cache
166+
tools: https://github.com/dsp-testing/aeisenberg-codeql-action-packaging/releases/download/codeql-bundle-20210615/codeql-bundle-linux64.tar.gz
167+
168+
- name: Build code
169+
shell: bash
170+
run: ./build.sh
171+
- uses: ./../action/analyze
172+
with:
173+
output: "${{ runner.temp }}/results"
174+
env:
175+
TEST_MODE: true
176+
- name: Assert Results
177+
run: |
178+
cd "$RUNNER_TEMP/results"
179+
# We should have 3 hits from these rules
180+
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
181+
182+
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
183+
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
184+
echo "Found matching rules '$RULES'"
185+
if [ "$RULES" != "$EXPECTED_RULES" ]; then
186+
echo "Did not match expected rules '$EXPECTED_RULES'."
187+
exit 1
188+
fi
189+
146190
# Identify the CodeQL tool versions to integration test against.
147191
check-codeql-versions:
148192
needs: [check-js, check-node-modules]

init/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ inputs:
2222
queries:
2323
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
2424
required: false
25+
packs:
26+
description: >-
27+
Comma-separated list of packs to run. Reference a pack in the format `scope/name[@version]`. If `version` is not
28+
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
29+
configuration file; prefix with "+" to use both sets of packs.
30+
31+
This input is only available in single-language analyses.
32+
required: false
2533
external-repository-token:
2634
description: A token for fetching external config files and queries if they reside in a private repository.
2735
required: false

lib/config-utils.js

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

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)