Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4fea2b0

Browse filesBrowse files
committed
Shared: Sprinkle some predicate defaults and clean up.
1 parent b2fe7cb commit 4fea2b0
Copy full SHA for 4fea2b0

File tree

5 files changed

+22
-79
lines changed
Filter options

5 files changed

+22
-79
lines changed

‎cpp/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Copy file name to clipboardExpand all lines: cpp/ql/src/utils/modelgenerator/internal/CaptureModels.qll
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,6 @@ private module SummaryModelGeneratorInput implements SummaryModelGeneratorInputS
352352
result = "Element[" + ec.getIndirectionIndex() + "]"
353353
)
354354
}
355-
356-
predicate isUninterestingForDataFlowModels(Callable api) { none() }
357-
358-
predicate isUninterestingForHeuristicDataFlowModels(Callable api) {
359-
isUninterestingForDataFlowModels(api)
360-
}
361355
}
362356

363357
private module SourceModelGeneratorInput implements SourceModelGeneratorInputSig {
@@ -369,11 +363,6 @@ private module SourceModelGeneratorInput implements SourceModelGeneratorInputSig
369363
SourceTargetApi() { relevant(this) and not hasManualSourceModel(this) }
370364
}
371365

372-
predicate irrelevantSourceSinkApi(Callable source, SourceTargetApi api) { none() }
373-
374-
bindingset[kind]
375-
predicate isRelevantSourceKind(string kind) { any() }
376-
377366
predicate sourceNode = ExternalFlow::sourceNode/2;
378367
}
379368

@@ -388,8 +377,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
388377
SinkTargetApi() { relevant(this) and not hasManualSinkModel(this) }
389378
}
390379

391-
predicate sinkModelSanitizer(DataFlow::Node node) { none() }
392-
393380
predicate apiSource(DataFlow::Node source) {
394381
DataFlowPrivate::nodeHasOperand(source, any(DataFlow::FieldAddress fa), 1)
395382
or
@@ -408,9 +395,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
408395
result = qualifierString()
409396
}
410397

411-
bindingset[kind]
412-
predicate isRelevantSinkKind(string kind) { any() }
413-
414398
predicate sinkNode = ExternalFlow::sinkNode/2;
415399
}
416400

‎csharp/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Copy file name to clipboardExpand all lines: csharp/ql/src/utils/modelgenerator/internal/CaptureModels.qll
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ module SummaryModelGeneratorInput implements SummaryModelGeneratorInputSig {
234234
api = any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel())
235235
}
236236

237-
predicate isUninterestingForDataFlowModels(Callable api) { none() }
238-
239237
predicate isUninterestingForHeuristicDataFlowModels(Callable api) { isHigherOrder(api) }
240238

241239
class SummaryTargetApi extends Callable {
@@ -356,9 +354,6 @@ private module SourceModelGeneratorInput implements SourceModelGeneratorInputSig
356354
)
357355
}
358356

359-
bindingset[kind]
360-
predicate isRelevantSourceKind(string kind) { any() }
361-
362357
predicate sourceNode = ExternalFlow::sourceNode/2;
363358
}
364359

@@ -372,8 +367,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
372367
SinkTargetApi() { relevant(this) and not hasManualSinkModel(this) }
373368
}
374369

375-
predicate sinkModelSanitizer(DataFlow::Node node) { none() }
376-
377370
private predicate isRelevantMemberAccess(DataFlow::Node node) {
378371
exists(CS::MemberAccess access | access = node.asExpr() |
379372
access.hasThisQualifier() and
@@ -400,9 +393,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
400393
result = qualifierString()
401394
}
402395

403-
bindingset[kind]
404-
predicate isRelevantSinkKind(string kind) { any() }
405-
406396
predicate sinkNode = ExternalFlow::sinkNode/2;
407397
}
408398

‎java/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Copy file name to clipboardExpand all lines: java/ql/src/utils/modelgenerator/internal/CaptureModels.qll
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ module SummaryModelGeneratorInput implements SummaryModelGeneratorInputSig {
211211
api.getDeclaringType() instanceof J::Interface and not exists(api.getBody())
212212
}
213213

214-
predicate isUninterestingForHeuristicDataFlowModels(Callable api) { none() }
215-
216214
predicate isAdditionalContentFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
217215
TaintTracking::defaultAdditionalTaintStep(node1, node2, _) and
218216
not exists(DataFlow::Content f |
@@ -264,11 +262,6 @@ private module SourceModelGeneratorInput implements SourceModelGeneratorInputSig
264262
SourceTargetApi() { relevant(this) and not hasManualSourceModel(this) }
265263
}
266264

267-
predicate irrelevantSourceSinkApi(Callable source, SourceTargetApi api) { none() }
268-
269-
bindingset[kind]
270-
predicate isRelevantSourceKind(string kind) { any() }
271-
272265
predicate sourceNode = ExternalFlow::sourceNode/2;
273266
}
274267

‎rust/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Copy file name to clipboardExpand all lines: rust/ql/src/utils/modelgenerator/internal/CaptureModels.qll
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ private module SummaryModelGeneratorInput implements SummaryModelGeneratorInputS
123123

124124
Parameter asParameter(NodeExtended node) { result = node.asParameter() }
125125

126-
predicate isUninterestingForDataFlowModels(Callable api) { none() }
127-
128-
predicate isUninterestingForHeuristicDataFlowModels(Callable api) { none() }
129-
130126
predicate isAdditionalContentFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { none() }
131127

132128
predicate isField(DataFlow::ContentSet c) {
@@ -169,12 +165,6 @@ private module SourceModelGeneratorInput implements SourceModelGeneratorInputSig
169165
SourceTargetApi() { relevant(this) }
170166
}
171167

172-
bindingset[sourceEnclosing, api]
173-
predicate irrelevantSourceSinkApi(Callable sourceEnclosing, SourceTargetApi api) { none() }
174-
175-
bindingset[kind]
176-
predicate isRelevantSourceKind(string kind) { any() }
177-
178168
predicate sourceNode(DataFlow::Node node, string kind) { FlowSource::sourceNode(node, kind) }
179169
}
180170

@@ -183,8 +173,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
183173
SinkTargetApi() { relevant(this) }
184174
}
185175

186-
predicate sinkModelSanitizer(DataFlow::Node node) { none() }
187-
188176
/**
189177
* Holds if `source` is an API entrypoint, i.e., a source of input where data
190178
* can flow in to a library. This is used for creating sink models, as we
@@ -197,9 +185,6 @@ private module SinkModelGeneratorInput implements SinkModelGeneratorInputSig {
197185
result = "Argument[" + source.(Node::SourceParameterNode).getPosition().toString() + "]"
198186
}
199187

200-
bindingset[kind]
201-
predicate isRelevantSinkKind(string kind) { any() }
202-
203188
predicate sinkNode(DataFlow::Node node, string kind) { FlowSink::sinkNode(node, kind) }
204189
}
205190

‎shared/mad/codeql/mad/modelgenerator/internal/ModelGeneratorImpl.qll

Copy file name to clipboardExpand all lines: shared/mad/codeql/mad/modelgenerator/internal/ModelGeneratorImpl.qll
+22-31Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ module MakeModelGeneratorFactory<
295295
*
296296
* This serves as an extra filter for the `relevant` predicate.
297297
*/
298-
predicate isUninterestingForDataFlowModels(Callable api);
298+
default predicate isUninterestingForDataFlowModels(Callable api) { none() }
299299

300300
/**
301301
* Holds if it is irrelevant to generate models for `api` based on the heuristic
@@ -304,7 +304,7 @@ module MakeModelGeneratorFactory<
304304
* This serves as an extra filter for the `relevant`
305305
* and `isUninterestingForDataFlowModels` predicates.
306306
*/
307-
predicate isUninterestingForHeuristicDataFlowModels(Callable api);
307+
default predicate isUninterestingForHeuristicDataFlowModels(Callable api) { none() }
308308
}
309309

310310
/**
@@ -936,24 +936,20 @@ module MakeModelGeneratorFactory<
936936
*/
937937
class SourceTargetApi extends Callable;
938938

939-
/**
940-
* Holds if it is not relevant to generate a source model for `api`, even
941-
* if flow is detected from a node within `source` to a sink within `api`.
942-
*/
943-
bindingset[sourceEnclosing, api]
944-
predicate irrelevantSourceSinkApi(Callable sourceEnclosing, SourceTargetApi api);
945-
946-
/**
947-
* Holds if `kind` is a relevant source kind for creating source models.
948-
*/
949-
bindingset[kind]
950-
predicate isRelevantSourceKind(string kind);
951-
952939
/**
953940
* Holds if `node` is specified as a source with the given kind in a MaD flow
954941
* model.
955942
*/
956943
predicate sourceNode(Lang::Node node, string kind);
944+
945+
/**
946+
* Holds if it is not relevant to generate a source model for `api`, even
947+
* if flow is detected from a node within `source` to a sink within `api`.
948+
*/
949+
bindingset[sourceEnclosing, api]
950+
default predicate irrelevantSourceSinkApi(Callable sourceEnclosing, SourceTargetApi api) {
951+
none()
952+
}
957953
}
958954

959955
/**
@@ -966,31 +962,31 @@ module MakeModelGeneratorFactory<
966962
class SinkTargetApi extends Callable;
967963

968964
/**
969-
* Gets the MaD input string representation of `source`.
965+
* Holds if `node` is specified as a sink with the given kind in a MaD flow
966+
* model.
970967
*/
971-
string getInputArgument(Lang::Node source);
968+
predicate sinkNode(Lang::Node node, string kind);
972969

973970
/**
974-
* Holds if `node` is a sanitizer for sink model construction.
971+
* Gets the MaD input string representation of `source`.
975972
*/
976-
predicate sinkModelSanitizer(Lang::Node node);
973+
string getInputArgument(Lang::Node source);
977974

978975
/**
979976
* Holds if `source` is an api entrypoint relevant for creating sink models.
980977
*/
981978
predicate apiSource(Lang::Node source);
982979

983980
/**
984-
* Holds if `kind` is a relevant sink kind for creating sink models.
981+
* Holds if `node` is a sanitizer for sink model construction.
985982
*/
986-
bindingset[kind]
987-
predicate isRelevantSinkKind(string kind);
983+
default predicate sinkModelSanitizer(Lang::Node node) { none() }
988984

989985
/**
990-
* Holds if `node` is specified as a sink with the given kind in a MaD flow
991-
* model.
986+
* Holds if `kind` is a relevant sink kind for creating sink models.
992987
*/
993-
predicate sinkNode(Lang::Node node, string kind);
988+
bindingset[kind]
989+
default predicate isRelevantSinkKind(string kind) { any() }
994990
}
995991

996992
/**
@@ -1025,12 +1021,7 @@ module MakeModelGeneratorFactory<
10251021
* via its return (then the API itself becomes a source).
10261022
*/
10271023
module PropagateFromSourceConfig implements DataFlow::ConfigSig {
1028-
predicate isSource(DataFlow::Node source) {
1029-
exists(string kind |
1030-
isRelevantSourceKind(kind) and
1031-
sourceNode(source, kind)
1032-
)
1033-
}
1024+
predicate isSource(DataFlow::Node source) { sourceNode(source, _) }
10341025

10351026
predicate isSink(DataFlow::Node sink) {
10361027
sink instanceof ReturnNodeExt and

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.