mirror of
https://github.com/securego/gosec.git
synced 2025-02-05 13:04:47 +02:00
Merge pull request #102 from GoASTScanner/bugfix
Reduce logging messages a tad
This commit is contained in:
commit
c68ed64f6c
@ -15,7 +15,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ryanuber/go-glob"
|
"github.com/ryanuber/go-glob"
|
||||||
@ -57,11 +56,13 @@ func (f *fileList) Set(path string) error {
|
|||||||
func (f fileList) Contains(path string) bool {
|
func (f fileList) Contains(path string) bool {
|
||||||
for p := range f.patterns {
|
for p := range f.patterns {
|
||||||
if glob.Glob(p, path) {
|
if glob.Glob(p, path) {
|
||||||
log.Printf("excluding: %s\n", path)
|
if logger != nil {
|
||||||
|
logger.Printf("skipping: %s\n", path)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("including: %s\n", path)
|
//log.Printf("including: %s\n", path)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
main.go
13
main.go
@ -167,12 +167,12 @@ func main() {
|
|||||||
tools := newUtils()
|
tools := newUtils()
|
||||||
flag.Var(tools, "tool", "GAS utilities to assist with rule development")
|
flag.Var(tools, "tool", "GAS utilities to assist with rule development")
|
||||||
|
|
||||||
|
// Setup logging
|
||||||
|
logger = log.New(os.Stderr, "[gas] ", log.LstdFlags)
|
||||||
|
|
||||||
// Parse command line arguments
|
// Parse command line arguments
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Setup logging
|
|
||||||
logger = log.New(os.Stderr, "[gas]", log.LstdFlags)
|
|
||||||
|
|
||||||
// Ensure at least one file was specified
|
// Ensure at least one file was specified
|
||||||
if flag.NArg() == 0 {
|
if flag.NArg() == 0 {
|
||||||
|
|
||||||
@ -195,6 +195,7 @@ func main() {
|
|||||||
toAnalyze := getFilesToAnalyze(flag.Args(), excluded)
|
toAnalyze := getFilesToAnalyze(flag.Args(), excluded)
|
||||||
|
|
||||||
for _, file := range toAnalyze {
|
for _, file := range toAnalyze {
|
||||||
|
logger.Printf("scanning \"%s\"\n", file)
|
||||||
if err := analyzer.Process(file); err != nil {
|
if err := analyzer.Process(file); err != nil {
|
||||||
logger.Fatal(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -226,10 +227,10 @@ func main() {
|
|||||||
|
|
||||||
// getFilesToAnalyze lists all files
|
// getFilesToAnalyze lists all files
|
||||||
func getFilesToAnalyze(paths []string, excluded *fileList) []string {
|
func getFilesToAnalyze(paths []string, excluded *fileList) []string {
|
||||||
log.Println("getFilesToAnalyze: start")
|
//log.Println("getFilesToAnalyze: start")
|
||||||
var toAnalyze []string
|
var toAnalyze []string
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
log.Printf("getFilesToAnalyze: processing \"%s\"\n", path)
|
//log.Printf("getFilesToAnalyze: processing \"%s\"\n", path)
|
||||||
// get the absolute path before doing anything else
|
// get the absolute path before doing anything else
|
||||||
path, err := filepath.Abs(path)
|
path, err := filepath.Abs(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -257,7 +258,7 @@ func getFilesToAnalyze(paths []string, excluded *fileList) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("getFilesToAnalyze: end")
|
//log.Println("getFilesToAnalyze: end")
|
||||||
return toAnalyze
|
return toAnalyze
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user