mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
28 lines
677 B
Plaintext
28 lines
677 B
Plaintext
import javascript
|
|
|
|
class Assertion extends CallExpr {
|
|
Assertion() {
|
|
getCalleeName() = "checkDeep" or
|
|
getCalleeName() = "checkShallow"
|
|
}
|
|
|
|
predicate shouldBeDeep() { getCalleeName() = "checkDeep" }
|
|
|
|
ExtendCall getExtendCall() { result = getArgument(0).flow() }
|
|
|
|
string getMessage() {
|
|
if not exists(getExtendCall())
|
|
then result = "Not an extend call"
|
|
else
|
|
if shouldBeDeep() and not getExtendCall().isDeep()
|
|
then result = "Not deep"
|
|
else
|
|
if not shouldBeDeep() and getExtendCall().isDeep()
|
|
then result = "Not shallow"
|
|
else result = "OK"
|
|
}
|
|
}
|
|
|
|
from Assertion assertion
|
|
select assertion, assertion.getMessage()
|