Files
codeql/javascript/ql/test/library-tests/Extend/ExtendCalls.ql
2023-05-03 15:31:00 +02:00

28 lines
722 B
Plaintext

import javascript
class Assertion extends CallExpr {
Assertion() {
this.getCalleeName() = "checkDeep" or
this.getCalleeName() = "checkShallow"
}
predicate shouldBeDeep() { this.getCalleeName() = "checkDeep" }
ExtendCall getExtendCall() { result = this.getArgument(0).flow() }
string getMessage() {
if not exists(this.getExtendCall())
then result = "Not an extend call"
else
if this.shouldBeDeep() and not this.getExtendCall().isDeep()
then result = "Not deep"
else
if not this.shouldBeDeep() and this.getExtendCall().isDeep()
then result = "Not shallow"
else result = "OK"
}
}
from Assertion assertion
select assertion, assertion.getMessage()