Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79fd2e6

Browse files
committed
C#/Java: Make configurations private and sprinkle some QL Doc.
1 parent 6194d5c commit 79fd2e6

10 files changed

Lines changed: 42 additions & 6 deletions

csharp/ql/src/utils/model-generator/CaptureSinkModels.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
private import CaptureSinkModelsSpecific
22

3-
class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
3+
private class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
44
PropagateToSinkConfiguration() { this = "parameters or fields flowing into sinks" }
55

66
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, _) }
@@ -10,6 +10,9 @@ class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific
1010
}
1111
}
1212

13+
/**
14+
* Gets the sink model(s) of `api`, if there is flow from a parameter to an existing known sink.
15+
*/
1316
string captureSink(TargetApi api) {
1417
exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind |
1518
config.hasFlow(src, sink) and

csharp/ql/src/utils/model-generator/CaptureSourceModels.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
private import CaptureSourceModelsSpecific
22
private import ModelGeneratorUtils
33

4-
class FromSourceConfiguration extends TaintTracking::Configuration {
4+
private class FromSourceConfiguration extends TaintTracking::Configuration {
55
FromSourceConfiguration() { this = "FromSourceConfiguration" }
66

77
override predicate isSource(DataFlow::Node source) { sourceNode(source, _) }
@@ -22,6 +22,9 @@ class FromSourceConfiguration extends TaintTracking::Configuration {
2222
}
2323
}
2424

25+
/**
26+
* Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
27+
*/
2528
string captureSource(TargetApi api) {
2629
exists(DataFlow::Node source, DataFlow::Node sink, FromSourceConfiguration config, string kind |
2730
config.hasFlow(source, sink) and

csharp/ql/src/utils/model-generator/CaptureSummaryModels.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private class TaintStore extends DataFlow::FlowState {
3636
*
3737
* This can be used to generate Flow summaries for APIs from parameter to return.
3838
*/
39-
class ThroughFlowConfig extends TaintTracking::Configuration {
39+
private class ThroughFlowConfig extends TaintTracking::Configuration {
4040
ThroughFlowConfig() { this = "ThroughFlowConfig" }
4141

4242
override predicate isSource(DataFlow::Node source, DataFlow::FlowState state) {

csharp/ql/src/utils/model-generator/CaptureSummaryModelsSpecific.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ import semmle.code.csharp.dataflow.internal.DataFlowImplCommon
88
import semmle.code.csharp.dataflow.internal.DataFlowPrivate
99
import ModelGeneratorUtils
1010

11+
/**
12+
* Gets the enclosing callable of `ret`.
13+
*/
1114
Callable returnNodeEnclosingCallable(ReturnNodeExt ret) { result = getNodeEnclosingCallable(ret) }
1215

16+
/**
17+
* Holds if `node` is an own instance access.
18+
*/
1319
predicate isOwnInstanceAccessNode(ReturnNode node) { node.asExpr() instanceof ThisAccess }
1420

21+
/**
22+
* Gets the CSV string representation of the qualifier.
23+
*/
1524
string qualifierString() { result = "Argument[Qualifier]" }

csharp/ql/src/utils/model-generator/ModelGeneratorUtilsSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ private import semmle.code.csharp.commons.Collections
55
private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon
66
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch
77

8+
/**
9+
* Holds if it is relevant to generate models for `api`.
10+
*/
811
predicate isRelevantForModels(Callable api) { not api instanceof MainMethod }
912

1013
/**

java/ql/src/utils/model-generator/CaptureSinkModels.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
private import CaptureSinkModelsSpecific
22

3-
class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
3+
private class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific {
44
PropagateToSinkConfiguration() { this = "parameters or fields flowing into sinks" }
55

66
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, _) }
@@ -10,6 +10,9 @@ class PropagateToSinkConfiguration extends PropagateToSinkConfigurationSpecific
1010
}
1111
}
1212

13+
/**
14+
* Gets the sink model(s) of `api`, if there is flow from a parameter to an existing known sink.
15+
*/
1316
string captureSink(TargetApi api) {
1417
exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind |
1518
config.hasFlow(src, sink) and

java/ql/src/utils/model-generator/CaptureSourceModels.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
private import CaptureSourceModelsSpecific
22
private import ModelGeneratorUtils
33

4-
class FromSourceConfiguration extends TaintTracking::Configuration {
4+
private class FromSourceConfiguration extends TaintTracking::Configuration {
55
FromSourceConfiguration() { this = "FromSourceConfiguration" }
66

77
override predicate isSource(DataFlow::Node source) { sourceNode(source, _) }
@@ -22,6 +22,9 @@ class FromSourceConfiguration extends TaintTracking::Configuration {
2222
}
2323
}
2424

25+
/**
26+
* Gets the source model(s) of `api`, if there is flow from an existing known source to the return of `api`.
27+
*/
2528
string captureSource(TargetApi api) {
2629
exists(DataFlow::Node source, DataFlow::Node sink, FromSourceConfiguration config, string kind |
2730
config.hasFlow(source, sink) and

java/ql/src/utils/model-generator/CaptureSummaryModels.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private class TaintStore extends DataFlow::FlowState {
3636
*
3737
* This can be used to generate Flow summaries for APIs from parameter to return.
3838
*/
39-
class ThroughFlowConfig extends TaintTracking::Configuration {
39+
private class ThroughFlowConfig extends TaintTracking::Configuration {
4040
ThroughFlowConfig() { this = "ThroughFlowConfig" }
4141

4242
override predicate isSource(DataFlow::Node source, DataFlow::FlowState state) {

java/ql/src/utils/model-generator/CaptureSummaryModelsSpecific.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ import semmle.code.java.dataflow.internal.DataFlowPrivate
1010
import semmle.code.java.dataflow.InstanceAccess
1111
import ModelGeneratorUtils
1212

13+
/**
14+
* Gets the enclosing callable of `ret`.
15+
*/
1316
Callable returnNodeEnclosingCallable(ReturnNodeExt ret) {
1417
result = getNodeEnclosingCallable(ret).asCallable()
1518
}
1619

20+
/**
21+
* Holds if `node` is an own instance access.
22+
*/
1723
predicate isOwnInstanceAccessNode(ReturnNode node) {
1824
node.asExpr().(ThisAccess).isOwnInstanceAccess()
1925
}
2026

27+
/**
28+
* Gets the CSV string representation of the qualifier.
29+
*/
2130
string qualifierString() { result = "Argument[-1]" }

java/ql/src/utils/model-generator/ModelGeneratorUtilsSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ private predicate isJdkInternal(CompilationUnit cu) {
3636
cu.getPackage().getName() = ""
3737
}
3838

39+
/**
40+
* Holds if it is relevant to generate models for `api`.
41+
*/
3942
predicate isRelevantForModels(Callable api) {
4043
not isInTestFile(api.getCompilationUnit().getFile()) and
4144
not isJdkInternal(api.getCompilationUnit()) and

0 commit comments

Comments
 (0)