Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions java/ql/src/Security/CWE/CWE-078/ExecUnescaped.ql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java
import semmle.code.java.security.CommandLineQuery
import semmle.code.java.security.ControlledString
import semmle.code.java.security.ExternalProcess

/**
Expand All @@ -22,13 +23,7 @@ import semmle.code.java.security.ExternalProcess
* has in it.
*/
predicate saneString(Expr expr) {
expr instanceof StringLiteral
or
expr instanceof NullLiteral
or
exists(Variable var | var.getAnAccess() = expr and exists(var.getAnAssignedValue()) |
forall(Expr other | var.getAnAssignedValue() = other | saneString(other))
)
controlledString(expr)
}

predicate builtFromUncontrolledConcat(Expr expr) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: majorAnalysis
---
* The `java/concatenated-command-line` query now uses the shared `controlledString` predicate to identify safe expressions in command-line concatenations, reducing false positives for expressions involving numeric types, enum constants, class names, and other programmer-controlled values.
Loading