Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
two-heart committed Nov 22, 2024
1 parent b7b00fc commit f15cfa1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: "CodeQL Nightly Analysis"

on:
push:
branches:
- 'codeql-improvement'
workflow_call:
workflow_dispatch:

Expand Down
3 changes: 2 additions & 1 deletion contrib/codeql/BuiltinExpectScopeTooNarrow.ql
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ where
(e instanceof BinaryLogicalOperation) or
(e instanceof ConditionalExpr)) and
included(builtinCall.getLocation())
select builtinCall, "Use of __builtin_expect() in non-conditional context"
select builtinCall, "Use of __builtin_expect() in non-conditional context"

5 changes: 3 additions & 2 deletions contrib/codeql/NonAnnotatedFormatFunction.ql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Find calls to functions that likely expect a format string but are not annotated as such.
* @id cpp/non-annotated-format-function
* @id asymmetric-research/non-annotated-format-function
* @kind problem
* @severity warning
*/
Expand All @@ -12,4 +12,5 @@ where s.getValueText().regexpMatch(".*%[A-z0-9$].*") and
s.getParent().(FunctionCall).getTarget() = f and /* ignores dynamic function calls */
not exists( Attribute attr | attr = f.getAnAttribute() | attr.getName() = "format" ) and
f.getLocation().getFile().getRelativePath().regexpMatch("src/.*")
select f, "Likely format string passed to non-format function"
select f, "Likely format string passed to non-format function"

2 changes: 1 addition & 1 deletion contrib/codeql/RedundantNullCheck.ql
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@

select checked, deref, checked, "This null check is redundant because $@ in any case.", deref,
"the value is dereferenced"

3 changes: 2 additions & 1 deletion contrib/codeql/UnclearOperatorPrecedence.ql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ from BinaryBitwiseOperation bit, ComparisonOperation rel, Expr other
where
bit.hasOperands(rel, other) and
not rel.isParenthesised()
select rel, "Operator precedence and paranthese hint at a likely issue"
select rel, "Operator precedence and paranthese hint at a likely issue"

4 changes: 2 additions & 2 deletions contrib/codeql/filter.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*/
import cpp
predicate included(Location loc) {
loc.getFile().getRelativePath().prefix(5) != "agave/"
}
loc.getFile().getRelativePath().prefix(6) != "agave/"
}

0 comments on commit f15cfa1

Please sign in to comment.