Skip to content

Commit aaed9e4

Browse files
committed
Update CodeQL scripts to use newer/stronger set of Java rules that
previously was included in the default java-queries CodeQL ruleset.
1 parent 476fab1 commit aaed9e4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

scripts/runCodeQL.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
# Prerequisites:
44
# 1) Install codeql in a tools/ directory that is a peer to the folder containing BenchmarkJava. For example, if you have a git/ folder, which contains BenchmarkJava, BenchmarkUtils, etc., then the tools/ folder would be at the same level as the git/ folder. i.e., relative to BenchmarkJava, it is at ../../tools/code-ql-home.
5-
# 2) Then the owasp-benchmark database has to be initialized by running this:
6-
# ../tools/codeql-home/codeql/codeql database create owasp-benchmark --language=java
5+
# 2) Then the owasp-benchmark database has to be initialized by first running the translateCodeQL.sh script.
76

87
# Mac Users: "If you are using macOS on Apple Silicon (for example, Apple M1), ensure that the Xcode command-line developer tools and Rosetta 2 are installed."
98
## For Xcode command line, run: xcode-select -p 1>/dev/null;echo $? - If this returns 0, its installed, if 2, its not installed.
109
## For Rosetta 2, run: lsbom -f /Library/Apple/System/Library/Receipts/com.apple.pkg.RosettaUpdateAuto.bom - And if it returns a list of files, it's installed.
1110

12-
# This then runs the codeql scan:
11+
# This then runs the CodeQL scan:
12+
## The following CodeQL query is a big complex. I had to raise an issue with the CodeQL team to figure out how to do this.
13+
## The issue raised and the answer that documents this query is here: https://github.com/github/codeql/issues/18518#issuecomment-2730684184
1314
benchmark_version=$(scripts/getBenchmarkVersion.sh)
14-
../tools/codeql-home/codeql/codeql database analyze owasp-benchmark codeql/java-queries --format=sarifv2.1.0 --output=results/Benchmark_$benchmark_version-codeql_java-queries.sarif
15+
../../tools/codeql-home/codeql/codeql database analyze owasp-benchmark codeql/java-queries:codeql-suites/java-security-extended.qls --format=sarifv2.1.0 --output=results/Benchmark_1.2-codeql_java-security-extended.sarif -j0 --download
1516

scripts/translateCodeQL.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# NOTE: This tool requires Java 11+
55

66
# You have to download the rulepacks now. This does this.
7-
../tools/codeql-home/codeql/codeql pack download codeql/java-queries
7+
../../tools/codeql-home/codeql/codeql pack download codeql/java-queries
88

99
# This translates the current app, and builds up the rules databases. This only has to be run once after each code change.
10-
../tools/codeql-home/codeql/codeql database create owasp-benchmark --language=java --overwrite --command="mvn clean package"
10+
../../tools/codeql-home/codeql/codeql database create owasp-benchmark --language=java --overwrite --command="mvn clean package"
1111

0 commit comments

Comments
 (0)