C#/Java: Make configurations private and sprinkle some QL Doc.

This commit is contained in:
Michael Nebel
2022-03-23 13:45:39 +01:00
parent 6194d5cf63
commit 79fd2e6a40
10 changed files with 42 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
private import CaptureSinkModelsSpecific
class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
private class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
PropagateToSinkConfiguration() { this = "parameters or fields flowing into sinks" }
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, _) }
@@ -10,6 +10,9 @@ class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific
}
}
/**
* Gets the sink model(s) of `api`, if there is flow from a parameter to an existing known sink.
*/
string captureSink(TargetApi api) {
exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind |
config.hasFlow(src, sink) and

View File

@@ -1,7 +1,7 @@
private import CaptureSourceModelsSpecific
private import ModelGeneratorUtils
class FromSourceConfiguration extends TaintTracking::Configuration {
private class FromSourceConfiguration extends TaintTracking::Configuration {
FromSourceConfiguration() { this = "FromSourceConfiguration" }
override predicate isSource(DataFlow::Node source) { sourceNode(source, _) }
@@ -22,6 +22,9 @@ class FromSourceConfiguration extends TaintTracking::Configuration {
}
}
/**
* Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
*/
string captureSource(TargetApi api) {
exists(DataFlow::Node source, DataFlow::Node sink, FromSourceConfiguration config, string kind |
config.hasFlow(source, sink) and

View File

@@ -36,7 +36,7 @@ private class TaintStore extends DataFlow::FlowState {
*
* This can be used to generate Flow summaries for APIs from parameter to return.
*/
class ThroughFlowConfig extends TaintTracking::Configuration {
private class ThroughFlowConfig extends TaintTracking::Configuration {
ThroughFlowConfig() { this = "ThroughFlowConfig" }
override predicate isSource(DataFlow::Node source, DataFlow::FlowState state) {

View File

@@ -8,8 +8,17 @@ import semmle.code.csharp.dataflow.internal.DataFlowImplCommon
import semmle.code.csharp.dataflow.internal.DataFlowPrivate
import ModelGeneratorUtils
/**
* Gets the enclosing callable of `ret`.
*/
Callable returnNodeEnclosingCallable(ReturnNodeExt ret) { result = getNodeEnclosingCallable(ret) }
/**
* Holds if `node` is an own instance access.
*/
predicate isOwnInstanceAccessNode(ReturnNode node) { node.asExpr() instanceof ThisAccess }
/**
* Gets the CSV string representation of the qualifier.
*/
string qualifierString() { result = "Argument[Qualifier]" }

View File

@@ -5,6 +5,9 @@ private import semmle.code.csharp.commons.Collections
private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch
/**
* Holds if it is relevant to generate models for `api`.
*/
predicate isRelevantForModels(Callable api) { not api instanceof MainMethod }
/**