Remove guardEnsuresEqUnordered and update tests

GuardCondition::ensuresEq is sufficient.
Update test-cases and expected results + removed a QL warning
This commit is contained in:
Nikita Kraiouchkine
2023-04-17 18:19:52 +02:00
parent bb14df1e4e
commit 1c70a42041
23 changed files with 21 additions and 227 deletions

View File

@@ -58,17 +58,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -78,7 +67,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}

View File

@@ -53,17 +53,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -73,7 +62,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}

View File

@@ -53,17 +53,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -73,7 +62,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}

View File

@@ -22,17 +22,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.

View File

@@ -24,17 +24,6 @@ class TypeValidationCall extends FunctionCall {
TypeValidationCall() { this.getTarget().hasName("DYN_INPUT_TYPE") }
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.

View File

@@ -24,17 +24,6 @@ class TypeValidationCall extends FunctionCall {
TypeValidationCall() { this.getTarget().hasName("DYN_INPUT_TYPE") }
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -44,7 +33,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}

View File

@@ -24,17 +24,6 @@ class TypeValidationCall extends FunctionCall {
TypeValidationCall() { this.getTarget().hasName("DYN_INPUT_TYPE") }
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -44,7 +33,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}
@@ -80,8 +69,7 @@ module InputTypesToTypeValidationConfig implements DataFlow::ConfigSig {
class EntrypointFunction extends Function {
EntrypointFunction() { this.hasName(["EP_copy_mem", "EP_print_val", "EP_write_val_to_mem"]) }
Parameter getInputParameter() { result = this.getParameter(0) }
// Parameter getInputParameter() { result = this.getParameter(0) }
Parameter getInputTypesParameter() { result = this.getParameter(1) }
}

View File

@@ -37,17 +37,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -57,7 +46,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}
@@ -94,8 +83,7 @@ module InputTypesToTypeValidationConfig implements DataFlow::ConfigSig {
class EntrypointFunction extends Function {
EntrypointFunction() { this.hasName(["EP_copy_mem", "EP_print_val", "EP_write_val_to_mem"]) }
Parameter getInputParameter() { result = this.getParameter(0) }
// Parameter getInputParameter() { result = this.getParameter(0) }
Parameter getInputTypesParameter() { result = this.getParameter(1) }
}

View File

@@ -53,17 +53,6 @@ class TypeValidationCall extends FunctionCall {
}
}
/**
* Holds if `op1` and `op2` are checked for equality in any order
* with no distinction between left and right operands of the equality check
*/
predicate guardEnsuresEqUnordered(
Expr op1, Expr op2, GuardCondition guard, BasicBlock block, boolean areEqual
) {
guard.ensuresEq(op1, op2, 0, block, areEqual) or
guard.ensuresEq(op2, op1, 0, block, areEqual)
}
/**
* Relates a `call` to a `guard`, which uses the result of the call to validate
* equality of the result of `call` against `other` to guard `block`.
@@ -73,7 +62,7 @@ predicate typeValidationGuard(
) {
exists(Expr dest |
DataFlow::localExprFlow(call, dest) and
guardEnsuresEqUnordered(dest, other, guard, block, true) and
guard.ensuresEq(dest, other, 0, block, true) and
InputTypesToTypeValidation::hasFlowToExpr(other)
)
}