I’m trying to scan my GoLang/Angular project. I used gosec to scan the GoLang part, but this error always occurs:
- /usr/local/go/bin/gosec ./…
[gosec] 2024/07/08 10:14:19 Including rules: default
[gosec] 2024/07/08 10:14:19 Excluding rules: default
[gosec] 2024/07/08 10:14:19 Import directory: /var/lib/jenkins/workspace/ang-go/server
2024/07/08 10:14:20 internal error: package “encoding/json” without types was imported from “command-line-arguments”
This is the initial stage:
stage('Install Go') { steps { dir('/var/lib/jenkins/workspace/ang-go/server/') {
sh '/usr/local/go/bin/go version'
sh '/usr/local/go/bin/go build -o myapp'
sh '/usr/local/go/bin/go get -u github.com/mattn/go-sqlite3'
sh '/usr/local/go/bin/go test'
sh '/usr/local/go/bin/gosec ./...'
}
}
}
I tried to clean cash and install dependecies with this stage:
stage('Install Go Dependencies') {
steps {
dir('/var/lib/jenkins/workspace/ang-go/server') {
sh '/usr/local/go/bin/go clean -modcache'
sh '/usr/local/go/bin/go mod tidy'
sh '/usr/local/go/bin/go mod vendor'
}
}
}
I also tried to upgrade golang.org/x/tools/go/packages with this stage :
stage('Upgrade Go Packages') {
steps {
script {
sh '/usr/local/go/bin/go get -u golang.org/x/tools/go/packages'
sh '/usr/local/go/bin/go mod tidy'
}
}
}
After trying these solutions, nothing has changed; the error remains the same, and I’m expecting to see the result of the scan
PS: the go version is: go version go1.22.3 linux/amd64