Skip to content

Commit b9c4c66

Browse files
jirfagccojocar
authored andcommitted
Expose analyzer API (#366)
Make it possible to use gosec from e.g. golangci-lint without modification of gosec.
1 parent 29fddff commit b9c4c66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

analyzer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (gosec *Analyzer) Process(buildTags []string, packagePaths ...string) error
125125
if err != nil {
126126
return fmt.Errorf("parsing errors in pkg %q: %v", pkg.Name, err)
127127
}
128-
gosec.check(pkg)
128+
gosec.Check(pkg)
129129
}
130130
}
131131
}
@@ -180,7 +180,8 @@ func (gosec *Analyzer) load(pkgPath string, conf *packages.Config) ([]*packages.
180180
return pkgs, nil
181181
}
182182

183-
func (gosec *Analyzer) check(pkg *packages.Package) {
183+
// Check runs analysis on the given package
184+
func (gosec *Analyzer) Check(pkg *packages.Package) {
184185
gosec.logger.Println("Checking package:", pkg.Name)
185186
for _, file := range pkg.Syntax {
186187
gosec.logger.Println("Checking file:", pkg.Fset.File(file.Pos()).Name())

0 commit comments

Comments
 (0)