mirror of
https://github.com/github/codeql.git
synced 2026-04-23 15:55:18 +02:00
C#: Emulate that some methods don't have a body (so generated summaries will be applied)
This commit is contained in:
@@ -21,11 +21,15 @@ module TaintConfig implements DataFlow::ConfigSig {
|
||||
module Taint = TaintTracking::Global<TaintConfig>;
|
||||
|
||||
/**
|
||||
* Simulate that methods with summaries are not included in the source code.
|
||||
* This is relevant for dataflow analysis using summaries tagged as generated.
|
||||
* Emulate that methods with summaries do not have a body.
|
||||
* This is relevant for dataflow analysis using summaries with a generated like
|
||||
* provenance as generated summaries are only applied, if a
|
||||
* callable does not have a body.
|
||||
*/
|
||||
private class MyMethod extends Method {
|
||||
override predicate fromSource() { none() }
|
||||
private class MixedFlowArgs extends Method {
|
||||
MixedFlowArgs() { this.hasFullyQualifiedName("My.Qltest", "G", "MixedFlowArgs") }
|
||||
|
||||
override predicate hasBody() { none() }
|
||||
}
|
||||
|
||||
from Taint::PathNode source, Taint::PathNode sink
|
||||
|
||||
@@ -6,6 +6,22 @@ import semmle.code.csharp.dataflow.FlowSummary
|
||||
import semmle.code.csharp.dataflow.internal.DataFlowDispatch as DataFlowDispatch
|
||||
import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
|
||||
|
||||
/**
|
||||
* Emulate that methods with summaries do not have a body.
|
||||
* This is relevant for dataflow analysis using summaries with a generated like
|
||||
* provenance as generated summaries are only applied, if a
|
||||
* callable does not have a body.
|
||||
*/
|
||||
private class StepArgQualGenerated extends Method {
|
||||
StepArgQualGenerated() {
|
||||
exists(string name |
|
||||
this.hasFullyQualifiedName("My.Qltest", "C", name) and name.matches("StepArgQualGenerated%")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate hasBody() { none() }
|
||||
}
|
||||
|
||||
query predicate summaryThroughStep(
|
||||
DataFlow::Node node1, DataFlow::Node node2, boolean preservesValue
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user