Skip to content

Update CodeQL CLI dependency to 2.11.6. #333

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

Merged
merged 48 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
48986a5
Modernize qlpacks and update to CodeQL 2.8.5
jketema Jul 14, 2022
d514cfb
Update test expectations for new flow paths
jketema Jul 14, 2022
cb88149
Add missing whitespace in development handbook
jketema Jul 14, 2022
2401e86
Bump codeql submodule
jketema Jul 14, 2022
896e289
Standardize on Python 3.9 per the user manual
jketema Jul 15, 2022
8363218
Merge pull request #4 from jketema/modernize-packs
jketema Jul 15, 2022
5613669
Update to CodeQL 2.9.4
jketema Jul 14, 2022
65f4e25
Bump codeql submodule
jketema Jul 14, 2022
ea338e6
Fix M0-1-4 to ignore compiler-generated accesses
jketema Jul 15, 2022
bac2169
Update symbol location in expected test output
jketema Jul 15, 2022
e252fb3
Fix braced initialization detection in A8-5-3
jketema Jul 15, 2022
6b7c906
Merge pull request #19 from jketema/update-to-2.9.4
jketema Jul 18, 2022
24d9942
Update to CodeQL 2.10.1
jketema Jul 19, 2022
70b684a
Bump codeql submodule
jketema Jul 19, 2022
5b6e9c2
Fix A2-10-4 and A2-10-5 test results
jketema Jul 19, 2022
182adb1
Merge pull request #21 from jketema/bleeding-edge
jketema Jul 20, 2022
5deb108
use idPod instead of isPOD
erik-krogh Aug 25, 2022
0619dce
Merge pull request #70 from erik-krogh/isPodDep
jketema Aug 26, 2022
e9444e1
Replace `XMLElement` by `XmlElement` and `XMLFile` by `XmlFile`
jketema Aug 30, 2022
34aea0a
Merge pull request #71 from jketema/xml-deprecation-fix
jketema Sep 2, 2022
422bdb3
Replace `NULLMacro` by `NullMacro`
jketema Sep 2, 2022
0971b4c
Merge pull request #76 from jketema/nullmacro-deprecation-fix
jketema Sep 2, 2022
799fc60
Update to CodeQL 2.11.0
jketema Oct 30, 2022
a38938d
Update expected test output
hvitved Nov 1, 2022
4fa80e8
Merge pull request #110 from jketema/cli-2.11.0-update
jketema Nov 2, 2022
f2aac38
Merge branch 'main' into next
jketema Nov 2, 2022
00a921e
Merge pull request #114 from hvitved/update-expected-output
jketema Nov 4, 2022
dde6141
Merge branch 'main' into next
jketema Nov 17, 2022
f6ca0ce
Merge branch 'main' into next
jketema Nov 23, 2022
b3f8d13
C++: Pull in the latest version of `TaintedPath.ql` from CodeQL
jketema Dec 6, 2022
0a7696c
Add change note
jketema Dec 6, 2022
f29b89b
Add back coding standards specific changes
jketema Dec 6, 2022
73c9ffc
Merge pull request #149 from jketema/jketema/update-taintedpath
jketema Dec 7, 2022
760ccde
C++: Accept test changes after CodeQL `scanf` work
jketema Dec 8, 2022
d1fe1ad
Fix references to pack names after pack renaming
jketema Dec 8, 2022
7051685
Merge pull request #150 from jketema/jketema/fix-expected-test-results
jketema Dec 8, 2022
cb9a05f
Merge pull request #151 from jketema/pack-names
jketema Dec 8, 2022
7554517
Merge commit 'cb9a05fb4a02424cb4da3a9de3ae818b2e3eb2b4' into lcartey/…
lcartey Jul 23, 2023
d1f7ebc
Update to CodeQL CLI 2.11.6.
lcartey Jul 29, 2023
a9b1557
Fix CERT C pack name.
lcartey Jul 30, 2023
368ee9e
Merge branch 'main' into lcartey/update-to-2.11
lcartey Jul 30, 2023
77d571a
Update all codeql/cpp-all dependencies to 0.4.6
lcartey Jul 30, 2023
c0f13fd
Enable installation of pre-release packs
lcartey Jul 30, 2023
caa3125
Fix name of allow-prerelease flag.
lcartey Jul 30, 2023
cd4bbc0
Revert "C++: Accept test changes after CodeQL `scanf` work"
lcartey Jul 30, 2023
68dc174
Remove redundant change notes.
lcartey Jul 30, 2023
125bfde
Fix `NULLMacro` deprecation warning
jketema Mar 1, 2023
8287ff2
Add change note.
lcartey Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .codeqlmanifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{ "provide": [ "cpp/*/src/qlpack.yml", "cpp/*/test/qlpack.yml", "c/*/src/qlpack.yml", "c/*/test/qlpack.yml", "scripts/generate_modules/queries/qlpack.yml" ] }
{
"provide": [
"cpp/*/src/qlpack.yml",
"cpp/*/test/qlpack.yml",
"c/*/src/qlpack.yml",
"c/*/test/qlpack.yml",
"scripts/generate_modules/queries/qlpack.yml"
]
}
6 changes: 4 additions & 2 deletions c/cert/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion c/cert/src/codeql-suites/cert-default.qls
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
- path-problem
- exclude:
tags contain:
- external/cert/default-disabled
- external/cert/default-disabled
2 changes: 1 addition & 1 deletion c/cert/src/qlpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ suites: codeql-suites
license: MIT
dependencies:
codeql/common-c-coding-standards: '*'
codeql/cpp-all: 0.3.5
codeql/cpp-all: 0.4.6
92 changes: 83 additions & 9 deletions c/cert/src/rules/FIO32-C/DoNotPerformFileOperationsOnDevices.ql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import cpp
import codingstandards.c.cert
import semmle.code.cpp.security.FunctionWithWrappers
import semmle.code.cpp.security.Security
import semmle.code.cpp.security.TaintTracking
import TaintedWithPath
import semmle.code.cpp.ir.IR
import semmle.code.cpp.ir.dataflow.TaintTracking
import DataFlow::PathGraph

// Query TaintedPath.ql from the CodeQL standard library
/**
Expand Down Expand Up @@ -45,20 +46,93 @@ class FileFunction extends FunctionWithWrappers {
override predicate interestingArg(int arg) { arg = 0 }
}

class TaintedPathConfiguration extends TaintTrackingConfiguration {
override predicate isSink(Element tainted) {
exists(FileFunction fileFunction | fileFunction.outermostWrapperFunctionCall(tainted, _))
Expr asSourceExpr(DataFlow::Node node) {
result = node.asConvertedExpr()
or
result = node.asDefiningArgument()
}

Expr asSinkExpr(DataFlow::Node node) {
result =
node.asOperand()
.(SideEffectOperand)
.getUse()
.(ReadSideEffectInstruction)
.getArgumentDef()
.getUnconvertedResultExpression()
}

/**
* Holds for a variable that has any kind of upper-bound check anywhere in the program.
* This is biased towards being inclusive and being a coarse overapproximation because
* there are a lot of valid ways of doing an upper bounds checks if we don't consider
* where it occurs, for example:
* ```cpp
* if (x < 10) { sink(x); }
*
* if (10 > y) { sink(y); }
*
* if (z > 10) { z = 10; }
* sink(z);
* ```
*/
predicate hasUpperBoundsCheck(Variable var) {
exists(RelationalOperation oper, VariableAccess access |
oper.getAnOperand() = access and
access.getTarget() = var and
// Comparing to 0 is not an upper bound check
not oper.getAnOperand().getValue() = "0"
)
}

class TaintedPathConfiguration extends TaintTracking::Configuration {
TaintedPathConfiguration() { this = "TaintedPathConfiguration" }

override predicate isSource(DataFlow::Node node) { isUserInput(asSourceExpr(node), _) }

override predicate isSink(DataFlow::Node node) {
exists(FileFunction fileFunction |
fileFunction.outermostWrapperFunctionCall(asSinkExpr(node), _)
)
}

override predicate isSanitizerIn(DataFlow::Node node) { this.isSource(node) }

override predicate isSanitizer(DataFlow::Node node) {
node.asExpr().(Call).getTarget().getUnspecifiedType() instanceof ArithmeticType
or
exists(LoadInstruction load, Variable checkedVar |
load = node.asInstruction() and
checkedVar = load.getSourceAddress().(VariableAddressInstruction).getAstVariable() and
hasUpperBoundsCheck(checkedVar)
)
}

predicate hasFilteredFlowPath(DataFlow::PathNode source, DataFlow::PathNode sink) {
this.hasFlowPath(source, sink) and
// The use of `isUserInput` in `isSink` in combination with `asSourceExpr` causes
// duplicate results. Filter these duplicates. The proper solution is to switch to
// using `LocalFlowSource` and `RemoteFlowSource`, but this currently only supports
// a subset of the cases supported by `isUserInput`.
not exists(DataFlow::PathNode source2 |
this.hasFlowPath(source2, sink) and
asSourceExpr(source.getNode()) = asSourceExpr(source2.getNode())
|
not exists(source.getNode().asConvertedExpr()) and exists(source2.getNode().asConvertedExpr())
)
}
}

from
FileFunction fileFunction, Expr taintedArg, Expr taintSource, PathNode sourceNode,
PathNode sinkNode, string taintCause, string callChain
FileFunction fileFunction, Expr taintedArg, Expr taintSource, TaintedPathConfiguration cfg,
DataFlow::PathNode sourceNode, DataFlow::PathNode sinkNode, string taintCause, string callChain
where
not isExcluded(taintedArg, IO3Package::doNotPerformFileOperationsOnDevicesQuery()) and
taintedArg = asSinkExpr(sinkNode.getNode()) and
fileFunction.outermostWrapperFunctionCall(taintedArg, callChain) and
taintedWithPath(taintSource, taintedArg, sourceNode, sinkNode) and
cfg.hasFilteredFlowPath(sourceNode, sinkNode) and
taintSource = asSourceExpr(sourceNode.getNode()) and
isUserInput(taintSource, taintCause)
select taintedArg, sourceNode, sinkNode,
"This argument to a file access function is derived from $@ and then passed to " + callChain,
"This argument to a file access function is derived from $@ and then passed to " + callChain + ".",
taintSource, "user input (" + taintCause + ")"
6 changes: 4 additions & 2 deletions c/cert/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
edges
| test.c:20:15:20:23 | array to pointer conversion | test.c:21:8:21:16 | (const char *)... |
| test.c:20:15:20:23 | array to pointer conversion | test.c:21:8:21:16 | file_name |
| test.c:20:15:20:23 | array to pointer conversion | test.c:21:8:21:16 | file_name indirection |
| test.c:20:15:20:23 | file_name | test.c:21:8:21:16 | (const char *)... |
| test.c:20:15:20:23 | file_name | test.c:21:8:21:16 | file_name |
| test.c:20:15:20:23 | file_name | test.c:21:8:21:16 | file_name indirection |
| test.c:20:15:20:23 | scanf output argument | test.c:21:8:21:16 | (const char *)... |
| test.c:20:15:20:23 | scanf output argument | test.c:21:8:21:16 | file_name |
| test.c:20:15:20:23 | scanf output argument | test.c:21:8:21:16 | file_name indirection |
| test.c:45:15:45:23 | array to pointer conversion | test.c:46:29:46:37 | (LPCTSTR)... |
| test.c:45:15:45:23 | array to pointer conversion | test.c:46:29:46:37 | file_name |
| test.c:45:15:45:23 | array to pointer conversion | test.c:46:29:46:37 | file_name indirection |
| test.c:45:15:45:23 | file_name | test.c:46:29:46:37 | (LPCTSTR)... |
| test.c:45:15:45:23 | file_name | test.c:46:29:46:37 | file_name |
| test.c:45:15:45:23 | file_name | test.c:46:29:46:37 | file_name indirection |
| test.c:45:15:45:23 | scanf output argument | test.c:46:29:46:37 | (LPCTSTR)... |
| test.c:45:15:45:23 | scanf output argument | test.c:46:29:46:37 | file_name |
| test.c:45:15:45:23 | scanf output argument | test.c:46:29:46:37 | file_name indirection |
subpaths
nodes
| test.c:20:15:20:23 | array to pointer conversion | semmle.label | array to pointer conversion |
| test.c:20:15:20:23 | file_name | semmle.label | file_name |
| test.c:20:15:20:23 | scanf output argument | semmle.label | scanf output argument |
| test.c:21:8:21:16 | (const char *)... | semmle.label | (const char *)... |
| test.c:21:8:21:16 | (const char *)... | semmle.label | (const char *)... |
| test.c:21:8:21:16 | file_name | semmle.label | file_name |
| test.c:21:8:21:16 | file_name indirection | semmle.label | file_name indirection |
| test.c:21:8:21:16 | file_name indirection | semmle.label | file_name indirection |
| test.c:45:15:45:23 | array to pointer conversion | semmle.label | array to pointer conversion |
| test.c:45:15:45:23 | file_name | semmle.label | file_name |
| test.c:45:15:45:23 | scanf output argument | semmle.label | scanf output argument |
| test.c:46:29:46:37 | (LPCTSTR)... | semmle.label | (LPCTSTR)... |
| test.c:46:29:46:37 | (LPCTSTR)... | semmle.label | (LPCTSTR)... |
| test.c:46:29:46:37 | file_name | semmle.label | file_name |
| test.c:46:29:46:37 | file_name indirection | semmle.label | file_name indirection |
| test.c:46:29:46:37 | file_name indirection | semmle.label | file_name indirection |
subpaths
#select
| test.c:21:8:21:16 | file_name | test.c:20:15:20:23 | file_name | test.c:21:8:21:16 | file_name | This argument to a file access function is derived from $@ and then passed to func(file_name), which calls fopen((unnamed parameter 0)) | test.c:20:15:20:23 | file_name | user input (scanf) |
| test.c:46:29:46:37 | file_name | test.c:45:15:45:23 | file_name | test.c:46:29:46:37 | file_name | This argument to a file access function is derived from $@ and then passed to CreateFile(lpFileName) | test.c:45:15:45:23 | file_name | user input (scanf) |
| test.c:21:8:21:16 | file_name | test.c:20:15:20:23 | file_name | test.c:21:8:21:16 | file_name indirection | This argument to a file access function is derived from $@ and then passed to func(file_name), which calls fopen((unnamed parameter 0)). | test.c:20:15:20:23 | file_name | user input (scanf) |
| test.c:46:29:46:37 | file_name | test.c:45:15:45:23 | file_name | test.c:46:29:46:37 | file_name indirection | This argument to a file access function is derived from $@ and then passed to CreateFile(lpFileName). | test.c:45:15:45:23 | file_name | user input (scanf) |
6 changes: 4 additions & 2 deletions c/common/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion c/common/src/codingstandards/c/Pointers.qll
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ArrayPointerArithmeticExpr extends PointerArithmeticExpr, ArrayExpr {
* A null pointer constant, which is either in the form `NULL` or `(void *)0`.
*/
predicate isNullPointerConstant(Expr e) {
e.findRootCause() instanceof NULLMacro
e.findRootCause() instanceof NullMacro
or
exists(CStyleCast c |
not c.isImplicit() and
Expand Down
2 changes: 1 addition & 1 deletion c/common/src/qlpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ version: 2.19.0-dev
license: MIT
dependencies:
codeql/common-cpp-coding-standards: '*'
codeql/cpp-all: 0.3.5
codeql/cpp-all: 0.4.6
6 changes: 4 additions & 2 deletions c/common/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
6 changes: 4 additions & 2 deletions c/misra/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion c/misra/src/codeql-suites/misra-default.qls
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
- exclude:
tags contain:
- external/misra/audit
- external/misra/default-disabled
- external/misra/default-disabled
2 changes: 1 addition & 1 deletion c/misra/src/qlpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ suites: codeql-suites
license: MIT
dependencies:
codeql/common-c-coding-standards: '*'
codeql/cpp-all: 0.3.5
codeql/cpp-all: 0.4.6
6 changes: 4 additions & 2 deletions c/misra/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `FIO32-C` - `DoNotPerformFileOperationsOnDevices.ql`:
- The query was rewritten to no longer depend of the `DefaultTaintTracking` library, which will be deprecated.
1 change: 1 addition & 0 deletions change_notes/2023-07-30-update-to-2.11.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated the supported CodeQL version to `2.11.6`.
6 changes: 4 additions & 2 deletions cpp/autosar/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-advisory.qls
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
- external/autosar/obligation/advisory
- exclude:
tags contain:
- external/autosar/audit
- external/autosar/audit
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-audit.qls
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- problem
- path-problem
tags contain:
- external/autosar/audit
- external/autosar/audit
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-default.qls
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
- exclude:
tags contain:
- external/autosar/audit
- external/autosar/default-disabled
- external/autosar/default-disabled
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-required.qls
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
- external/autosar/obligation/required
- exclude:
tags contain:
- external/autosar/audit
- external/autosar/audit
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
- exclude:
tags contain:
- external/autosar/audit
- external/autosar/default-disabled
- external/autosar/default-disabled
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DefinedSizeType extends Type {

class DefinedSizeClass extends Class {
DefinedSizeClass() {
this.isPOD() and
this.isPod() and
forall(Field f | f = this.getAField() | f.getType() instanceof DefinedSizeType)
}
}
2 changes: 1 addition & 1 deletion cpp/autosar/src/qlpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ suites: codeql-suites
license: MIT
dependencies:
codeql/common-cpp-coding-standards: '*'
codeql/cpp-all: 0.3.5
codeql/cpp-all: 0.4.6
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ import codingstandards.cpp.Typehelpers
from Struct s
where
not isExcluded(s, ClassesPackage::nonPodTypeShouldBeDefinedAsClassQuery()) and
not s.isPOD()
not s.isPod()
select s, "Non-POD type defined as struct instead of class."
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import cpp
import codingstandards.cpp.autosar

class Object extends Class {
Object() { not this.(Struct).isPOD() }
Object() { not this.(Struct).isPod() }
}

predicate isPointerToObject(Expr e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ from HardwareOrProtocolInterfaceClass c
where
not isExcluded(c,
ClassesPackage::dataTypesUsedForInterfacingWithHardwareOrProtocolsMustBeTrivialAndStandardLayoutQuery()) and
not c.isPOD()
not c.isPod()
select c,
"Data type used for hardware interface or communication protocol is not standard layout and trivial."
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import cpp
import codingstandards.cpp.autosar

class NonPODType extends Class {
NonPODType() { not this.isPOD() }
NonPODType() { not this.isPod() }
}

from NonPODType p, Field f
Expand Down
6 changes: 4 additions & 2 deletions cpp/autosar/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
6 changes: 4 additions & 2 deletions cpp/cert/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
lockVersion: 1.0.0
dependencies:
codeql/cpp-all:
version: 0.3.5
version: 0.4.6
codeql/ssa:
version: 0.0.7
compiled: false
lockVersion: 1.0.0
Loading