Skip to content

Commit ffeece1

Browse files
authored
Merge pull request #20410 from igfoo/igfoo/bmn-med
C++: Remove the BMN filter from some queries, but reduce precision to medium
2 parents 8ce2d39 + 050a9e1 commit ffeece1

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ ql/cpp/ql/src/Diagnostics/ExtractedFiles.ql
77
ql/cpp/ql/src/Diagnostics/ExtractionWarnings.ql
88
ql/cpp/ql/src/Diagnostics/FailedExtractorInvocations.ql
99
ql/cpp/ql/src/Likely Bugs/Arithmetic/BadAdditionOverflowCheck.ql
10-
ql/cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.ql
1110
ql/cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.ql
1211
ql/cpp/ql/src/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql
1312
ql/cpp/ql/src/Likely Bugs/Format/SnprintfOverflow.ql
1413
ql/cpp/ql/src/Likely Bugs/Format/WrongNumberOfFormatArguments.ql
15-
ql/cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql
1614
ql/cpp/ql/src/Likely Bugs/Memory Management/AllocaInLoop.ql
1715
ql/cpp/ql/src/Likely Bugs/Memory Management/PointerOverflow.ql
1816
ql/cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql
@@ -30,7 +28,6 @@ ql/cpp/ql/src/Security/CWE/CWE-120/VeryLikelyOverrunWrite.ql
3028
ql/cpp/ql/src/Security/CWE/CWE-131/NoSpaceForZeroTerminator.ql
3129
ql/cpp/ql/src/Security/CWE/CWE-134/UncontrolledFormatString.ql
3230
ql/cpp/ql/src/Security/CWE/CWE-190/ArithmeticUncontrolled.ql
33-
ql/cpp/ql/src/Security/CWE/CWE-190/ComparisonWithWiderType.ql
3431
ql/cpp/ql/src/Security/CWE/CWE-191/UnsignedDifferenceExpressionComparedZero.ql
3532
ql/cpp/ql/src/Security/CWE/CWE-253/HResultBooleanConversion.ql
3633
ql/cpp/ql/src/Security/CWE/CWE-311/CleartextFileWrite.ql
@@ -43,7 +40,6 @@ ql/cpp/ql/src/Security/CWE/CWE-367/TOCTOUFilesystemRace.ql
4340
ql/cpp/ql/src/Security/CWE/CWE-416/IteratorToExpiredContainer.ql
4441
ql/cpp/ql/src/Security/CWE/CWE-416/UseOfStringAfterLifetimeEnds.ql
4542
ql/cpp/ql/src/Security/CWE/CWE-416/UseOfUniquePointerAfterLifetimeEnds.ql
46-
ql/cpp/ql/src/Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql
4743
ql/cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql
4844
ql/cpp/ql/src/Security/CWE/CWE-611/XXE.ql
4945
ql/cpp/ql/src/Security/CWE/CWE-676/DangerousFunctionOverflow.ql

cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @kind problem
66
* @problem.severity warning
77
* @security-severity 8.1
8-
* @precision high
8+
* @precision medium
99
* @id cpp/integer-multiplication-cast-to-long
1010
* @tags reliability
1111
* security
@@ -179,7 +179,6 @@ predicate overflows(MulExpr me, Type t) {
179179

180180
from MulExpr me, Type t1, Type t2
181181
where
182-
not any(Compilation c).buildModeNone() and
183182
t1 = me.getType().getUnderlyingType() and
184183
t2 = me.getConversion().getType().getUnderlyingType() and
185184
t1.getSize() < t2.getSize() and

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @kind problem
66
* @problem.severity error
77
* @security-severity 7.5
8-
* @precision high
8+
* @precision medium
99
* @id cpp/wrong-type-format-argument
1010
* @tags reliability
1111
* correctness
@@ -154,7 +154,6 @@ int sizeof_IntType() { exists(IntType it | result = it.getSize()) }
154154

155155
from FormattingFunctionCall ffc, int n, Expr arg, Type expected, Type actual
156156
where
157-
not any(Compilation c).buildModeNone() and
158157
(
159158
formattingFunctionCallExpectedType(ffc, n, expected) and
160159
formattingFunctionCallActualType(ffc, n, arg, actual) and

cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* may lead to unpredictable behavior.
66
* @kind problem
77
* @problem.severity warning
8-
* @precision high
8+
* @precision medium
99
* @id cpp/implicit-function-declaration
1010
* @tags correctness
1111
* maintainability
@@ -38,7 +38,6 @@ predicate isCompiledAsC(File f) {
3838

3939
from FunctionDeclarationEntry fdeIm, FunctionCall fc
4040
where
41-
not any(Compilation c).buildModeNone() and
4241
isCompiledAsC(fdeIm.getFile()) and
4342
not isFromMacroDefinition(fc) and
4443
fdeIm.isImplicit() and

cpp/ql/src/Security/CWE/CWE-190/ComparisonWithWiderType.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @kind problem
77
* @problem.severity warning
88
* @security-severity 7.8
9-
* @precision high
9+
* @precision medium
1010
* @tags reliability
1111
* security
1212
* external/cwe/cwe-190
@@ -51,7 +51,6 @@ int getComparisonSizeAdjustment(Expr e) {
5151

5252
from Loop l, RelationalOperation rel, VariableAccess small, Expr large
5353
where
54-
not any(Compilation c).buildModeNone() and
5554
small = rel.getLesserOperand() and
5655
large = rel.getGreaterOperand() and
5756
rel = l.getCondition().getAChild*() and

cpp/ql/src/Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @kind problem
77
* @problem.severity warning
88
* @security-severity 8.8
9-
* @precision high
9+
* @precision medium
1010
* @id cpp/suspicious-add-sizeof
1111
* @tags security
1212
* external/cwe/cwe-468
@@ -24,7 +24,6 @@ private predicate isCharSzPtrExpr(Expr e) {
2424

2525
from Expr sizeofExpr, Expr e
2626
where
27-
not any(Compilation c).buildModeNone() and
2827
// If we see an addWithSizeof then we expect the type of
2928
// the pointer expression to be `char*` or `void*`. Otherwise it
3029
// is probably a mistake.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
* The queries `cpp/wrong-type-format-argument`, `cpp/comparison-with-wider-type`, `cpp/integer-multiplication-cast-to-long`, `cpp/implicit-function-declaration` and `cpp/suspicious-add-sizeof` have had their precisions reduced from `high` to `medium`. They will also now give alerts for projects built with `build-mode: none`.
5+
* The queries `cpp/wrong-type-format-argument`, `cpp/comparison-with-wider-type`, `cpp/integer-multiplication-cast-to-long` and `cpp/suspicious-add-sizeof` are no longer included in the `code-scanning` suite.

0 commit comments

Comments
 (0)