Skip to content

Commit 7c2bfef

Browse files
esbenaStephan Brandauer
authored andcommitted
add CompareFeatures.ql
1 parent 41b35ea commit 7c2bfef

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import experimental.adaptivethreatmodeling.TaintedPathATM
2+
import experimental.adaptivethreatmodeling.EndpointFeatures
3+
import experimental.adaptivethreatmodeling.EndpointScoring
4+
5+
string getValueOrNone(EndpointFeature feature, DataFlow::Node endpoint) {
6+
if exists(feature.getValue(endpoint)) then feature.getValue(endpoint) = result else isNone(result)
7+
}
8+
9+
predicate isNone(string value) { value = "" }
10+
11+
// query for comparing feature values
12+
from
13+
DataFlow::Node endpoint, EndpointFeature feature1, EndpointFeature feature2, string featureValue1,
14+
string featureValue2
15+
where
16+
feature1 instanceof ArgumentIndexFromArgumentTraversal and
17+
feature2 instanceof ArgumentIndex and
18+
featureValue1 = getValueOrNone(feature1, endpoint) and
19+
featureValue2 = getValueOrNone(feature2, endpoint) and
20+
featureValue1 != featureValue2 and
21+
isNone([featureValue1, featureValue2])
22+
select endpoint, endpoint.getFile().getBaseName() as file, endpoint.getStartLine() as line,
23+
featureValue1, featureValue2

0 commit comments

Comments
 (0)