@@ -93,11 +93,20 @@ private import codeql.mad.ModelValidation as SharedModelVal
93
93
/** Gets the prefix for a group of packages. */
94
94
string groupPrefix ( ) { result = "group:" }
95
95
96
- /** Gets a group that `package` is in, according to `packageGrouping`. */
97
- private string getGroup ( string package ) {
96
+ /**
97
+ * Gets a package represented by `packageOrGroup`.
98
+ *
99
+ * If `packageOrGroup` is of the form `group:<groupname>` then `result` is a
100
+ * package in the group `<groupname>`, as determined by `packageGrouping`.
101
+ * Otherwise, `result` is `packageOrGroup`.
102
+ */
103
+ bindingset [ packageOrGroup]
104
+ private string getPackage ( string packageOrGroup ) {
105
+ not exists ( string s | packageOrGroup = groupPrefix ( ) + s ) and result = packageOrGroup
106
+ or
98
107
exists ( string group |
99
- FlowExtensions:: packageGrouping ( group , package ) and
100
- result = groupPrefix ( ) + group
108
+ FlowExtensions:: packageGrouping ( group , result ) and
109
+ packageOrGroup = groupPrefix ( ) + group
101
110
)
102
111
}
103
112
@@ -110,14 +119,10 @@ predicate sourceModel(
110
119
string package , string type , boolean subtypes , string name , string signature , string ext ,
111
120
string output , string kind , string provenance , QlBuiltins:: ExtensionId madId
112
121
) {
113
- exists ( string p |
114
- FlowExtensions:: sourceModel ( p , type , subtypes , name , signature , ext , output , kind , provenance ,
115
- madId )
116
- |
117
- not exists ( string s | p = groupPrefix ( ) + s ) and package = p
118
- or
119
- // Also look for models that are defined for a group that `package` is part of.
120
- p = getGroup ( package )
122
+ exists ( string packageOrGroup |
123
+ package = getPackage ( packageOrGroup ) and
124
+ FlowExtensions:: sourceModel ( packageOrGroup , type , subtypes , name , signature , ext , output , kind ,
125
+ provenance , madId )
121
126
)
122
127
}
123
128
@@ -130,14 +135,9 @@ predicate sinkModel(
130
135
string package , string type , boolean subtypes , string name , string signature , string ext ,
131
136
string input , string kind , string provenance , QlBuiltins:: ExtensionId madId
132
137
) {
133
- exists ( string p |
134
- FlowExtensions:: sinkModel ( p , type , subtypes , name , signature , ext , input , kind , provenance ,
135
- madId )
136
- |
137
- not exists ( string s | p = groupPrefix ( ) + s ) and package = p
138
- or
139
- // Also look for models that are defined for a group that `package` is part of.
140
- p = getGroup ( package )
138
+ exists ( string packageOrGroup | package = getPackage ( packageOrGroup ) |
139
+ FlowExtensions:: sinkModel ( packageOrGroup , type , subtypes , name , signature , ext , input , kind ,
140
+ provenance , madId )
141
141
)
142
142
}
143
143
@@ -150,14 +150,9 @@ predicate summaryModel(
150
150
string package , string type , boolean subtypes , string name , string signature , string ext ,
151
151
string input , string output , string kind , string provenance , QlBuiltins:: ExtensionId madId
152
152
) {
153
- exists ( string p |
154
- FlowExtensions:: summaryModel ( p , type , subtypes , name , signature , ext , input , output , kind ,
155
- provenance , madId )
156
- |
157
- not exists ( string s | p = groupPrefix ( ) + s ) and package = p
158
- or
159
- // Also look for models that are defined for a group that `package` is part of.
160
- p = getGroup ( package )
153
+ exists ( string packageOrGroup | package = getPackage ( packageOrGroup ) |
154
+ FlowExtensions:: summaryModel ( packageOrGroup , type , subtypes , name , signature , ext , input ,
155
+ output , kind , provenance , madId )
161
156
)
162
157
}
163
158
@@ -169,11 +164,8 @@ predicate summaryModel(
169
164
predicate neutralModel (
170
165
string package , string type , string name , string signature , string kind , string provenance
171
166
) {
172
- exists ( string p | FlowExtensions:: neutralModel ( p , type , name , signature , kind , provenance ) |
173
- not exists ( string s | p = groupPrefix ( ) + s ) and package = p
174
- or
175
- // Also look for models that are defined for a group that `package` is part of.
176
- p = getGroup ( package )
167
+ exists ( string packageOrGroup | package = getPackage ( packageOrGroup ) |
168
+ FlowExtensions:: neutralModel ( packageOrGroup , type , name , signature , kind , provenance )
177
169
)
178
170
}
179
171
0 commit comments