Swift: Use a barrier as a simple fix.

This commit is contained in:
Geoffrey White
2024-08-01 15:58:43 +01:00
parent 7bf61d1d7e
commit 2b7b1c624d
3 changed files with 9 additions and 21 deletions

View File

@@ -64,5 +64,12 @@ private class CommandInjectionDefaultBarrier extends CommandInjectionBarrier {
CommandInjectionDefaultBarrier() {
// any numeric type
this.asExpr().getType().getUnderlyingType().getABaseType*().getName() = "Numeric"
or
// we get poor results when the tainted data is a directory list, such as
// the result of `FileMananger.contentsOfDirectory` and similar functions.
exists(CallExpr ce |
ce.getStaticTarget().getName().matches(["%directory%", "%Directory%"]) and
this.asExpr() = ce
)
}
}