Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion sast-engine/cmd/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,25 @@ Examples:
builder.InitGoStdlibLoader(goRegistry, projectPath, logger)
goTypeEngine := resolution.NewGoTypeInferenceEngine(goRegistry)

goCG, err := builder.BuildGoCallGraph(codeGraph, goRegistry, goTypeEngine, logger)
enableDBCache, _ := cmd.Flags().GetBool("enable-db-cache")
var analysisCache *builder.AnalysisCache
if enableDBCache {
var cacheErr error
analysisCache, cacheErr = builder.OpenAnalysisCache(projectPath)
if cacheErr != nil {
logger.Warning("Could not open analysis cache: %v — running full analysis", cacheErr)
} else {
defer analysisCache.Close()
}
}

goCG, err := builder.BuildGoCallGraph(codeGraph, goRegistry, goTypeEngine, logger, analysisCache)
if err != nil {
logger.Warning("Failed to build Go call graph: %v", err)
} else {
if analysisCache != nil {
logger.Progress("Cache: incremental analysis cache updated")
}
builder.MergeCallGraphs(cg, goCG)
logger.Statistic("Go call graph merged: %d functions, %d call sites",
len(goCG.Functions), countTotalCallSites(goCG))
Expand Down Expand Up @@ -507,5 +522,6 @@ func init() {
ciCmd.Flags().Int("github-pr", 0, "Pull request number for posting comments")
ciCmd.Flags().Bool("pr-comment", false, "Post summary comment on the pull request")
ciCmd.Flags().Bool("pr-inline", false, "Post inline review comments for critical/high findings")
ciCmd.Flags().Bool("enable-db-cache", false, "Enable SQLite-backed incremental analysis cache (experimental)")
ciCmd.MarkFlagRequired("project")
}
18 changes: 17 additions & 1 deletion sast-engine/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,25 @@ Examples:

goTypeEngine := resolution.NewGoTypeInferenceEngine(goRegistry)

goCG, err := builder.BuildGoCallGraph(codeGraph, goRegistry, goTypeEngine, logger)
enableDBCache, _ := cmd.Flags().GetBool("enable-db-cache")
var analysisCache *builder.AnalysisCache
if enableDBCache {
var cacheErr error
analysisCache, cacheErr = builder.OpenAnalysisCache(projectPath)
if cacheErr != nil {
logger.Warning("Could not open analysis cache: %v — running full analysis", cacheErr)
} else {
defer analysisCache.Close()
}
}

goCG, err := builder.BuildGoCallGraph(codeGraph, goRegistry, goTypeEngine, logger, analysisCache)
if err != nil {
logger.Warning("Failed to build Go call graph: %v", err)
} else {
if analysisCache != nil {
logger.Progress("Cache: incremental analysis cache updated")
}
builder.MergeCallGraphs(cg, goCG)
logger.Statistic("Go call graph merged: %d functions, %d call sites",
len(goCG.Functions), countTotalCallSites(goCG))
Expand Down Expand Up @@ -1052,5 +1067,6 @@ func init() {
scanCmd.Flags().Bool("diff-aware", false, "Enable diff-aware scanning (only report findings in changed files)")
scanCmd.Flags().String("base", "", "Base git ref for diff-aware scanning (required with --diff-aware)")
scanCmd.Flags().String("head", "HEAD", "Head git ref for diff-aware scanning")
scanCmd.Flags().Bool("enable-db-cache", false, "Enable SQLite-backed incremental analysis cache (experimental)")
scanCmd.MarkFlagRequired("project")
}
Loading