Skip to content

Commit 13741ba

Browse files
authored
Update FindWrapperFunctions.ql
1 parent 18de9f0 commit 13741ba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @problem.severity warning
77
* @precision medium
88
* @tags correctness
9+
* maintainability
910
* security
1011
* external/cwe/cwe-1041
1112
*/
@@ -48,7 +49,7 @@ predicate conditionsOutsideWrapper(FunctionCall fcp) {
4849
not exists(ExprCall ectmp | fcp = ectmp.getAnArgument().getAChild*())
4950
}
5051

51-
/** Holds if the conditions for a call within the wrapper function are met. */
52+
/** Held if the conditions for calling `fcp` inside the `fnp` wrapper function are met. */
5253
pragma[inline]
5354
predicate conditionsInsideWrapper(FunctionCall fcp, Function fnp) {
5455
not exists(FunctionCall fctmp2 |
@@ -60,7 +61,7 @@ predicate conditionsInsideWrapper(FunctionCall fcp, Function fnp) {
6061
fnp.getNumberOfParameters() > 0 and
6162
// the call arguments must be passed through the arguments of the wrapper function
6263
forall(int i | i in [0 .. fcp.getNumberOfArguments() - 1] |
63-
fcp.getArgument(i).(VariableAccess).getTarget() = fnp.getAParameter().getAnAccess().getTarget()
64+
globalValueNumber(fcp.getArgument(i)) = globalValueNumber(fnp.getAParameter().getAnAccess())
6465
) and
6566
// there should be no more than one required call inside the wrapper function
6667
not exists(FunctionCall fctmp |
@@ -119,8 +120,8 @@ predicate conditionsForWrapper(FunctionCall fcp, Function fnp) {
119120
forall(int i | i in [0 .. fnp.getNumberOfParameters() - 1] |
120121
fnp.getParameter(i).getAnAccess().getTarget() =
121122
fcp.getAnArgument().(VariableAccess).getTarget() or
122-
fnp.getParameter(i).getType() instanceof Class or
123-
fnp.getParameter(i).getType().(ReferenceType).getBaseType() instanceof Class or
123+
fnp.getParameter(i).getUnspecifiedType() instanceof Class or
124+
fnp.getParameter(i).getUnspecifiedType().(ReferenceType).getBaseType() instanceof Class or
124125
fnp.getParameter(i).getAnAccess().getTarget() =
125126
fctmp.getAnArgument().(VariableAccess).getTarget()
126127
)

0 commit comments

Comments
 (0)