Skip to content

Commit 063ae32

Browse files
shivasuryaclaude
andcommitted
fix(scan): Normalize project path to absolute before building callgraph
Fixed critical bug where scan command failed to index any functions in the callgraph when using relative paths (e.g., --project .). Root Cause: - graph.Initialize() created nodes with relative file paths - BuildModuleRegistry() converted paths to absolute internally - indexFunctions() couldn't match relative paths to absolute paths - All functions skipped, resulting in 0 vulnerabilities detected Solution: Convert projectPath to absolute using filepath.Abs() before passing to both graph.Initialize() and callgraph.BuildCallGraph() to ensure consistent path representation throughout the pipeline. Impact: - Before: "indexed 0, skipped_registry=1149" (0 functions) - After: "indexed 1149, skipped_registry=0" (all functions) - Integration test now correctly detects vulnerabilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 523e005 commit 063ae32

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sourcecode-parser/cmd/scan.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"path/filepath"
78

89
"github.com/shivasurya/code-pathfinder/sourcecode-parser/dsl"
910
"github.com/shivasurya/code-pathfinder/sourcecode-parser/graph"
@@ -34,6 +35,13 @@ Examples:
3435
return fmt.Errorf("--project flag is required")
3536
}
3637

38+
// Convert project path to absolute path to ensure consistency
39+
absProjectPath, err := filepath.Abs(projectPath)
40+
if err != nil {
41+
return fmt.Errorf("failed to resolve project path: %w", err)
42+
}
43+
projectPath = absProjectPath
44+
3745
// Step 1: Build code graph (AST)
3846
log.Printf("Building code graph from %s...\n", projectPath)
3947
codeGraph := graph.Initialize(projectPath)

0 commit comments

Comments
 (0)