Skip to content

Commit dbcdc22

Browse files
committed
Use names constants for confidence levels
1 parent b6532fa commit dbcdc22

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ abstract class AtmConfig extends string {
5050
// known sink for the class.
5151
exists(EndpointCharacteristic characteristic |
5252
characteristic.getEndpoints(sink) and
53-
characteristic.getImplications(this.getASinkEndpointType(), true, 1.0)
53+
characteristic
54+
.getImplications(this.getASinkEndpointType(), true, characteristic.maximalConfidence())
5455
)
5556
}
5657

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ abstract class EndpointCharacteristic extends string {
4444
abstract predicate getImplications(
4545
EndpointType endpointClass, boolean isPositiveIndicator, float confidence
4646
);
47+
48+
// The following are some confidence values that are used in practice by the subclasses. They are defined as named
49+
// constants here to make it easier to change them in the future.
50+
final float maximalConfidence() { result = 1.0 }
51+
52+
final float highConfidence() { result = 0.9 }
53+
54+
final float mediumConfidence() { result = 0.6 }
4755
}
4856

4957
/*
@@ -63,7 +71,9 @@ private class DomBasedXssSinkCharacteristic extends EndpointCharacteristic {
6371
override predicate getImplications(
6472
EndpointType endpointClass, boolean isPositiveIndicator, float confidence
6573
) {
66-
endpointClass instanceof XssSinkType and isPositiveIndicator = true and confidence = 1.0
74+
endpointClass instanceof XssSinkType and
75+
isPositiveIndicator = true and
76+
confidence = maximalConfidence()
6777
}
6878
}
6979

@@ -79,7 +89,9 @@ private class TaintedPathSinkCharacteristic extends EndpointCharacteristic {
7989
override predicate getImplications(
8090
EndpointType endpointClass, boolean isPositiveIndicator, float confidence
8191
) {
82-
endpointClass instanceof TaintedPathSinkType and isPositiveIndicator = true and confidence = 1.0
92+
endpointClass instanceof TaintedPathSinkType and
93+
isPositiveIndicator = true and
94+
confidence = maximalConfidence()
8395
}
8496
}
8597

@@ -97,7 +109,7 @@ private class SqlInjectionSinkCharacteristic extends EndpointCharacteristic {
97109
) {
98110
endpointClass instanceof SqlInjectionSinkType and
99111
isPositiveIndicator = true and
100-
confidence = 1.0
112+
confidence = maximalConfidence()
101113
}
102114
}
103115

@@ -115,7 +127,7 @@ private class NosqlInjectionSinkCharacteristic extends EndpointCharacteristic {
115127
) {
116128
endpointClass instanceof NosqlInjectionSinkType and
117129
isPositiveIndicator = true and
118-
confidence = 1.0
130+
confidence = maximalConfidence()
119131
}
120132
}
121133

@@ -151,7 +163,9 @@ abstract private class NotASinkCharacteristic extends OtherModeledArgumentCharac
151163
override predicate getImplications(
152164
EndpointType endpointClass, boolean isPositiveIndicator, float confidence
153165
) {
154-
endpointClass instanceof NegativeType and isPositiveIndicator = true and confidence = 0.9
166+
endpointClass instanceof NegativeType and
167+
isPositiveIndicator = true and
168+
confidence = highConfidence()
155169
}
156170
}
157171

@@ -168,7 +182,9 @@ abstract class LikelyNotASinkCharacteristic extends OtherModeledArgumentCharacte
168182
override predicate getImplications(
169183
EndpointType endpointClass, boolean isPositiveIndicator, float confidence
170184
) {
171-
endpointClass instanceof NegativeType and isPositiveIndicator = true and confidence = 0.6
185+
endpointClass instanceof NegativeType and
186+
isPositiveIndicator = true and
187+
confidence = mediumConfidence()
172188
}
173189
}
174190

0 commit comments

Comments
 (0)