New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPP: Make more alert-messages follow the style guide #10507
Conversation
| from LocalVariable v, Function f | ||
| where | ||
| f = v.getFunction() and | ||
| not exists(v.getAnAccess()) and | ||
| not v.isConst() and // workaround for folded constants | ||
| not exists(DeclStmt ds | ds.getADeclaration() = v and ds.isInMacroExpansion()) and // variable declared in a macro expansion | ||
| not declarationHasSideEffects(v) and | ||
| not exists(AsmStmt s | f = s.getEnclosingFunction()) and | ||
| not v.getAnAttribute().getName() = "unused" and | ||
| not any(ErrorExpr e).getEnclosingFunction() = f // unextracted expr may use `v` | ||
| select v, "Variable " + v.getName() + " is not used" | ||
| select v, "Variable " + v.getName() + " is not used." |
Check warning
Code scanning / CodeQL
Consistent alert message Warning
cpp/ql/src/experimental/Security/CWE/CWE-787/UnsignedToSignedPointerArith.ql
Fixed
Show fixed
Hide fixed
d3f6148
to
045bd00
Compare
| from Expr origin, Expr e, string effect, PathNode sourceNode, PathNode sinkNode, Operation op | ||
| where | ||
| taintedWithPath(origin, e, sourceNode, sinkNode) and | ||
| op.getAnOperand() = e and | ||
| missingGuard(op, e, effect) | ||
| select e, sourceNode, sinkNode, | ||
| "$@ flows to here and is used in arithmetic, potentially causing an " + effect + ".", origin, | ||
| "User-provided value" | ||
| "$@ flows to an operand of an arithmetic expression, potentially causing an " + effect + ".", | ||
| origin, "User-provided value" |
Check warning
Code scanning / CodeQL
Consistent alert message Warning
| from | ||
| PrintfLikeFunction printf, Expr arg, PathNode sourceNode, PathNode sinkNode, | ||
| string printfFunction, Expr userValue, string cause | ||
| where | ||
| printf.outermostWrapperFunctionCall(arg, printfFunction) and | ||
| taintedWithPath(userValue, arg, sourceNode, sinkNode) and | ||
| isUserInput(userValue, cause) | ||
| select arg, sourceNode, sinkNode, | ||
| "The value of this argument may come from $@ and is being used as a formatting argument to " + | ||
| printfFunction, userValue, cause | ||
| printfFunction + ".", userValue, cause |
Check warning
Code scanning / CodeQL
Consistent alert message Warning
| from | ||
| FromSensitiveConfiguration config, SensitiveExpr sensitive, DataFlow::PathNode source, | ||
| DataFlow::PathNode sink, SqliteFunctionCall sqliteCall | ||
| where | ||
| config.hasFlowPath(source, sink) and | ||
| source.getNode().asExpr() = sensitive and | ||
| sqliteCall.getASource() = sink.getNode().asExpr() | ||
| select sqliteCall, source, sink, "This SQLite call may store $@ in a non-encrypted SQLite database", | ||
| sensitive, "sensitive information" | ||
| select sqliteCall, source, sink, | ||
| "This SQLite call may store $@ in a non-encrypted SQLite database.", sensitive, | ||
| "sensitive information" |
Check warning
Code scanning / CodeQL
Consistent alert message Warning
| from | ||
| UncontrolledArithConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink, | ||
| VariableAccess va, string effect | ||
| where | ||
| config.hasFlowPath(source, sink) and | ||
| sink.getNode().asExpr() = va and | ||
| missingGuard(va, effect) | ||
| select sink.getNode(), source, sink, | ||
| "$@ flows to here and is used in arithmetic, potentially causing an " + effect + ".", | ||
| getExpr(source.getNode()), "Uncontrolled value" | ||
| "Arithmetic expression depends on an $@, potentially causing an " + effect + ".", | ||
| getExpr(source.getNode()), "uncontrolled value" |
Check warning
Code scanning / CodeQL
Consistent alert message Warning
cpp/ql/src/experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed up to ImproperNullTerminationTainted.ql. Almost all of the changes are adding a full stop at the end of the message (which I approve of). I'll finish my review and try to add some more constructive suggestions in a few places later.
cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/Security/CWE/CWE-170/ImproperNullTerminationTainted.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-401/MemoryLeakOnFailedCallToRealloc.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql
Outdated
Show resolved
Hide resolved
...xperimental/Security/CWE/CWE-691/InsufficientControlFlowManagementAfterRefactoringTheCode.ql
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-787/UnsignedToSignedPointerArith.ql
Outdated
Show resolved
Hide resolved
...curity/CWE/CWE-129/semmle/ImproperArrayIndexValidation/ImproperArrayIndexValidation.expected
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The tests are failing and that's fine, there is an internal PR where the tests pass (the internal PR updates some expected test outputs).
I've been working on making the alert-messages consistent across languages, and some fan out work from that is ensuring that the alert-messages follow the style guide (which I've also revised).
Fixes done as part of this PR:
'$@'with$@).depends onfor taint-tracking queries andflows tofor dataflow-queries.Some of the messages become inconsistent with other languages, but I'm updating one language at a time, so some will get out of sync.
Some other PRs in this series: JS, Py, Rb, Go, Java (draft).
Style guide update.