consider quoted string concatenations as sanitizers for js/shell-command-injection-from-environment

This commit is contained in:
Erik Krogh Kristensen
2021-03-25 10:17:30 +01:00
parent 801eb538db
commit 3d49b8cb91
3 changed files with 14 additions and 0 deletions

View File

@@ -55,4 +55,14 @@ module ShellCommandInjectionFromEnvironment {
class ShellCommandSink extends Sink, DataFlow::ValueNode {
ShellCommandSink() { any(SystemCommandExecution sys).isShellInterpreted(this) }
}
/**
* A string-concatenation leaf that is sorounded by quotes, seen as a sanitizer for command-injection.
*/
class QuotingConcatSanitizer extends Sanitizer, StringOps::ConcatenationLeaf {
QuotingConcatSanitizer() {
this.getNextLeaf().getStringValue().regexpMatch("(\"|').*") and
this.getPreviousLeaf().getStringValue().regexpMatch(".*(\"|')")
}
}
}