Skip to content

Commit 2a95ddd

Browse files
north-echoclaude
andcommitted
docs: update CLAUDE.md for v0.7.0 — public API, 53 rules, 6 platforms
Reflects current state: - pkg/scanner public API (importable as Go library) - 53 rules across 6 platforms (GitHub Actions, GitLab, Azure, Jenkins, Tekton, CircleCI) - 16 CLI commands including dashboard, diff, merge, export, disclosure - Severity tuning lessons learned from scan results - Acknowledgements to Poutine and zizmor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6e19948 commit 2a95ddd

1 file changed

Lines changed: 66 additions & 10 deletions

File tree

CLAUDE.md

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Project
44

5-
Fluxgate is a CI/CD pipeline security static analysis tool. It scans GitHub Actions, GitLab CI, and Azure Pipelines workflow files for dangerous security patterns (pwn requests, script injection, OIDC misconfiguration, etc.).
5+
Fluxgate is a CI/CD pipeline security static analysis tool with **53 detection rules across 6 platforms** (GitHub Actions, GitLab CI, Azure Pipelines, Jenkins, Tekton, CircleCI). Current version: **v0.7.0**.
66

77
## Security Boundaries
88

@@ -16,27 +16,83 @@ Never commit to this public repo:
1616

1717
Test fixtures must be synthetic — never copy real workflow files from scanned repos. When in doubt, keep it private.
1818

19+
A pre-push hook blocks commits containing disclosure ID patterns. Use `--no-verify` only when intentional and the content is public (e.g., referencing an already-published CVE).
20+
1921
## Code Structure
2022

21-
- `cmd/fluxgate/` — CLI entry point (cobra)
22-
- `internal/scanner/` — GitHub Actions parser, rules (FG-xxx), scanner orchestration
23-
- `internal/cicd/` — GitLab CI parser+rules (GL-xxx), Azure Pipelines parser+rules (AZ-xxx)
24-
- `internal/github/` — GitHub API client, batch scanning, discovery
23+
### Public API (v0.7.0+)
24+
- `pkg/scanner/` — Importable as `github.com/north-echo/fluxgate/pkg/scanner`
25+
- Finding, ScanResult, Workflow types
26+
- ScanWorkflowBytes, ScanFile, ScanDirectory, ParseWorkflow
27+
- AllRules(), RuleDescriptions, all Check* functions
28+
- GitHub Actions rules (FG-001 through FG-023) live here
29+
30+
### Private packages
31+
- `cmd/fluxgate/` — CLI entry point (cobra), 16 commands
32+
- `internal/scanner/` — Thin re-export shims for `pkg/scanner` (backward compat)
33+
- `internal/cicd/` — Platform-specific parsers+rules:
34+
- GitLab CI (GL-001 through GL-010)
35+
- Azure Pipelines (AZ-001 through AZ-010)
36+
- Jenkins (JK-001 through JK-009)
37+
- Tekton (TK-001 through TK-009)
38+
- CircleCI (CC-001 through CC-009)
39+
- `internal/github/`, `internal/gitlab/`, `internal/azure/` — API clients with rate limiting, PAT rotation
2540
- `internal/report/` — Output formatters (table, JSON, SARIF, markdown)
26-
- `internal/store/` — SQLite persistence
41+
- `internal/store/` — SQLite persistence with migrations
42+
- `internal/dashboard/` — Go/HTMX web UI (multi-DB switcher, CSV export)
43+
- `internal/diff/`, `internal/merge/`, `internal/export/` — Longitudinal analysis
2744
- `test/fixtures/` — Synthetic YAML fixtures for rule tests
45+
- `research-station/` — Gitignored. Persistent scanning infrastructure on Dell OptiPlex.
46+
47+
## Available CLI Commands
48+
49+
```
50+
scan — Scan local workflow files (auto-detects all 6 platforms)
51+
remote — Scan a remote repo (--platform github|gitlab|azure)
52+
batch — Batch scan repos with --top or --list (supports --tokens for PAT rotation)
53+
discover — Discover repos by workflow pattern via GitHub code search
54+
ingest — Ingest workflow YAML from JSONL (BigQuery exports)
55+
gatox-import — Import Gato-X enumeration results
56+
dashboard — Launch Go/HTMX web UI (--db flag repeatable for multi-DB switcher)
57+
diff — Longitudinal diff between two scan databases
58+
merge — Merge multiple scan databases
59+
export — Export anonymized academic dataset
60+
disclosure — Track disclosure lifecycle (add/list/update/patch subcommands)
61+
sarif-push — Upload findings to GitHub Code Scanning API
62+
cache — Manage no-workflow cache (stats/clear)
63+
```
2864

2965
## Testing
3066

3167
```bash
32-
go test ./...
68+
go test ./... # All tests (scanner, cicd, github, gitlab, diff, merge, export, pkg/scanner)
69+
go build ./... # Must compile cleanly
3370
```
3471

35-
All rules must have corresponding test fixtures and test functions in `*_test.go`.
72+
All rules must have corresponding test fixtures and test functions in `*_test.go`. Rules in `pkg/scanner/rules.go` have tests in `pkg/scanner/rules_test.go`. Platform rules in `internal/cicd/` have tests in the same package.
3673

3774
## Style
3875

3976
- Go standard library style, no unnecessary abstractions
40-
- Rules are functions with signature `func(wf *Workflow) []Finding`
77+
- Rules are functions with signature `func(wf *scanner.Workflow) []scanner.Finding`
4178
- Platform-specific rules live in their parser package (internal/cicd/)
42-
- Bridge functions in scanner.go convert platform findings to common Finding type
79+
- Bridge functions in `pkg/scanner/scan.go` convert platform findings to common Finding type
80+
- Mitigation-aware severity: rules should detect defensive controls (label gates, fork guards, permission checks, etc.) and adjust severity accordingly — see `MitigationAnalysis` in `pkg/scanner/rules.go`
81+
- Echo/logging context downgrade: injection findings in `echo`/`printf`-only contexts should be downgraded to info
82+
- Quoted CLI arguments are harder to exploit than unquoted — downgrade to medium
83+
84+
## Severity Tuning Lessons Learned
85+
86+
- **Compound guards**: actor guard + fork-origin check in the same `if:` = ForkGuard (suppress to info), not just ActorGuard (cap at high)
87+
- **Trusted-ref isolation**: fork checkout to subdir + executed scripts from trusted ref checkout = info
88+
- **Permission-gate jobs**: upstream job verifying `getCollaboratorPermissionLevel` = internal threat only, downgrade by 2
89+
- **Ref-scoped cache keys**: `CI_COMMIT_REF_SLUG` is ref-scoped by default since GitLab 13.x — info, not medium
90+
- **Rules vs scripts**: CI variables in GitLab `rules:` blocks are NOT shell injection, only in `script:` blocks
91+
92+
## Acknowledgements
93+
94+
Detection coverage informed by comparative analysis of:
95+
- [Poutine](https://github.com/boostsecurityio/poutine) (BoostSecurity) — OPA/Rego rules, OSV integration
96+
- [zizmor](https://github.com/zizmorcore/zizmor) (Trail of Bits) — impostor commit detection, cross-step taint tracking
97+
98+
Extends their patterns with mitigation-aware severity modeling, AI-assisted triage, and multi-platform coverage.

0 commit comments

Comments
 (0)