Files
gosec/internal/ssautil/ssa_result.go
T
Cosmin Cojocar caf93d07f1 Improve taint analyzer performance with shared SSA cache, parallel analyzer execution, and CI regression guard (#1530)
* 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>
2026-02-19 16:50:41 +01:00

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
}