-
Notifications
You must be signed in to change notification settings - Fork 0
Test v0.3.0 summary schema #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Binaries | ||
| devsecops | ||
| devsecops-* | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
|
|
||
| # Claude Code | ||
| CLAUDE.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "errors" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| ) | ||
|
|
||
| // ProjectInfo contains detected project information | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 Secret Detected Rule:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 Secret Detected Rule:
|
||
|
|
@@ -14,6 +15,8 @@ type ProjectInfo struct { | |
| PackageFile string // e.g. "package.json", "go.mod" | ||
| RootDir string // project root directory | ||
| Dependencies []string // coarse list of deps (for future heuristics) | ||
| HasDocker bool // true if Dockerfile detected | ||
| DockerImages []string // list of Docker image names found | ||
| } | ||
|
|
||
| // Detector interface for language/framework detection | ||
|
|
@@ -51,9 +54,71 @@ func DetectProject(dir string) (*ProjectInfo, error) { | |
| return nil, errors.New("no supported project type detected") | ||
| } | ||
|
|
||
| // Check for Docker (can coexist with any language) | ||
| detectDocker(dir, bestMatch) | ||
|
|
||
| return bestMatch, nil | ||
| } | ||
|
|
||
| // detectDocker checks for Dockerfile and docker-compose.yml, updates ProjectInfo in-place | ||
| func detectDocker(dir string, info *ProjectInfo) { | ||
| // Check for Dockerfile | ||
| dockerfilePath := filepath.Join(dir, "Dockerfile") | ||
| if fileExists(dockerfilePath) { | ||
| info.HasDocker = true | ||
|
|
||
| // Try to extract image names from Dockerfile | ||
| images := extractDockerImages(dockerfilePath) | ||
| info.DockerImages = images | ||
| } | ||
|
|
||
| // Also check for docker-compose.yml (indicates Docker usage) | ||
| composePaths := []string{ | ||
| filepath.Join(dir, "docker-compose.yml"), | ||
| filepath.Join(dir, "docker-compose.yaml"), | ||
| } | ||
|
|
||
| for _, composePath := range composePaths { | ||
| if fileExists(composePath) { | ||
| info.HasDocker = true | ||
| break | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // extractDockerImages parses Dockerfile to find image references | ||
| // Returns a simple heuristic: finds lines like "FROM image:tag" | ||
| func extractDockerImages(dockerfilePath string) []string { | ||
| data, err := os.ReadFile(dockerfilePath) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
|
|
||
| var images []string | ||
| content := string(data) | ||
| lines := strings.Split(content, "\n") | ||
|
|
||
| for _, line := range lines { | ||
| line = strings.TrimSpace(line) | ||
|
|
||
| // Look for "FROM <image>" | ||
| if strings.HasPrefix(strings.ToUpper(line), "FROM ") { | ||
| parts := strings.Fields(line) // Split by whitespace | ||
| if len(parts) >= 2 { | ||
| image := parts[1] | ||
| // Skip build stages (FROM ... AS stage_name) | ||
| // Check if next word is "AS" | ||
| if len(parts) >= 3 && strings.ToUpper(parts[2]) == "AS" { | ||
| continue // This is a build stage, skip it | ||
| } | ||
| images = append(images, image) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return images | ||
| } | ||
|
|
||
| // fileExists checks if a file exists | ||
| func fileExists(path string) bool { | ||
| _, err := os.Stat(path) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 Secret Detected
Rule:
generic-api-keyMatch:
sk-1234567890abcdefg...