Skip to content

Commit 0d0ce32

Browse files
committed
Merge branch 'ruby-framework-grape' of github.com:felickz/codeql into ruby-framework-grape
2 parents fc98cd8 + 19cb187 commit 0d0ce32

File tree

53 files changed

+3209
-242
lines changed

Some content is hidden

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

53 files changed

+3209
-242
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: feature
33
---
4-
* Added predicates `getTransitiveNumberOfVlaDimensionStmts`, `getTransitiveVlaDimensionStmt`, and `getParentVlaDecl` to `VlaDeclStmt` for handling `VlaDeclStmt`s whose base type defined in terms of an other `VlaDeclStmt` via a `typedef`.
4+
* Added predicates `getTransitiveNumberOfVlaDimensionStmts`, `getTransitiveVlaDimensionStmt`, and `getParentVlaDecl` to `VlaDeclStmt` for handling `VlaDeclStmt`s whose base type is defined in terms of another `VlaDeclStmt` via a `typedef`.

csharp/ql/src/Likely Bugs/LeapYear/UnsafeYearConstruction.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<example>
1313
<p>In this example, we are incrementing/decrementing the current date by one year when creating a new <code>System.DateTime</code> object. This may work most of the time, but on any given February 29th, the resulting value will be invalid.</p>
1414
<sample src="UnsafeYearConstructionBad.cs" />
15-
<p>To fix this bug, we add/substract years to the current date by calling <code>AddYears</code> method on it.</p>
15+
<p>To fix this bug, we add/subtract years to the current date by calling <code>AddYears</code> method on it.</p>
1616
<sample src="UnsafeYearConstructionGood.cs" />
1717
</example>
1818
<references>

javascript/ql/src/LanguageFeatures/LengthComparisonOffByOne.ql

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ ConditionGuardNode getLengthLEGuard(Variable index, Variable array) {
3333
)
3434
}
3535

36+
/**
37+
* Gets a condition that checks that `index` is less than `array.length`.
38+
*/
39+
ConditionGuardNode getLengthLTGuard(Variable index, Variable array) {
40+
exists(RelationalComparison cmp | cmp instanceof GTExpr or cmp instanceof LTExpr |
41+
cmp = result.getTest() and
42+
result.getOutcome() = true and
43+
cmp.getGreaterOperand() = arrayLen(array) and
44+
cmp.getLesserOperand() = index.getAnAccess()
45+
)
46+
}
47+
3648
/**
3749
* Gets a condition that checks that `index` is not equal to `array.length`.
3850
*/
@@ -62,7 +74,8 @@ where
6274
elementRead(ea, array, index, bb) and
6375
// and the read is guarded by the comparison
6476
cond.dominates(bb) and
65-
// but the read is not guarded by another check that `index != array.length`
66-
not getLengthNEGuard(index, array).dominates(bb)
77+
// but the read is not guarded by another check that `index != array.length` or `index < array.length`
78+
not getLengthNEGuard(index, array).dominates(bb) and
79+
not getLengthLTGuard(index, array).dominates(bb)
6780
select cond.getTest(), "Off-by-one index comparison against length may lead to out-of-bounds $@.",
6881
ea, "read"

javascript/ql/src/Security/CWE-116/IncompleteMultiCharacterSanitization.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ str.replace(/\.\.\//g, "");
108108
</sample>
109109

110110
<p>
111-
The regular expression attempts to strip out all occurences of <code>/../</code> from <code>str</code>.
111+
The regular expression attempts to strip out all occurrences of <code>/../</code> from <code>str</code>.
112112
This will not work as expected: for the string <code>/./.././</code>, for example, it will remove the single
113113
occurrence of <code>/../</code> in the middle, but the remainder of the string then becomes
114114
<code>/../</code>, which is another instance of the substring we were trying to remove.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Query `js/index-out-of-bounds` no longer produces a false-positive when a strictly-less-than check overrides a previous less-than-or-equal test.

javascript/ql/test/query-tests/LanguageFeatures/LengthComparisonOffByOne/tst.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ function badContains(a, elt) {
5555
return true;
5656
return false;
5757
}
58+
59+
// OK - incorrect upper bound, but extra check
60+
function badContains2(a, elt) {
61+
for (let i = 0; i <= a.length; ++i)
62+
if (i < a.length && a[i] === elt)
63+
return true;
64+
return false;
65+
}

ruby/ql/lib/codeql/ruby/frameworks/Grape.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ private class GrapeParamsCall extends ParamsCallImpl {
136136
this.getParent+() = api.getADeclaration()
137137
)
138138
}
139-
}/**
139+
}
140+
141+
/**
140142
* A call to `headers` from within a Grape API endpoint or headers block.
141143
* Headers can also be a source of user input.
142144
*/

rust/ql/integration-tests/query-suite/rust-code-scanning.qls.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ql/rust/ql/src/queries/security/CWE-328/WeakSensitiveDataHashing.ql
1919
ql/rust/ql/src/queries/security/CWE-770/UncontrolledAllocationSize.ql
2020
ql/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
2121
ql/rust/ql/src/queries/security/CWE-825/AccessInvalidPointer.ql
22+
ql/rust/ql/src/queries/security/CWE-918/RequestForgery.ql
2223
ql/rust/ql/src/queries/summary/LinesOfCode.ql
2324
ql/rust/ql/src/queries/summary/LinesOfUserCode.ql
2425
ql/rust/ql/src/queries/summary/NodesWithTypeAtLengthLimit.ql

rust/ql/integration-tests/query-suite/rust-security-and-quality.qls.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ql/rust/ql/src/queries/security/CWE-770/UncontrolledAllocationSize.ql
2222
ql/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
2323
ql/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql
2424
ql/rust/ql/src/queries/security/CWE-825/AccessInvalidPointer.ql
25+
ql/rust/ql/src/queries/security/CWE-918/RequestForgery.ql
2526
ql/rust/ql/src/queries/summary/LinesOfCode.ql
2627
ql/rust/ql/src/queries/summary/LinesOfUserCode.ql
2728
ql/rust/ql/src/queries/summary/NodesWithTypeAtLengthLimit.ql

rust/ql/integration-tests/query-suite/rust-security-extended.qls.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ql/rust/ql/src/queries/security/CWE-770/UncontrolledAllocationSize.ql
2121
ql/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
2222
ql/rust/ql/src/queries/security/CWE-825/AccessAfterLifetime.ql
2323
ql/rust/ql/src/queries/security/CWE-825/AccessInvalidPointer.ql
24+
ql/rust/ql/src/queries/security/CWE-918/RequestForgery.ql
2425
ql/rust/ql/src/queries/summary/LinesOfCode.ql
2526
ql/rust/ql/src/queries/summary/LinesOfUserCode.ql
2627
ql/rust/ql/src/queries/summary/NodesWithTypeAtLengthLimit.ql

0 commit comments

Comments
 (0)