-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add mono-repo filtering example using a workflow matrix #1
base: main
Are you sure you want to change the base?
Changes from 7 commits
b56a9d1
a68d8db
4bff199
a577df3
62c9ac8
d3ec207
d5ffc10
2c72cd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: "CodeQL Analysis" | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- language: 'java' | ||
build-command: 'mvn compile -B' | ||
directory: 'project1' | ||
- language: 'java' | ||
build-command: 'mvn compile -B' | ||
directory: 'project2' | ||
- language: 'java' | ||
build-command: 'mvn compile -B' | ||
directory: 'project3' | ||
- language: 'java' | ||
build-command: 'mvn compile -B' | ||
directory: 'project4' | ||
- language: 'javascript' | ||
build-command: ${{ null }} | ||
directory: 'project5' | ||
config: | | ||
paths: | ||
- project5 | ||
- language: 'javascript' | ||
build-command: ${{ null }} | ||
directory: 'project6' | ||
config: | | ||
paths: | ||
- project6 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
nicolaswill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
queries: security-extended,security-and-quality | ||
config: ${{ matrix.config }} | ||
|
||
- name: Run build command for subproject | ||
run: ${{ matrix.build-command }} | ||
working-directory: ${{ matrix.directory }} | ||
if: ${{ matrix.build-command }} | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
with: | ||
category: "/language:${{matrix.language}}" | ||
upload: False | ||
output: sarif-results | ||
env: | ||
CODEQL_ACTION_EXTRA_OPTIONS: '{"database":{"analyze":["--sarif-add-snippets","--sarif-add-query-help","--sarif-group-rules-by-pack"]}}' | ||
|
||
- name: Rename CodeQL tool | ||
run: | | ||
jq ".runs[0].tool.driver.name = \"CodeQL-${WORKFLOW_TAG}-${{matrix.language}}\"" sarif-results/${{ matrix.language }}.sarif > sarif-results/${{ matrix.language }}-edited.sarif | ||
env: | ||
WORKFLOW_TAG: ${{ matrix.directory }} | ||
|
||
- name: Upload SARIF | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: sarif-results/${{ matrix.language }}-edited.sarif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var fs = require('fs'), | ||
http = require('http'), | ||
url = require('url'); | ||
|
||
var server = http.createServer(function(req, res) { | ||
let path = url.parse(req.url, true).query.path; | ||
|
||
fs.readFileSync(path); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
|
||
var obj = bla ? something() : path; | ||
|
||
fs.readFileSync(obj.sub); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
|
||
obj.sub = "safe"; | ||
|
||
fs.readFileSync(obj.sub); // OK | ||
|
||
obj.sub2 = "safe"; | ||
if (random()) { | ||
fs.readFileSync(obj.sub2); // OK | ||
} | ||
|
||
if (random()) { | ||
obj.sub3 = "safe" | ||
Check notice Code scanning / CodeQL-project5-javascript Semicolon insertion Note test
Avoid automated semicolon insertion (90% of all statements in
the enclosing function Error loading related location Loading Check notice Code scanning / CodeQL-project5-javascript Semicolon insertion
Avoid automated semicolon insertion (90% of all statements in [the enclosing function](1) have an explicit semicolon).
|
||
} | ||
fs.readFileSync(obj.sub3); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
|
||
obj.sub4 = | ||
fs.readFileSync(obj.sub4) ? // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
fs.readFileSync(obj.sub4) : // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
fs.readFileSync(obj.sub4); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading |
||
}); | ||
|
||
server.listen(); | ||
|
||
var nodefs = require('node:fs'); | ||
|
||
var server2 = http.createServer(function(req, res) { | ||
let path = url.parse(req.url, true).query.path; | ||
nodefs.readFileSync(path); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression
This path depends on a [user-provided value](1).
|
||
}); | ||
|
||
server2.listen(); | ||
|
||
const chownr = require("chownr"); | ||
|
||
var server3 = http.createServer(function (req, res) { | ||
Check notice Code scanning / CodeQL-project5-javascript Unused variable, import, function or class Note test
Unused variable server3.
Check notice Code scanning / CodeQL-project5-javascript Unused variable, import, function or class
Unused variable server3.
|
||
let path = url.parse(req.url, true).query.path; | ||
chownr(path, "someuid", "somegid", function (err) {}); // NOT OK | ||
Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression High test
This path depends on a
user-provided value Error loading related location Loading Check failure Code scanning / CodeQL-project5-javascript Uncontrolled data used in path expression
This path depends on a [user-provided value](1).
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// copied from tests for `UnsafeDynamicMethodAccess.ql` to check that they do not overlap | ||
|
||
let obj = {}; | ||
|
||
window.addEventListener('message', (ev) => { | ||
Check warning Code scanning / CodeQL-project6-javascript Missing origin verification in `postMessage` handler Medium
Postmessage handler has no origin check.
Check warning Code scanning / CodeQL-project6-javascript Missing origin verification in `postMessage` handler
Postmessage handler has no origin check.
|
||
let message = JSON.parse(ev.data); | ||
window[message.name](message.payload); // NOT OK, but reported by UnsafeDynamicMethodAccess.ql [INCONSISTENCY] | ||
Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access Critical
This method is invoked using a
user-controlled value Error loading related location Loading Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access
This method is invoked using a [user-controlled value](1), which may allow remote code execution.
|
||
new window[message.name](message.payload); // NOT OK, but reported by UnsafeDynamicMethodAccess.ql [INCONSISTENCY] | ||
Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access Critical
This method is invoked using a
user-controlled value Error loading related location Loading Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access
This method is invoked using a [user-controlled value](1), which may allow remote code execution.
|
||
window["HTMLElement" + message.name](message.payload); // OK - concatenation restricts choice of methods | ||
window[`HTMLElement${message.name}`](message.payload); // OK - concatenation restricts choice of methods | ||
|
||
function f() {} | ||
f[message.name](message.payload)(); // NOT OK, but reported by UnsafeDynamicMethodAccess.ql [INCONSISTENCY] | ||
Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access Critical
This method is invoked using a
user-controlled value Error loading related location Loading Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access
This method is invoked using a [user-controlled value](1), which may allow remote code execution.
|
||
|
||
obj[message.name](message.payload); // NOT OK | ||
Check failure Code scanning / CodeQL-project6-javascript Unvalidated dynamic method call High
Invocation of method with
user-controlled Error loading related location Loading Check failure Code scanning / CodeQL-project6-javascript Unvalidated dynamic method call
Invocation of method with [user-controlled](1) name may dispatch to unexpected target and cause an exception.
|
||
|
||
window[ev](ev); // NOT OK, but reported by UnsafeDynamicMethodAccess.ql [INCONSISTENCY] | ||
Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access Critical
This method is invoked using a
user-controlled value Error loading related location Loading Check failure Code scanning / CodeQL-project6-javascript Unsafe dynamic method access
This method is invoked using a [user-controlled value](1), which may allow remote code execution.
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you bump that to v4 please?