Skip to content

Commit 29391a1

Browse files
committed
Merge branch 'main' into codeql-cli-2.8.0-copy
2 parents 14d227a + 92862fa commit 29391a1

14 files changed

Lines changed: 1125 additions & 12 deletions

File tree

.github/workflows/codeqltest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797

9898
test-win:
9999
name: Test Windows
100-
runs-on: windows-latest
100+
runs-on: windows-2019
101101
steps:
102102
- name: Set up Go 1.17
103103
uses: actions/setup-go@v1

extractor/dbscheme/tables.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ var ChanTypeExprs = map[ast.ChanDir]*BranchType{
497497
ast.SEND | ast.RECV: ExprKind.NewBranch("@sendrcvchantypeexpr", ChanTypeExpr),
498498
}
499499

500+
// ErrorExpr is an AST node type that is not used anywhere
501+
var ErrorExpr = ExprKind.NewBranch("@errorexpr")
502+
500503
// StmtKind is a case type for distinguishing different kinds of statement AST nodes
501504
var StmtKind = NewCaseType(StmtType, "kind")
502505

ql/examples/qlpack.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: codeql/go-examples
2-
version: 0.0.2
2+
groups:
3+
- go
4+
- examples
35
dependencies:
4-
codeql/go-all: "*"
6+
codeql/go-all: "*"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @name Incomplete switch over enum
3+
* @description A switch statement of enum type should explicitly reference each
4+
* of the members of that enum.
5+
* @kind problem
6+
* @id go/examples/incomplete-switch
7+
*/
8+
9+
import go
10+
11+
from ExpressionSwitchStmt ss, DeclaredConstant c, NamedType t
12+
where
13+
t.getUnderlyingType() instanceof IntegerType and
14+
t = ss.getExpr().getType() and
15+
c.getType() = t and
16+
forall(CaseClause case | case = ss.getACase() | not case = c.getAReference().getParent())
17+
select ss, "This switch statement is not exhaustive: missing $@", c, c.getName()

ql/lib/go.dbscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ case @expr.kind of
308308
| 48 = @andnotexpr
309309
| 49 = @sendchantypeexpr
310310
| 50 = @recvchantypeexpr
311-
| 51 = @sendrcvchantypeexpr;
311+
| 51 = @sendrcvchantypeexpr
312+
| 52 = @errorexpr;
312313

313314
@basiclit = @intlit | @floatlit | @imaglit | @charlit | @stringlit;
314315

ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/go-all
2-
version: 0.0.7
2+
version: 0.0.8-dev
33
groups: go
44
dbscheme: go.dbscheme
55
extractor: go

ql/lib/semmle/go/frameworks/SQL.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ module SQL {
8383
SquirrelQueryString() {
8484
exists(Function fn |
8585
exists(string sq |
86-
sq = package(["github.com/Masterminds", "github.com/lann"], "squirrel")
86+
sq =
87+
package([
88+
"github.com/Masterminds/squirrel", "gopkg.in/Masterminds/squirrel",
89+
"github.com/lann/squirrel"
90+
], "")
8791
|
8892
// first argument to `squirrel.Expr`
8993
fn.hasQualifiedName(sq, "Expr")

ql/lib/semmle/go/security/TaintedPathCustomizations.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ module TaintedPath {
7676
}
7777
}
7878

79+
/**
80+
* A call to `filepath.Clean("/" + e)`, considered to sanitize `e` against path traversal.
81+
*/
82+
class FilepathCleanSanitizer extends Sanitizer {
83+
FilepathCleanSanitizer() {
84+
exists(DataFlow::CallNode cleanCall, StringOps::Concatenation concatNode |
85+
cleanCall = any(Function f | f.hasQualifiedName("path/filepath", "Clean")).getACall() and
86+
concatNode = cleanCall.getArgument(0) and
87+
concatNode.getOperand(0).asExpr().(StringLit).getValue() = "/" and
88+
this = cleanCall.getResult()
89+
)
90+
}
91+
}
92+
7993
/**
8094
* A check of the form `!strings.Contains(nd, "..")`, considered as a sanitizer guard for
8195
* path traversal.

0 commit comments

Comments
 (0)