Skip to content

Commit e24e3a6

Browse files
Jami CogswellJami Cogswell
authored andcommitted
JS/Python/Ruby: add getInvalidModelKind as experiment
1 parent 93215ba commit e24e3a6

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,23 @@ module ModelOutput {
654654
import Cached
655655
import Specific::ModelOutputSpecific
656656

657+
private string getInvalidModelKind() {
658+
exists(string kind | sinkModel(_, _, kind) |
659+
not kind =
660+
[
661+
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
662+
"mvel-injection", "xpath-injection", "groovy-injection", "html-injection", "js-injection",
663+
"ognl-injection", "intent-redirection", "pending-intents", "url-redirection",
664+
"path-injection", "file-content-store", "hostname-verification", "response-splitting",
665+
"information-leak", "xslt-injection", "jexl-injection", "bean-validation",
666+
"template-injection", "fragment-injection", "command-injection"
667+
] and
668+
not kind.matches("credentials-%") and
669+
not kind.matches("test-%") and
670+
result = "Invalid kind \"" + kind + "\" in sink model."
671+
)
672+
}
673+
657674
/**
658675
* Gets an error message relating to an invalid CSV row in a model.
659676
*/
@@ -698,5 +715,8 @@ module ModelOutput {
698715
not isValidNoArgumentTokenInIdentifyingAccessPath(token.getName()) and
699716
result = "Invalid token '" + token + "' is missing its arguments, in access path: " + path
700717
)
718+
or
719+
// Check for valid model kinds
720+
result = getInvalidModelKind()
701721
}
702722
}

python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,23 @@ module ModelOutput {
654654
import Cached
655655
import Specific::ModelOutputSpecific
656656

657+
private string getInvalidModelKind() {
658+
exists(string kind | sinkModel(_, _, kind) |
659+
not kind =
660+
[
661+
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
662+
"mvel-injection", "xpath-injection", "groovy-injection", "html-injection", "js-injection",
663+
"ognl-injection", "intent-redirection", "pending-intents", "url-redirection",
664+
"path-injection", "file-content-store", "hostname-verification", "response-splitting",
665+
"information-leak", "xslt-injection", "jexl-injection", "bean-validation",
666+
"template-injection", "fragment-injection", "command-injection"
667+
] and
668+
not kind.matches("credentials-%") and
669+
not kind.matches("test-%") and
670+
result = "Invalid kind \"" + kind + "\" in sink model."
671+
)
672+
}
673+
657674
/**
658675
* Gets an error message relating to an invalid CSV row in a model.
659676
*/
@@ -698,5 +715,8 @@ module ModelOutput {
698715
not isValidNoArgumentTokenInIdentifyingAccessPath(token.getName()) and
699716
result = "Invalid token '" + token + "' is missing its arguments, in access path: " + path
700717
)
718+
or
719+
// Check for valid model kinds
720+
result = getInvalidModelKind()
701721
}
702722
}

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,23 @@ module ModelOutput {
654654
import Cached
655655
import Specific::ModelOutputSpecific
656656

657+
private string getInvalidModelKind() {
658+
exists(string kind | sinkModel(_, _, kind) |
659+
not kind =
660+
[
661+
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
662+
"mvel-injection", "xpath-injection", "groovy-injection", "html-injection", "js-injection",
663+
"ognl-injection", "intent-redirection", "pending-intents", "url-redirection",
664+
"path-injection", "file-content-store", "hostname-verification", "response-splitting",
665+
"information-leak", "xslt-injection", "jexl-injection", "bean-validation",
666+
"template-injection", "fragment-injection", "command-injection"
667+
] and
668+
not kind.matches("credentials-%") and
669+
not kind.matches("test-%") and
670+
result = "Invalid kind \"" + kind + "\" in sink model."
671+
)
672+
}
673+
657674
/**
658675
* Gets an error message relating to an invalid CSV row in a model.
659676
*/
@@ -698,5 +715,8 @@ module ModelOutput {
698715
not isValidNoArgumentTokenInIdentifyingAccessPath(token.getName()) and
699716
result = "Invalid token '" + token + "' is missing its arguments, in access path: " + path
700717
)
718+
or
719+
// Check for valid model kinds
720+
result = getInvalidModelKind()
701721
}
702722
}

0 commit comments

Comments
 (0)