Skip to content

Commit 3d2bd8f

Browse files
committed
Merge branch 'main' into redsun82/cargo-upgrade-2
2 parents 4df4794 + f1ca0ec commit 3d2bd8f

File tree

70 files changed

+851
-46
lines changed

Some content is hidden

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

70 files changed

+851
-46
lines changed

cpp/ql/src/Best Practices/SloppyGlobal.ql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import semmle.code.cpp.ConfigurationTestFile
1414
from GlobalVariable gv
1515
where
1616
gv.getName().length() <= 3 and
17+
// We will give an alert for the TemplateVariable, so we don't
18+
// need to also give one for each instantiation
19+
not gv instanceof VariableTemplateInstantiation and
1720
not gv.isStatic() and
1821
not gv.getFile() instanceof ConfigurationTestFile // variables in files generated during configuration are likely false positives
1922
select gv,

cpp/ql/src/Critical/OverflowDestination.ql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ module OverflowDestinationConfig implements DataFlow::ConfigSig {
8282
nodeIsBarrierEqualityCandidate(node, access, checkedVar)
8383
)
8484
}
85+
86+
predicate observeDiffInformedIncrementalMode() { any() }
87+
88+
Location getASelectedSourceLocation(DataFlow::Node source) { none() }
89+
90+
Location getASelectedSinkLocation(DataFlow::Node sink) {
91+
exists(FunctionCall fc | result = fc.getLocation() |
92+
sourceSized(fc, sink.asIndirectConvertedExpr())
93+
)
94+
}
8595
}
8696

8797
module OverflowDestination = TaintTracking::Global<OverflowDestinationConfig>;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ module NonConstFlowConfig implements DataFlow::ConfigSig {
168168
cannotContainString(t)
169169
)
170170
}
171+
172+
predicate observeDiffInformedIncrementalMode() { any() }
173+
174+
Location getASelectedSourceLocation(DataFlow::Node source) { none() }
175+
176+
Location getASelectedSinkLocation(DataFlow::Node sink) {
177+
result = sink.getLocation()
178+
or
179+
exists(FormattingFunctionCall call, Expr formatString | result = call.getLocation() |
180+
isSinkImpl(sink, formatString) and
181+
call.getArgument(call.getFormatParameterIndex()) = formatString
182+
)
183+
}
171184
}
172185

173186
module NonConstFlow = TaintTracking::Global<NonConstFlowConfig>;

cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ private module LeapYearCheckConfig implements DataFlow::ConfigSig {
215215
predicate isSink(DataFlow::Node sink) {
216216
exists(ChecksForLeapYearFunctionCall fc | sink.asExpr() = fc.getAnArgument())
217217
}
218+
219+
predicate observeDiffInformedIncrementalMode() {
220+
none() // only used negatively in UncheckedLeapYearAfterYearModification.ql
221+
}
218222
}
219223

220224
module LeapYearCheckFlow = DataFlow::Global<LeapYearCheckConfig>;
@@ -285,6 +289,14 @@ private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::C
285289
aexpr.getLValue() = fa
286290
)
287291
}
292+
293+
predicate observeDiffInformedIncrementalMode() { any() }
294+
295+
Location getASelectedSourceLocation(DataFlow::Node source) {
296+
result = source.asExpr().getLocation()
297+
}
298+
299+
Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.asExpr().getLocation() }
288300
}
289301

290302
module PossibleYearArithmeticOperationCheckFlow =

cpp/ql/src/Security/CWE/CWE-022/TaintedPath.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ module TaintedPathConfig implements DataFlow::ConfigSig {
9393
// make sinks barriers so that we only report the closest instance
9494
isSink(node)
9595
}
96+
97+
predicate observeDiffInformedIncrementalMode() { any() }
98+
99+
Location getASelectedSinkLocation(DataFlow::Node sink) {
100+
result = sink.asIndirectArgument().getLocation()
101+
}
96102
}
97103

98104
module TaintedPath = TaintTracking::Global<TaintedPathConfig>;

cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ module ExecTaintConfig implements DataFlow::StateConfigSig {
150150
predicate isBarrierOut(DataFlow::Node node) {
151151
isSink(node, _) // Prevent duplicates along a call chain, since `shellCommand` will include wrappers
152152
}
153+
154+
predicate observeDiffInformedIncrementalMode() { any() }
155+
156+
Location getASelectedSinkLocation(DataFlow::Node sink) {
157+
exists(DataFlow::Node concatResult, Expr command, ExecState state |
158+
result = [concatResult.getLocation(), command.getLocation()] and
159+
isSink(sink, state) and
160+
isSinkImpl(sink, command, _) and
161+
concatResult = state.getOutgoingNode()
162+
)
163+
}
153164
}
154165

155166
module ExecTaint = TaintTracking::GlobalWithState<ExecTaintConfig>;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ module Config implements DataFlow::ConfigSig {
3939
or
4040
node.asCertainDefinition().getUnspecifiedType() instanceof ArithmeticType
4141
}
42+
43+
predicate observeDiffInformedIncrementalMode() { any() }
44+
45+
Location getASelectedSourceLocation(DataFlow::Node source) {
46+
exists(QueryString query | result = query.getLocation() | query = source.asIndirectExpr())
47+
}
4248
}
4349

4450
module Flow = TaintTracking::Global<Config>;

cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ module SqlTaintedConfig implements DataFlow::ConfigSig {
5454
sql.barrierSqlArgument(input, _)
5555
)
5656
}
57+
58+
predicate observeDiffInformedIncrementalMode() { any() }
59+
60+
Location getASelectedSinkLocation(DataFlow::Node sink) {
61+
exists(Expr taintedArg | result = taintedArg.getLocation() | taintedArg = asSinkExpr(sink))
62+
}
5763
}
5864

5965
module SqlTainted = TaintTracking::Global<SqlTaintedConfig>;

cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ module Config implements DataFlow::ConfigSig {
124124
// Block flow if the node is guarded by any <, <= or = operations.
125125
node = DataFlow::BarrierGuard<lessThanOrEqual/3>::getABarrierNode()
126126
}
127+
128+
predicate observeDiffInformedIncrementalMode() { any() }
129+
130+
Location getASelectedSinkLocation(DataFlow::Node sink) {
131+
exists(BufferWrite bw | result = bw.getLocation() | isSink(sink, bw, _))
132+
}
127133
}
128134

129135
module Flow = TaintTracking::Global<Config>;

cpp/ql/src/Security/CWE/CWE-170/ImproperNullTerminationTainted.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ private module Config implements DataFlow::ConfigSig {
4343
}
4444

4545
predicate isSink(DataFlow::Node sink) { isSink(sink, _) }
46+
47+
predicate observeDiffInformedIncrementalMode() { any() }
48+
49+
Location getASelectedSinkLocation(DataFlow::Node sink) {
50+
exists(VariableAccess va | result = va.getLocation() | isSink(sink, va))
51+
}
4652
}
4753

4854
module Flow = TaintTracking::Global<Config>;

0 commit comments

Comments
 (0)