Skip to content

Commit 3c1ec5a

Browse files
author
Robert Marsh
committed
Merge branch 'main' into rdmarsh2/ir-global-vars
2 parents af6a4f3 + e5f2b83 commit 3c1ec5a

277 files changed

Lines changed: 10516 additions & 3573 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ql-for-ql-build.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- name: Find codeql
1818
id: find-codeql
19-
uses: github/codeql-action/init@erik-krogh/ql
19+
uses: github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
2020
with:
2121
languages: javascript # does not matter
22+
tools: latest
2223
- name: Get CodeQL version
2324
id: get-codeql-version
2425
run: |
@@ -159,7 +160,7 @@ jobs:
159160
PACK: ${{ runner.temp }}/pack
160161
- name: Hack codeql-action options
161162
run: |
162-
JSON=$(jq -nc --arg pack "${PACK}" '.resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]')
163+
JSON=$(jq -nc --arg pack "${PACK}" '.database."run-queries"=["--search-path", $pack] | .resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]')
163164
echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
164165
env:
165166
PACK: ${{ runner.temp }}/pack
@@ -171,22 +172,25 @@ jobs:
171172
echo "paths:" > ${CONF}
172173
echo " - ${FOLDER}" >> ${CONF}
173174
echo "paths-ignore:" >> ${CONF}
174-
echo " - ql/ql/test" >> ${CONF}
175+
echo " - ql/ql/test" >> ${CONF}
176+
echo "disable-default-queries: true" >> ${CONF}
177+
echo "packs:" >> ${CONF}
178+
echo " - codeql/ql" >> ${CONF}
175179
echo "Config file: "
176180
cat ${CONF}
177181
env:
178182
CONF: ./ql-for-ql-config.yml
179183
FOLDER: ${{ matrix.folder }}
180-
181184
- name: Initialize CodeQL
182-
uses: github/codeql-action/init@erik-krogh/ql
185+
uses: github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
183186
with:
184187
languages: ql
185188
db-location: ${{ runner.temp }}/db
186189
config-file: ./ql-for-ql-config.yml
190+
tools: latest
187191

188192
- name: Perform CodeQL Analysis
189-
uses: github/codeql-action/analyze@erik-krogh/ql
193+
uses: github/codeql-action/analyze@aa93aea877e5fb8841bcb1193f672abf6e9f2980
190194
with:
191195
category: "ql-for-ql-${{ matrix.folder }}"
192196
- name: Copy sarif file to CWD

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
- name: Find codeql
2828
id: find-codeql
29-
uses: github/codeql-action/init@erik-krogh/ql
29+
uses: github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
3030
with:
3131
languages: javascript # does not matter
3232
- uses: actions/cache@v2

.github/workflows/ql-for-ql-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v2
2121
- name: Find codeql
2222
id: find-codeql
23-
uses: github/codeql-action/init@erik-krogh/ql
23+
uses: github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
2424
with:
2525
languages: javascript # does not matter
2626
- uses: actions/cache@v2

config/identical-files.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,12 @@
482482
"python/ql/lib/semmle/python/security/performance/ReDoSUtil.qll",
483483
"ruby/ql/lib/codeql/ruby/security/performance/ReDoSUtil.qll"
484484
],
485-
"ReDoS Exponential Python/JS": [
485+
"ReDoS Exponential Python/JS/Ruby": [
486486
"javascript/ql/lib/semmle/javascript/security/performance/ExponentialBackTracking.qll",
487-
"python/ql/lib/semmle/python/security/performance/ExponentialBackTracking.qll"
487+
"python/ql/lib/semmle/python/security/performance/ExponentialBackTracking.qll",
488+
"ruby/ql/lib/codeql/ruby/security/performance/ExponentialBackTracking.qll"
488489
],
489-
"ReDoS Polynomial Python/JS": [
490+
"ReDoS Polynomial Python/JS/Ruby": [
490491
"javascript/ql/lib/semmle/javascript/security/performance/SuperlinearBackTracking.qll",
491492
"python/ql/lib/semmle/python/security/performance/SuperlinearBackTracking.qll",
492493
"ruby/ql/lib/codeql/ruby/security/performance/SuperlinearBackTracking.qll"
@@ -518,8 +519,14 @@
518519
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
519520
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll"
520521
],
522+
"Concepts Python/Ruby/JS": [
523+
"python/ql/lib/semmle/python/internal/ConceptsShared.qll",
524+
"ruby/ql/lib/codeql/ruby/internal/ConceptsShared.qll",
525+
"javascript/ql/lib/semmle/javascript/internal/ConceptsShared.qll"
526+
],
521527
"Hostname Regexp queries": [
522528
"javascript/ql/src/Security/CWE-020/HostnameRegexpShared.qll",
529+
"python/ql/src/Security/CWE-020/HostnameRegexpShared.qll",
523530
"ruby/ql/src/queries/security/cwe-020/HostnameRegexpShared.qll"
524531
],
525532
"ApiGraphModels": [
@@ -533,5 +540,13 @@
533540
"TaintedFormatStringCustomizations Ruby/JS": [
534541
"javascript/ql/lib/semmle/javascript/security/dataflow/TaintedFormatStringCustomizations.qll",
535542
"ruby/ql/lib/codeql/ruby/security/TaintedFormatStringCustomizations.qll"
543+
],
544+
"HttpToFileAccessQuery JS/Ruby": [
545+
"javascript/ql/lib/semmle/javascript/security/dataflow/HttpToFileAccessQuery.qll",
546+
"ruby/ql/lib/codeql/ruby/security/HttpToFileAccessQuery.qll"
547+
],
548+
"HttpToFileAccessCustomizations JS/Ruby": [
549+
"javascript/ql/lib/semmle/javascript/security/dataflow/HttpToFileAccessCustomizations.qll",
550+
"ruby/ql/lib/codeql/ruby/security/HttpToFileAccessCustomizations.qll"
536551
]
537-
}
552+
}

cpp/ql/lib/semmle/code/cpp/Location.qll

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,24 @@ class Location extends @location {
7373

7474
/** Holds if `this` comes on a line strictly before `l`. */
7575
pragma[inline]
76-
predicate isBefore(Location l) {
77-
this.getFile() = l.getFile() and this.getEndLine() < l.getStartLine()
76+
predicate isBefore(Location l) { this.isBefore(l, false) }
77+
78+
/**
79+
* Holds if `this` comes strictly before `l`. The boolean `sameLine` is
80+
* true if `l` is on the same line as `this`, but starts at a later column.
81+
* Otherwise, `sameLine` is false.
82+
*/
83+
pragma[inline]
84+
predicate isBefore(Location l, boolean sameLine) {
85+
this.getFile() = l.getFile() and
86+
(
87+
sameLine = false and
88+
this.getEndLine() < l.getStartLine()
89+
or
90+
sameLine = true and
91+
this.getEndLine() = l.getStartLine() and
92+
this.getEndColumn() < l.getStartColumn()
93+
)
7894
}
7995

8096
/** Holds if location `l` is completely contained within this one. */

cpp/ql/lib/semmle/code/cpp/Type.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Type extends Locatable, @type {
9494
* The result of this predicate will be the type itself, except in the case of a TypedefType or a Decltype,
9595
* in which case the result will be type which results from (possibly recursively) resolving typedefs.
9696
*/
97+
pragma[nomagic]
9798
Type getUnderlyingType() { result = this }
9899

99100
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Instruction getInstructionBackEdgeSuccessor(Instruction instruction, EdgeKind ki
352352

353353
/** Holds if `goto` jumps strictly forward in the program text. */
354354
private predicate isStrictlyForwardGoto(GotoStmt goto) {
355-
goto.getLocation().isBefore(goto.getTarget().getLocation())
355+
goto.getLocation().isBefore(goto.getTarget().getLocation(), _)
356356
}
357357

358358
Locatable getInstructionAst(TStageInstruction instr) {

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,6 @@ private predicate ignoreSideEffects(Expr expr) {
156156
* around extractor bugs. Once the relevant extractor bugs are fixed, this predicate can be removed.
157157
*/
158158
private predicate isInvalidFunction(Function func) {
159-
exists(Literal literal |
160-
// Constructor field inits within a compiler-generated copy constructor have a source expression
161-
// that is a `Literal` with no value.
162-
literal = func.(Constructor).getAnInitializer().(ConstructorFieldInit).getExpr() and
163-
not exists(literal.getValue())
164-
)
165-
or
166159
exists(ThisExpr thisExpr |
167160
// An instantiation of a member function template is not treated as a `MemberFunction` if it has
168161
// only non-type template arguments.

0 commit comments

Comments
 (0)