|
62 | 62 | * in the given range. The range is inclusive at both ends. |
63 | 63 | * - "ReturnValue": Selects the return value of a call to the selected element. |
64 | 64 | * |
65 | | - * For summaries, `input` and `output` may be prefixed by one of the following, |
66 | | - * separated by the "of" keyword: |
| 65 | + * For summaries, `input` and `output` may be suffixed by any number of the |
| 66 | + * following, separated by ".": |
67 | 67 | * - "Element": Selects an element in a collection. |
68 | 68 | * - "Field[f]": Selects the contents of field `f`. |
69 | 69 | * - "Property[p]": Selects the contents of property `p`. |
@@ -95,6 +95,7 @@ private import internal.DataFlowPublic |
95 | 95 | private import internal.FlowSummaryImpl::Public |
96 | 96 | private import internal.FlowSummaryImpl::Private::External |
97 | 97 | private import internal.FlowSummaryImplSpecific |
| 98 | +private import codeql.mad.ModelValidation as SharedModelVal |
98 | 99 |
|
99 | 100 | /** Holds if a source model exists for the given parameters. */ |
100 | 101 | predicate sourceModel = Extensions::sourceModel/9; |
@@ -204,30 +205,18 @@ module ModelValidation { |
204 | 205 | ) |
205 | 206 | } |
206 | 207 |
|
207 | | - private string getInvalidModelKind() { |
208 | | - exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) | |
209 | | - not kind = ["taint", "value"] and |
210 | | - result = "Invalid kind \"" + kind + "\" in summary model." |
211 | | - ) |
212 | | - or |
213 | | - exists(string kind | sinkModel(_, _, _, _, _, _, _, kind, _) | |
214 | | - not kind = |
215 | | - ["code-injection", "sql-injection", "js-injection", "html-injection", "file-content-store"] and |
216 | | - not kind.matches("encryption-%") and |
217 | | - result = "Invalid kind \"" + kind + "\" in sink model." |
218 | | - ) |
219 | | - or |
220 | | - exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) | |
221 | | - not kind = ["local", "remote", "file", "file-write"] and |
222 | | - result = "Invalid kind \"" + kind + "\" in source model." |
223 | | - ) |
224 | | - or |
225 | | - exists(string kind | neutralModel(_, _, _, _, kind, _) | |
226 | | - not kind = ["summary", "source", "sink"] and |
227 | | - result = "Invalid kind \"" + kind + "\" in neutral model." |
228 | | - ) |
| 208 | + private module KindValConfig implements SharedModelVal::KindValidationConfigSig { |
| 209 | + predicate summaryKind(string kind) { summaryModel(_, _, _, _, _, _, _, _, kind, _) } |
| 210 | + |
| 211 | + predicate sinkKind(string kind) { sinkModel(_, _, _, _, _, _, _, kind, _) } |
| 212 | + |
| 213 | + predicate sourceKind(string kind) { sourceModel(_, _, _, _, _, _, _, kind, _) } |
| 214 | + |
| 215 | + predicate neutralKind(string kind) { neutralModel(_, _, _, _, kind, _) } |
229 | 216 | } |
230 | 217 |
|
| 218 | + private module KindVal = SharedModelVal::KindValidation<KindValConfig>; |
| 219 | + |
231 | 220 | private string getInvalidModelSignature() { |
232 | 221 | exists( |
233 | 222 | string pred, string namespace, string type, string name, string signature, string ext, |
@@ -269,7 +258,7 @@ module ModelValidation { |
269 | 258 | msg = |
270 | 259 | [ |
271 | 260 | getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(), |
272 | | - getInvalidModelKind() |
| 261 | + KindVal::getInvalidModelKind() |
273 | 262 | ] |
274 | 263 | } |
275 | 264 | } |
|
0 commit comments