Skip to content

Commit c5d217d

Browse files
authored
Update Go version in CI script (#913)
* Update Go version in CI script * Introduce back an additional check for filepath clean to fix the unit tests
1 parent 5874e63 commit c5d217d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
strategy:
1212
matrix:
1313
go_version:
14-
- '1.18.8' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
15-
- '1.19.3' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
14+
- '1.18.9' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
15+
- '1.19.4' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
1616
runs-on: ubuntu-latest
1717
env:
1818
GO111MODULE: on
@@ -44,7 +44,7 @@ jobs:
4444
- name: Setup go
4545
uses: actions/setup-go@v3
4646
with:
47-
go-version: '1.19.2' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
47+
go-version: '1.19.4' # TODO: remove this once actions/setup-go@v3 uses latest as latest; see https://github.com/securego/gosec/pull/880
4848
- name: Checkout Source
4949
uses: actions/checkout@v3
5050
- uses: actions/cache@v3

rules/readfile.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ func (r *readfile) isJoinFunc(n ast.Node, c *gosec.Context) bool {
5959
}
6060

6161
// isFilepathClean checks if there is a filepath.Clean for given variable
62-
func (r *readfile) isFilepathClean(n *ast.Ident) bool {
62+
func (r *readfile) isFilepathClean(n *ast.Ident, c *gosec.Context) bool {
6363
if _, ok := r.cleanedVar[n.Obj.Decl]; ok {
6464
return true
6565
}
66+
if n.Obj.Kind != ast.Var {
67+
return false
68+
}
69+
if node, ok := n.Obj.Decl.(*ast.AssignStmt); ok {
70+
if call, ok := node.Rhs[0].(*ast.CallExpr); ok {
71+
if clean := r.clean.ContainsPkgCallExpr(call, c, false); clean != nil {
72+
return true
73+
}
74+
}
75+
}
6676
return false
6777
}
6878

@@ -101,7 +111,7 @@ func (r *readfile) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error) {
101111
obj := c.Info.ObjectOf(ident)
102112
if _, ok := obj.(*types.Var); ok &&
103113
!gosec.TryResolve(ident, c) &&
104-
!r.isFilepathClean(ident) {
114+
!r.isFilepathClean(ident, c) {
105115
return gosec.NewIssue(c, n, r.ID(), r.What, r.Severity, r.Confidence), nil
106116
}
107117
}

0 commit comments

Comments
 (0)