mirror of
https://github.com/securego/gosec.git
synced 2026-06-20 00:15:59 +02:00
* Improve taint analyzer performance with shared SSA cache, parallel analyzer execution, and CI regression guard * Added a shared per-package SSA analysis cache with lazy, concurrency-safe call graph reuse across analyzers. * Updated taint analyzers to consume the shared cache instead of recomputing expensive artifacts per rule run. * Parallelized analyzer execution at package level while preserving deterministic issue aggregation. * Added a package-level taint benchmark to measure real end-to-end taint analyzer pass performance. * Introduced a CI benchmark regression guard with configurable thresholds for ns/op, B/op, and allocs/op. * Documented the performance guard workflow, local run command, and baseline update process in the README. Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch> * Fix script Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch> --------- Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
38 lines
951 B
Go
38 lines
951 B
Go
// Package ssautil provides shared SSA analysis utilities for gosec analyzers.
|
|
package ssautil
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
|
|
"golang.org/x/tools/go/analysis"
|
|
"golang.org/x/tools/go/analysis/passes/buildssa"
|
|
)
|
|
|
|
var (
|
|
ErrNoSSAResult = errors.New("no SSA result found in the analysis pass")
|
|
ErrInvalidSSAType = errors.New("the analysis pass result is not of type SSA")
|
|
)
|
|
|
|
// SSAAnalyzerResult contains various information returned by the
|
|
// SSA analysis along with some configuration
|
|
type SSAAnalyzerResult struct {
|
|
Config map[string]any
|
|
Logger *log.Logger
|
|
SSA *buildssa.SSA
|
|
Shared *PackageAnalysisCache
|
|
}
|
|
|
|
// GetSSAResult retrieves the SSA result from analysis pass
|
|
func GetSSAResult(pass *analysis.Pass) (*SSAAnalyzerResult, error) {
|
|
result, ok := pass.ResultOf[buildssa.Analyzer]
|
|
if !ok {
|
|
return nil, ErrNoSSAResult
|
|
}
|
|
ssaResult, ok := result.(*SSAAnalyzerResult)
|
|
if !ok {
|
|
return nil, ErrInvalidSSAType
|
|
}
|
|
return ssaResult, nil
|
|
}
|