@@ -28,29 +28,51 @@ extensible predicate threatModelConfiguration(string kind, boolean enable, int p
2828 */
2929extensible private predicate threatModelGrouping ( string kind , string group ) ;
3030
31+ /** Holds if the specified threat model kind is mentioned in either the configuration or grouping table. */
32+ private predicate knownThreatModel ( string kind ) {
33+ threatModelConfiguration ( kind , _, _) or
34+ threatModelGrouping ( kind , _) or
35+ threatModelGrouping ( _, kind ) or
36+ kind = "all"
37+ }
38+
3139/**
3240 * Gets the threat model group that directly contains the specified threat model.
3341 */
3442private string getParentThreatModel ( string child ) {
3543 threatModelGrouping ( child , result )
44+ or
45+ knownThreatModel ( child ) and child != "all" and result = "all"
3646}
3747
3848/**
39- * Holds if the source model kind `kind` is relevant for generic queries
40- * under the current threat model configuration .
49+ * Gets the `enabled` column of the highest-priority configuration row whose `kind` column includes
50+ * the specified threat model kind .
4151 */
42- bindingset [ kind]
43- predicate currentThreatModel ( string kind ) {
52+ private boolean threatModelExplicitState ( string kind ) {
4453 // Find the highest-oriority configuration row whose `kind` column includes the specified threat
4554 // model kind. If such a row exists and its `enabled` column is `true`, then the threat model is
4655 // enabled.
47- max ( boolean enabled , int priority |
48- exists ( string configuredKind |
49- configuredKind = getParentThreatModel * ( kind ) or configuredKind = "all"
56+ ( knownThreatModel ( kind ) or kind = "<other>" ) and
57+ result =
58+ max ( boolean enabled , int priority |
59+ exists ( string configuredKind | configuredKind = getParentThreatModel * ( kind ) |
60+ threatModelConfiguration ( configuredKind , enabled , priority )
61+ )
5062 |
51- threatModelConfiguration ( configuredKind , enabled , priority )
63+ enabled order by priority
5264 )
53- |
54- enabled order by priority
55- ) = true
65+ }
66+
67+ /**
68+ * Holds if the source model kind `kind` is relevant for generic queries
69+ * under the current threat model configuration.
70+ */
71+ bindingset [ kind]
72+ predicate currentThreatModel ( string kind ) {
73+ knownThreatModel ( kind ) and threatModelExplicitState ( kind ) = true
74+ or
75+ // For any threat model kind not mentioned in the configuration or grouping tables, its state of
76+ // enablement is controlled only by the entries that specifiy the "all" kind.
77+ not knownThreatModel ( kind ) and threatModelExplicitState ( "all" ) = true
5678}
0 commit comments