5
5
import go
6
6
7
7
module InsecureFeatureFlag {
8
+ /**
9
+ * Holds if `name` may be the name of a feature flag that controls a security feature.
10
+ */
11
+ bindingset [ name]
12
+ predicate isSecurityFlagName ( string name ) { name .regexpMatch ( "(?i).*(secure|(en|dis)able).*" ) }
13
+
8
14
/**
9
15
* Holds if `name` may be the name of a feature flag that controls whether certificate checking is
10
16
* enabled.
11
17
*/
12
18
bindingset [ name]
13
- predicate isFeatureFlagName ( string name ) {
14
- name .regexpMatch ( "(?i).*(secure| selfCert|selfSign|validat|verif|trust|(en|dis)able ).*" )
19
+ predicate isCertificateFlagName ( string name ) {
20
+ name .regexpMatch ( "(?i).*(selfCert|selfSign|validat|verif|trust).*" )
15
21
}
16
22
17
23
/**
18
- * Holds if `name` suggests an old or legacy version.
24
+ * Holds if `name` suggests an old or legacy version of TLS .
19
25
*
20
26
* We accept 'intermediate' because it appears to be common for TLS users
21
27
* to define three profiles: modern, intermediate, legacy/old, perhaps based
22
28
* on https://wiki.mozilla.org/Security/Server_Side_TLS (though note the
23
29
* 'intermediate' used there would now pass muster according to this query)
24
30
*/
25
31
bindingset [ name]
26
- predicate isLegacyFlagName ( string name ) { name .regexpMatch ( "(?i).*(old|intermediate|legacy).*" ) }
32
+ predicate isLegacyTlsFlagName ( string name ) {
33
+ name .regexpMatch ( "(?i).*(old|intermediate|legacy).*" )
34
+ }
27
35
28
36
/**
29
37
* A kind of flag that may indicate security expectations regarding the code it guards.
30
38
*/
31
39
abstract class FlagKind extends string {
32
- FlagKind ( ) { this = "feature" or this = "legacy" }
40
+ FlagKind ( ) {
41
+ this = "securityFeature" or this = "legacyTlsVersion" or this = "insecureCertificate"
42
+ }
33
43
34
44
/**
35
45
* Returns a flag name of this type.
@@ -40,32 +50,47 @@ module InsecureFeatureFlag {
40
50
/**
41
51
* Flags suggesting an optional feature, perhaps deliberately insecure.
42
52
*/
43
- class FeatureFlag extends FlagKind {
44
- FeatureFlag ( ) { this = "feature " }
53
+ class SecurityFeatureFlag extends FlagKind {
54
+ SecurityFeatureFlag ( ) { this = "securityFeature " }
45
55
46
56
bindingset [ result ]
47
- override string getAFlagName ( ) { isFeatureFlagName ( result ) }
57
+ override string getAFlagName ( ) { isSecurityFlagName ( result ) }
48
58
}
49
59
50
60
/**
51
61
* Flags suggesting an optional feature, perhaps deliberately insecure.
52
62
*/
53
- string featureFlag ( ) { result = "feature " }
63
+ string securityFeatureFlag ( ) { result = "securityFeature " }
54
64
55
65
/**
56
- * Flags suggesting support for an old or legacy feature .
66
+ * Flags suggesting support for an old or legacy TLS version .
57
67
*/
58
- class LegacyFlag extends FlagKind {
59
- LegacyFlag ( ) { this = "legacy " }
68
+ class LegacyTlsVersionFlag extends FlagKind {
69
+ LegacyTlsVersionFlag ( ) { this = "legacyTlsVersion " }
60
70
61
71
bindingset [ result ]
62
- override string getAFlagName ( ) { isLegacyFlagName ( result ) }
72
+ override string getAFlagName ( ) { isLegacyTlsFlagName ( result ) }
73
+ }
74
+
75
+ /**
76
+ * Flags suggesting support for an old or legacy TLS version.
77
+ */
78
+ string legacyTlsVersionFlag ( ) { result = "legacyTlsVersion" }
79
+
80
+ /**
81
+ * Flags suggesting a deliberately insecure certificate setup.
82
+ */
83
+ class InsecureCertificateFlag extends FlagKind {
84
+ InsecureCertificateFlag ( ) { this = "insecureCertificate" }
85
+
86
+ bindingset [ result ]
87
+ override string getAFlagName ( ) { isCertificateFlagName ( result ) }
63
88
}
64
89
65
90
/**
66
91
* Flags suggesting support for an old or legacy feature.
67
92
*/
68
- string legacyFlag ( ) { result = "legacy " }
93
+ string insecureCertificateFlag ( ) { result = "insecureCertificate " }
69
94
70
95
/** Gets a global value number representing a (likely) security flag. */
71
96
GVN getAFlag ( FlagKind flagKind ) {
@@ -149,16 +174,23 @@ module InsecureFeatureFlag {
149
174
}
150
175
151
176
/**
152
- * Gets a control-flow node that represents a (likely) feature-flag check for certificate checking.
177
+ * Gets a control-flow node that represents a (likely) security feature-flag check
178
+ */
179
+ ControlFlow:: ConditionGuardNode getASecurityFeatureFlagCheck ( ) {
180
+ result .ensures ( getAFlag ( securityFeatureFlag ( ) ) .getANode ( ) , _)
181
+ }
182
+
183
+ /**
184
+ * Gets a control-flow node that represents a (likely) flag controlling TLS version selection.
153
185
*/
154
- ControlFlow:: ConditionGuardNode getAFeatureFlagCheck ( ) {
155
- result .ensures ( getAFlag ( featureFlag ( ) ) .getANode ( ) , _)
186
+ ControlFlow:: ConditionGuardNode getALegacyTlsVersionCheck ( ) {
187
+ result .ensures ( getAFlag ( legacyTlsVersionFlag ( ) ) .getANode ( ) , _)
156
188
}
157
189
158
190
/**
159
- * Gets a control-flow node that represents a (likely) feature- flag check for certificate checking .
191
+ * Gets a control-flow node that represents a (likely) flag controlling an insecure certificate setup .
160
192
*/
161
- ControlFlow:: ConditionGuardNode getALegacyVersionCheck ( ) {
162
- result .ensures ( getAFlag ( legacyFlag ( ) ) .getANode ( ) , _)
193
+ ControlFlow:: ConditionGuardNode getAnInsecureCertificateCheck ( ) {
194
+ result .ensures ( getAFlag ( insecureCertificateFlag ( ) ) .getANode ( ) , _)
163
195
}
164
196
}
0 commit comments