Skip to content
Open
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
3 changes: 2 additions & 1 deletion internal/analysis/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)
Expand Down Expand Up @@ -98,7 +99,7 @@ type ParseOptions struct {

// RepositoryExists checks if a valid git repository exists at the given path.
func RepositoryExists(path string) bool {
gitDir := strings.TrimSpace(path) + "/.git"
gitDir := filepath.Join(strings.TrimSpace(path), ".git")
_, err := os.Stat(gitDir)
return err == nil
}
10 changes: 8 additions & 2 deletions internal/projects/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func ExpandGlobPatterns(patterns, excludes []string) ([]string, error) {
// Build exclude set (expanded)
for _, exc := range excludes {
excPath := expandPath(exc)
excPath, _ = filepath.Abs(excPath)
excPath, err := filepath.Abs(excPath)
if err != nil {
continue
}
excludeSet[excPath] = true
}

Expand All @@ -114,7 +117,10 @@ func ExpandGlobPatterns(patterns, excludes []string) ([]string, error) {
}

for _, match := range matches {
absMatch, _ := filepath.Abs(match)
absMatch, err := filepath.Abs(match)
if err != nil {
continue
}

// Check if excluded
if excludeSet[absMatch] {
Expand Down
3 changes: 2 additions & 1 deletion internal/reporting/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ func (g *Generator) sendSlack(summary *Summary, webhookURL string) error {
return fmt.Errorf("marshaling slack payload: %w", err)
}

resp, err := http.Post(webhookURL, "application/json", bytes.NewReader(jsonPayload))
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Post(webhookURL, "application/json", bytes.NewReader(jsonPayload))
if err != nil {
return fmt.Errorf("posting to slack: %w", err)
}
Expand Down
9 changes: 5 additions & 4 deletions internal/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,18 @@ func ValidateProjectPath(path string) error {
return fmt.Errorf("resolving path: %w", err)
}

home, _ := os.UserHomeDir()
home, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("cannot determine home directory: %w", err)
}

blocked := []string{
"/",
"/tmp",
"/var",
"/etc",
"/usr",
}
if home != "" {
blocked = append(blocked, home)
home,
}

for _, b := range blocked {
Expand Down
5 changes: 4 additions & 1 deletion internal/snapshots/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ func (c *Collector) TakeSnapshot(ctx context.Context, provider string) (Snapshot
return Snapshot{}, fmt.Errorf("insert snapshot: %w", err)
}

id, _ := result.LastInsertId()
id, err := result.LastInsertId()
if err != nil {
return Snapshot{}, fmt.Errorf("get snapshot id: %w", err)
}

return Snapshot{
ID: id,
Expand Down
Loading