Skip to content

Commit 7c1bfdb

Browse files
authored
Merge pull request github#11511 from github/tiferet/renamings
Rename predicates to fit style guide
2 parents bd129ed + 4a6de3e commit 7c1bfdb

File tree

8 files changed

+89
-87
lines changed

8 files changed

+89
-87
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ abstract class AtmConfig extends JS::TaintTracking::Configuration {
6363
// If the list of characteristics includes positive indicators with maximal confidence for this class, then it's a
6464
// known sink for the class.
6565
exists(EndpointCharacteristics::EndpointCharacteristic characteristic |
66-
characteristic.getEndpoints(sink) and
66+
characteristic.appliesToEndpoint(sink) and
6767
characteristic
68-
.getImplications(this.getASinkEndpointType(), true, characteristic.maximalConfidence())
68+
.hasImplications(this.getASinkEndpointType(), true, characteristic.maximalConfidence())
6969
)
7070
}
7171

@@ -99,18 +99,18 @@ abstract class AtmConfig extends JS::TaintTracking::Configuration {
9999
// have given the endpoint filter characteristics medium confidence, and we exclude endpoints that have a
100100
// medium-confidence characteristic that indicates that they are not sinks, either in general or for this sink type.
101101
exists(EndpointCharacteristics::EndpointCharacteristic filter, float confidence |
102-
filter.getEndpoints(candidateSink) and
102+
filter.appliesToEndpoint(candidateSink) and
103103
confidence >= filter.mediumConfidence() and
104104
// TODO: Experiment with excluding all endpoints that have a medium- or high-confidence characteristic that
105105
// implies they're not sinks, rather than using only medium-confidence characteristics, by deleting the following
106106
// line.
107107
confidence < filter.highConfidence() and
108108
(
109109
// Exclude endpoints that have a characteristic that implies they're not sinks for _any_ sink type.
110-
filter.getImplications(any(NegativeType negative), true, confidence)
110+
filter.hasImplications(any(NegativeType negative), true, confidence)
111111
or
112112
// Exclude endpoints that have a characteristic that implies they're not sinks for _this particular_ sink type.
113-
filter.getImplications(this.getASinkEndpointType(), false, confidence)
113+
filter.hasImplications(this.getASinkEndpointType(), false, confidence)
114114
) and
115115
result = filter
116116
)
@@ -147,7 +147,9 @@ abstract class AtmConfig extends JS::TaintTracking::Configuration {
147147
* to this ML-boosted configuration, whereas the unboosted base query does not contain this source and sink
148148
* combination.
149149
*/
150-
predicate getAlerts(JS::DataFlow::PathNode source, JS::DataFlow::PathNode sink, float score) {
150+
predicate hasBoostedFlowPath(
151+
JS::DataFlow::PathNode source, JS::DataFlow::PathNode sink, float score
152+
) {
151153
this.hasFlowPath(source, sink) and
152154
not AtmResultsInfo::isFlowLikelyInBaseQuery(source.getNode(), sink.getNode()) and
153155
score = AtmResultsInfo::getScoreForFlow(source.getNode(), sink.getNode())

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointCharacteristics.qll

Lines changed: 64 additions & 64 deletions
Large diffs are not rendered by default.

javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointDataTraining.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ predicate tokenFeatures(DataFlow::Node endpoint, string featureName, string feat
5353
query predicate trainingEndpoints(
5454
DataFlow::Node endpoint, EndpointType endpointClass, EndpointCharacteristic characteristic
5555
) {
56-
characteristic.getEndpoints(endpoint) and
56+
characteristic.appliesToEndpoint(endpoint) and
5757
// Only consider the source code for the project being analyzed.
5858
exists(endpoint.getFile().getRelativePath()) and
5959
// Only select endpoints that can be part of a tainted flow: Constant expressions always evaluate to a constant
@@ -69,7 +69,7 @@ query predicate trainingEndpoints(
6969
not (
7070
endpointClass instanceof NegativeType and
7171
exists(EndpointCharacteristic c |
72-
c.getEndpoints(endpoint) and
72+
c.appliesToEndpoint(endpoint) and
7373
c instanceof LikelyNotASinkCharacteristic
7474
)
7575
) and
@@ -81,8 +81,8 @@ query predicate trainingEndpoints(
8181
// If the list of characteristics includes positive indicators with high confidence for this class, select this as a
8282
// training sample belonging to the class.
8383
exists(EndpointCharacteristic characteristic2, float confidence |
84-
characteristic2.getEndpoints(endpoint) and
85-
characteristic2.getImplications(endpointClass, true, confidence) and
84+
characteristic2.appliesToEndpoint(endpoint) and
85+
characteristic2.hasImplications(endpointClass, true, confidence) and
8686
confidence >= characteristic2.getHighConfidenceThreshold()
8787
) and
8888
(
@@ -93,8 +93,8 @@ query predicate trainingEndpoints(
9393
not endpointClass instanceof NegativeType
9494
or
9595
not exists(EndpointCharacteristic characteristic3, float confidence3, EndpointType posClass |
96-
characteristic3.getEndpoints(endpoint) and
97-
characteristic3.getImplications(posClass, true, confidence3) and
96+
characteristic3.appliesToEndpoint(endpoint) and
97+
characteristic3.hasImplications(posClass, true, confidence3) and
9898
confidence3 >= characteristic3.getHighConfidenceThreshold() and
9999
not posClass instanceof NegativeType
100100
)
@@ -106,8 +106,8 @@ query predicate trainingEndpoints(
106106
endpointClass instanceof NegativeType and
107107
forall(EndpointType otherClass | not otherClass instanceof NegativeType |
108108
exists(EndpointCharacteristic characteristic2, float confidence |
109-
characteristic2.getEndpoints(endpoint) and
110-
characteristic2.getImplications(otherClass, false, confidence) and
109+
characteristic2.appliesToEndpoint(endpoint) and
110+
characteristic2.hasImplications(otherClass, false, confidence) and
111111
confidence >= characteristic2.getHighConfidenceThreshold()
112112
)
113113
)
@@ -180,15 +180,15 @@ query predicate reformattedTrainingEndpoints(
180180
// The reason, or reasons, why the endpoint was labeled NotASink for this query, only for negative examples.
181181
key = "notASinkReason" and
182182
exists(EndpointCharacteristic characteristic, EndpointType endpointClass |
183-
characteristic.getEndpoints(endpoint) and
184-
characteristic.getImplications(endpointClass, true, _) and
183+
characteristic.appliesToEndpoint(endpoint) and
184+
characteristic.hasImplications(endpointClass, true, _) and
185185
endpointClass instanceof NegativeType and
186186
value = characteristic
187187
) and
188188
// Don't include a notASinkReason for endpoints that are also known sinks.
189189
not exists(EndpointCharacteristic characteristic3, float confidence3, EndpointType posClass |
190-
characteristic3.getEndpoints(endpoint) and
191-
characteristic3.getImplications(posClass, true, confidence3) and
190+
characteristic3.appliesToEndpoint(endpoint) and
191+
characteristic3.hasImplications(posClass, true, confidence3) and
192192
confidence3 >= characteristic3.getHighConfidenceThreshold() and
193193
not posClass instanceof NegativeType
194194
) and

javascript/ql/experimental/adaptivethreatmodeling/src/NosqlInjectionATM.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import DataFlow::PathGraph
1818
import experimental.adaptivethreatmodeling.NosqlInjectionATM
1919

2020
from AtmConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink, float score
21-
where cfg.getAlerts(source, sink, score)
21+
where cfg.hasBoostedFlowPath(source, sink, score)
2222
select sink.getNode(), source, sink,
2323
"(Experimental) This may be a database query that depends on $@. Identified using machine learning.",
2424
source.getNode(), "a user-provided value", score

javascript/ql/experimental/adaptivethreatmodeling/src/SqlInjectionATM.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import ATM::ResultsInfo
1818
import DataFlow::PathGraph
1919

2020
from AtmConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink, float score
21-
where cfg.getAlerts(source, sink, score)
21+
where cfg.hasBoostedFlowPath(source, sink, score)
2222
select sink.getNode(), source, sink,
2323
"(Experimental) This may be a database query that depends on $@. Identified using machine learning.",
2424
source.getNode(), "a user-provided value", score

javascript/ql/experimental/adaptivethreatmodeling/src/TaintedPathATM.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import DataFlow::PathGraph
2222
import experimental.adaptivethreatmodeling.TaintedPathATM
2323

2424
from AtmConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink, float score
25-
where cfg.getAlerts(source, sink, score)
25+
where cfg.hasBoostedFlowPath(source, sink, score)
2626
select sink.getNode(), source, sink,
2727
"(Experimental) This may be a path that depends on $@. Identified using machine learning.",
2828
source.getNode(), "a user-provided value", score

javascript/ql/experimental/adaptivethreatmodeling/src/XssATM.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import DataFlow::PathGraph
1919
import experimental.adaptivethreatmodeling.XssATM
2020

2121
from AtmConfig cfg, DataFlow::PathNode source, DataFlow::PathNode sink, float score
22-
where cfg.getAlerts(source, sink, score)
22+
where cfg.hasBoostedFlowPath(source, sink, score)
2323
select sink.getNode(), source, sink,
2424
"(Experimental) This may be a cross-site scripting vulnerability due to $@. Identified using machine learning.",
2525
source.getNode(), "a user-provided value", score

javascript/ql/experimental/adaptivethreatmodeling/test/endpoint_large_scale/EndpointFeatures.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ query predicate tokenFeatures(DataFlow::Node endpoint, string featureName, strin
2222
not exists(any(TaintedPathAtm::TaintedPathAtmConfig cfg).getAReasonSinkExcluded(endpoint)) or
2323
not exists(any(XssAtm::DomBasedXssAtmConfig cfg).getAReasonSinkExcluded(endpoint)) or
2424
any(EndpointCharacteristics::IsArgumentToModeledFunctionCharacteristic characteristic)
25-
.getEndpoints(endpoint)
25+
.appliesToEndpoint(endpoint)
2626
) and
2727
EndpointFeatures::tokenFeatures(endpoint, featureName, featureValue)
2828
}

0 commit comments

Comments
 (0)