Improve check for containment in with statement

This commit is contained in:
Joe Farebrother
2025-09-09 11:26:17 +01:00
parent 0b293eaba5
commit e382f7cd43
2 changed files with 8 additions and 2 deletions

View File

@@ -88,6 +88,12 @@ class WithStatement extends FileClose {
With w;
WithStatement() { this.asExpr() = w.getContextExpr() }
override predicate guardsExceptions(DataFlow::CfgNode fileRaises) {
super.guardsExceptions(fileRaises)
or
w.getBody().contains(fileRaises.asExpr())
}
}
/** Holds if an exception may be raised at `raises` if `file` is a file object. */