Skip to content

Commit d4b2c01

Browse files
committed
Lift out intermediate helper predicate.
1 parent 201f64e commit d4b2c01

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.ql

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@ abstract class SystemData extends Element {
3333
result = getAnExpr() or
3434

3535
// flow via global or member variable (conservative approximation)
36-
exists(Variable var |
37-
(
38-
var.getAnAssignedValue() = getAnExprIndirect() or
39-
var.getAnAccess() = getAnExprIndirect()
40-
) and
41-
result = var.getAnAccess() and
42-
not var instanceof LocalScopeVariable
43-
) or
36+
result = getAnAffectedVar().getAnAccess() or
4437

4538
// flow via stack variable
4639
definitionUsePair(_, getAnExprIndirect(), result) or
@@ -50,6 +43,17 @@ abstract class SystemData extends Element {
5043
// flow from assigned value to assignment expression
5144
result.(AssignExpr).getRValue() = getAnExprIndirect()
5245
}
46+
47+
/** Gets a global or member variable that may be affected by this system
48+
* data (conservative approximation).
49+
*/
50+
private Variable getAnAffectedVar() {
51+
(
52+
result.getAnAssignedValue() = this.getAnExprIndirect() or
53+
result.getAnAccess() = this.getAnExprIndirect()
54+
) and
55+
not result instanceof LocalScopeVariable
56+
}
5357
}
5458

5559
/**

0 commit comments

Comments
 (0)