@@ -87,6 +87,7 @@ private import internal.FlowSummaryImplSpecific as FlowSummaryImplSpecific
8787private import internal.AccessPathSyntax
8888private import ExternalFlowExtensions as Extensions
8989private import FlowSummary
90+ private import codeql.mad.ModelValidation as SharedModelVal
9091
9192/**
9293 * A class for activating additional model rows.
@@ -265,87 +266,18 @@ module ModelValidation {
265266 )
266267 }
267268
268- private class OutdatedSinkKind extends string {
269- OutdatedSinkKind ( ) {
270- this =
271- [
272- "sql" , "url-redirect" , "xpath" , "ssti" , "logging" , "groovy" , "jexl" , "mvel" , "xslt" ,
273- "ldap" , "pending-intent-sent" , "intent-start" , "set-hostname-verifier" ,
274- "header-splitting" , "xss" , "write-file" , "create-file" , "read-file" , "open-url" ,
275- "jdbc-url"
276- ]
277- }
278-
279- private string replacementKind ( ) {
280- this = [ "sql" , "xpath" , "groovy" , "jexl" , "mvel" , "xslt" , "ldap" ] and
281- result = this + "-injection"
282- or
283- this = "url-redirect" and result = "url-redirection"
284- or
285- this = "ssti" and result = "template-injection"
286- or
287- this = "logging" and result = "log-injection"
288- or
289- this = "pending-intent-sent" and result = "pending-intents"
290- or
291- this = "intent-start" and result = "intent-redirection"
292- or
293- this = "set-hostname-verifier" and result = "hostname-verification"
294- or
295- this = "header-splitting" and result = "response-splitting"
296- or
297- this = "xss" and result = "html-injection\" or \"js-injection"
298- or
299- this = "write-file" and result = "file-content-store"
300- or
301- this = [ "create-file" , "read-file" ] and result = "path-injection"
302- or
303- this = [ "open-url" , "jdbc-url" ] and result = "request-forgery"
304- }
269+ private module KindValConfig implements SharedModelVal:: KindValidationConfigSig {
270+ predicate summaryKind ( string kind ) { summaryModel ( _, _, _, _, _, _, _, _, kind , _) }
305271
306- string outdatedMessage ( ) {
307- result =
308- "The kind \"" + this + "\" is outdated. Use \"" + this .replacementKind ( ) + "\" instead."
309- }
310- }
272+ predicate sinkKind ( string kind ) { sinkModel ( _, _, _, _, _, _, _, kind , _) }
311273
312- private string getInvalidModelKind ( ) {
313- exists ( string kind | summaryModel ( _, _, _, _, _, _, _, _, kind , _) |
314- not kind = [ "taint" , "value" ] and
315- result = "Invalid kind \"" + kind + "\" in summary model."
316- )
317- or
318- exists ( string kind , string msg | sinkModel ( _, _, _, _, _, _, _, kind , _) |
319- not kind =
320- [
321- "request-forgery" , "jndi-injection" , "ldap-injection" , "sql-injection" , "log-injection" ,
322- "mvel-injection" , "xpath-injection" , "groovy-injection" , "html-injection" , "js-injection" ,
323- "ognl-injection" , "intent-redirection" , "pending-intents" , "url-redirection" ,
324- "path-injection" , "file-content-store" , "hostname-verification" , "response-splitting" ,
325- "information-leak" , "xslt-injection" , "jexl-injection" , "bean-validation" ,
326- "template-injection" , "fragment-injection" , "command-injection"
327- ] and
328- not kind .matches ( "regex-use%" ) and
329- not kind .matches ( "qltest%" ) and
330- msg = "Invalid kind \"" + kind + "\" in sink model." and
331- // The part of this message that refers to outdated sink kinds can be deleted after June 1st, 2024.
332- if kind instanceof OutdatedSinkKind
333- then result = msg + " " + kind .( OutdatedSinkKind ) .outdatedMessage ( )
334- else result = msg
335- )
336- or
337- exists ( string kind | sourceModel ( _, _, _, _, _, _, _, kind , _) |
338- not kind = [ "remote" , "contentprovider" , "android-external-storage-dir" ] and
339- not kind .matches ( "qltest%" ) and
340- result = "Invalid kind \"" + kind + "\" in source model."
341- )
342- or
343- exists ( string kind | neutralModel ( _, _, _, _, kind , _) |
344- not kind = [ "summary" , "source" , "sink" ] and
345- result = "Invalid kind \"" + kind + "\" in neutral model."
346- )
274+ predicate sourceKind ( string kind ) { sourceModel ( _, _, _, _, _, _, _, kind , _) }
275+
276+ predicate neutralKind ( string kind ) { neutralModel ( _, _, _, _, kind , _) }
347277 }
348278
279+ private module KindVal = SharedModelVal:: KindValidation< KindValConfig > ;
280+
349281 private string getInvalidModelSignature ( ) {
350282 exists (
351283 string pred , string package , string type , string name , string signature , string ext ,
@@ -387,7 +319,7 @@ module ModelValidation {
387319 msg =
388320 [
389321 getInvalidModelSignature ( ) , getInvalidModelInput ( ) , getInvalidModelOutput ( ) ,
390- getInvalidModelKind ( )
322+ KindVal :: getInvalidModelKind ( )
391323 ]
392324 }
393325}
0 commit comments