mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Fix some lint warnings
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
parent
bac6f0fb8f
commit
3af4ae9ddb
4 changed files with 11 additions and 14 deletions
|
@ -231,11 +231,11 @@ func (gosec *Analyzer) ignore(n ast.Node) ([]string, bool) {
|
|||
gosec.stats.NumNosec++
|
||||
|
||||
// Pull out the specific rules that are listed to be ignored.
|
||||
re := regexp.MustCompile("(G\\d{3})")
|
||||
re := regexp.MustCompile(`(G\d{3})`)
|
||||
matches := re.FindAllStringSubmatch(group.Text(), -1)
|
||||
|
||||
// If no specific rules were given, ignore everything.
|
||||
if matches == nil || len(matches) == 0 {
|
||||
if len(matches) == 0 {
|
||||
return nil, true
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ func (gosec *Analyzer) Visit(n ast.Node) ast.Visitor {
|
|||
}
|
||||
|
||||
// Now create the union of exclusions.
|
||||
ignores := make(map[string]bool, 0)
|
||||
ignores := map[string]bool{}
|
||||
if len(gosec.context.Ignores) > 0 {
|
||||
for k, v := range gosec.context.Ignores[0] {
|
||||
ignores[k] = v
|
||||
|
|
5
issue.go
5
issue.go
|
@ -78,7 +78,10 @@ func codeSnippet(file *os.File, start int64, end int64, n ast.Node) (string, err
|
|||
}
|
||||
|
||||
size := (int)(end - start) // Go bug, os.File.Read should return int64 ...
|
||||
file.Seek(start, 0) // #nosec
|
||||
_, err := file.Seek(start, 0) // #nosec
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("move to the beginning of file: %v", err)
|
||||
}
|
||||
|
||||
buf := make([]byte, size)
|
||||
if nread, err := file.Read(buf); err != nil || nread != size {
|
||||
|
|
|
@ -36,11 +36,11 @@ func (r *filePermissions) ID() string {
|
|||
func getConfiguredMode(conf map[string]interface{}, configKey string, defaultMode int64) int64 {
|
||||
var mode = defaultMode
|
||||
if value, ok := conf[configKey]; ok {
|
||||
switch value.(type) {
|
||||
switch value := value.(type) {
|
||||
case int64:
|
||||
mode = value.(int64)
|
||||
mode = value
|
||||
case string:
|
||||
if m, e := strconv.ParseInt(value.(string), 0, 64); e != nil {
|
||||
if m, e := strconv.ParseInt(value, 0, 64); e != nil {
|
||||
mode = defaultMode
|
||||
} else {
|
||||
mode = m
|
||||
|
|
|
@ -30,12 +30,6 @@ type TestPackage struct {
|
|||
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
|
||||
// auxiliary files
|
||||
func NewTestPackage() *TestPackage {
|
||||
goPath := os.Getenv("GOPATH")
|
||||
// if user did not set GOPATH, set to the default
|
||||
if goPath == "" {
|
||||
goPath = build.Default.GOPATH
|
||||
}
|
||||
|
||||
workingDir, err := ioutil.TempDir("", "gosecs_test")
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue