mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 20:15:54 +00:00
Fix some gas warnings
This commit is contained in:
parent
230d286f4e
commit
7355f0a119
2 changed files with 5 additions and 2 deletions
|
@ -102,7 +102,10 @@ func (gas *Analyzer) Process(packagePaths ...string) error {
|
||||||
AllowErrors: true,
|
AllowErrors: true,
|
||||||
}
|
}
|
||||||
for _, packagePath := range packagePaths {
|
for _, packagePath := range packagePaths {
|
||||||
abspath, _ := filepath.Abs(packagePath)
|
abspath, err := filepath.Abs(packagePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
gas.logger.Println("Searching directory:", abspath)
|
gas.logger.Println("Searching directory:", abspath)
|
||||||
|
|
||||||
basePackage, err := build.Default.ImportDir(packagePath, build.ImportComment)
|
basePackage, err := build.Default.ImportDir(packagePath, build.ImportComment)
|
||||||
|
|
2
issue.go
2
issue.go
|
@ -76,7 +76,7 @@ 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 ...
|
size := (int)(end - start) // Go bug, os.File.Read should return int64 ...
|
||||||
file.Seek(start, 0)
|
file.Seek(start, 0) // #nosec
|
||||||
|
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
if nread, err := file.Read(buf); err != nil || nread != size {
|
if nread, err := file.Read(buf); err != nil || nread != size {
|
||||||
|
|
Loading…
Reference in a new issue