Skip to content

Commit 908f48a

Browse files
authored
Merge branch 'main' into js/vue_tanstack_model
2 parents 5dff23d + 9a8cb1a commit 908f48a

File tree

160 files changed

+6770
-411
lines changed

Some content is hidden

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

160 files changed

+6770
-411
lines changed

.github/codeql/codeql-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ paths-ignore:
1010
- '/javascript/ql/test'
1111
- '/javascript/ql/integration-tests'
1212
- '/javascript/extractor/tests'
13+
- '/javascript/extractor/parser-tests'
14+
- '/javascript/ql/src/'
1315
- '/rust/ql'

Cargo.lock

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

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ use_repo(
7373
tree_sitter_extractors_deps,
7474
"vendor_ts__anyhow-1.0.96",
7575
"vendor_ts__argfile-0.2.1",
76+
"vendor_ts__chalk-ir-0.99.0",
7677
"vendor_ts__chrono-0.4.39",
7778
"vendor_ts__clap-4.5.31",
7879
"vendor_ts__dunce-1.0.5",
@@ -94,6 +95,7 @@ use_repo(
9495
"vendor_ts__ra_ap_hir-0.0.266",
9596
"vendor_ts__ra_ap_hir_def-0.0.266",
9697
"vendor_ts__ra_ap_hir_expand-0.0.266",
98+
"vendor_ts__ra_ap_hir_ty-0.0.266",
9799
"vendor_ts__ra_ap_ide_db-0.0.266",
98100
"vendor_ts__ra_ap_intern-0.0.266",
99101
"vendor_ts__ra_ap_load-cargo-0.0.266",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
- description: Security-and-quality queries for GitHub Actions
2-
- import: codeql-suites/actions-security-extended.qls
2+
- queries: .
3+
- apply: security-and-quality-selectors.yml
4+
from: codeql/suite-helpers
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
- description: Extended and experimental security queries for GitHub Actions
2-
- import: codeql-suites/actions-code-scanning.qls
2+
- queries: .
3+
- apply: security-experimental-selectors.yml
4+
from: codeql/suite-helpers
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added `Node.asUncertainDefinition` and `Node.asCertainDefinition` to the `DataFlow::Node` class for querying whether a definition overwrites the entire destination buffer.

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,79 @@ class Node extends TIRDataFlowNode {
313313
* `n.asExpr() instanceof IncrementOperation` since the result of evaluating
314314
* the expression `x++` is passed to `sink`.
315315
*/
316-
Expr asDefinition() {
317-
exists(StoreInstruction store |
316+
Expr asDefinition() { result = this.asDefinition(_) }
317+
318+
/**
319+
* Gets the definition associated with this node, if any.
320+
*
321+
* For example, consider the following example
322+
* ```cpp
323+
* int x = 42; // 1
324+
* x = 34; // 2
325+
* ++x; // 3
326+
* x++; // 4
327+
* x += 1; // 5
328+
* int y = x += 2; // 6
329+
* ```
330+
* - For (1) the result is `42`.
331+
* - For (2) the result is `x = 34`.
332+
* - For (3) the result is `++x`.
333+
* - For (4) the result is `x++`.
334+
* - For (5) the result is `x += 1`.
335+
* - For (6) there are two results:
336+
* - For the definition generated by `x += 2` the result is `x += 2`
337+
* - For the definition generated by `int y = ...` the result is
338+
* also `x += 2`.
339+
*
340+
* For assignments, `node.asDefinition(_)` and `node.asExpr()` will both exist
341+
* for the same dataflow node. However, for expression such as `x++` that
342+
* both write to `x` and read the current value of `x`, `node.asDefinition(_)`
343+
* will give the node corresponding to the value after the increment, and
344+
* `node.asExpr()` will give the node corresponding to the value before the
345+
* increment. For an example of this, consider the following:
346+
*
347+
* ```cpp
348+
* sink(x++);
349+
* ```
350+
* in the above program, there will not be flow from a node `n` such that
351+
* `n.asDefinition(_) instanceof IncrementOperation` to the argument of `sink`
352+
* since the value passed to `sink` is the value before to the increment.
353+
* However, there will be dataflow from a node `n` such that
354+
* `n.asExpr() instanceof IncrementOperation` since the result of evaluating
355+
* the expression `x++` is passed to `sink`.
356+
*
357+
* If `uncertain = false` then the definition is guaranteed to overwrite
358+
* the entire buffer pointed to by the destination address of the definition.
359+
* Otherwise, `uncertain = true`.
360+
*
361+
* For example, the write `int x; x = 42;` is guaranteed to overwrite all the
362+
* bytes allocated to `x`, while the assignment `int p[10]; p[3] = 42;` has
363+
* `uncertain = true` since the write will not overwrite the entire buffer
364+
* pointed to by `p`.
365+
*/
366+
Expr asDefinition(boolean uncertain) {
367+
exists(StoreInstruction store, Ssa::DefinitionExt def |
318368
store = this.asInstruction() and
319-
result = asDefinitionImpl(store)
369+
result = asDefinitionImpl(store) and
370+
Ssa::defToNode(this, def, _, _, _, _) and
371+
if def.isCertain() then uncertain = false else uncertain = true
320372
)
321373
}
322374

375+
/**
376+
* Gets the definition associated with this node, if this node is a certain definition.
377+
*
378+
* See `Node.asDefinition/1` for a description of certain and uncertain definitions.
379+
*/
380+
Expr asCertainDefinition() { result = this.asDefinition(false) }
381+
382+
/**
383+
* Gets the definition associated with this node, if this node is an uncertain definition.
384+
*
385+
* See `Node.asDefinition/1` for a description of certain and uncertain definitions.
386+
*/
387+
Expr asUncertainDefinition() { result = this.asDefinition(true) }
388+
323389
/**
324390
* Gets the indirect definition at a given indirection corresponding to this
325391
* node, if any.

cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import cpp
1313

1414
predicate allowedTypedefs(TypedefType t) {
15-
t.getName() = ["I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32"]
15+
t.getName() =
16+
[
17+
"I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32", "int64_t", "uint64_t",
18+
"int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t"
19+
]
1620
}
1721

1822
/**
@@ -46,6 +50,8 @@ from Declaration d, Type usedType
4650
where
4751
usedType = getAUsedType*(getAnImmediateUsedType(d)) and
4852
problematic(usedType) and
53+
// Allow uses of boolean types where defined by the language.
54+
not usedType instanceof BoolType and
4955
// Ignore violations for which we do not have a valid location.
5056
not d.getLocation() instanceof UnknownLocation
5157
select d,

cpp/ql/src/Security/CWE/CWE-079/CgiXss.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Config implements DataFlow::ConfigSig {
3737
predicate isBarrier(DataFlow::Node node) {
3838
isSink(node) and node.asExpr().getUnspecifiedType() instanceof ArithmeticType
3939
or
40-
node.asInstruction().(StoreInstruction).getResultType() instanceof ArithmeticType
40+
node.asCertainDefinition().getUnspecifiedType() instanceof ArithmeticType
4141
}
4242
}
4343

cpp/ql/src/Security/CWE/CWE-114/UncontrolledProcessOperation.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Config implements DataFlow::ConfigSig {
3737
predicate isBarrier(DataFlow::Node node) {
3838
isSink(node) and node.asExpr().getUnspecifiedType() instanceof ArithmeticType
3939
or
40-
node.asInstruction().(StoreInstruction).getResultType() instanceof ArithmeticType
40+
node.asCertainDefinition().getUnspecifiedType() instanceof ArithmeticType
4141
}
4242
}
4343

0 commit comments

Comments
 (0)