feat(07-02): add Gitleaks JSON + CSV importers

- GitleaksImporter parses native JSON array output to []engine.Finding
- GitleaksCSVImporter parses CSV with header-based column resolution
- normalizeGitleaksRuleID strips suffixes (-api-key, -access-token, ...)
- Shared buildGitleaksFinding helper keeps JSON/CSV paths in lockstep
- Test fixtures + 8 tests covering happy path, empty, invalid, symlink fallback
This commit is contained in:
salvacybersec
2026-04-05 23:55:36 +03:00
parent 46eec328d2
commit 83640ac200
4 changed files with 378 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
RuleID,Commit,File,SymlinkFile,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint,Tags
openai-api-key,abc123,config/app.yml,,sk-proj-1234567890abcdef1234,key: sk-proj-1234567890abcdef1234,12,12,10,60,dev,add config,2026-04-01T12:00:00Z,dev@example.com,abc123:config/app.yml:openai-api-key:12,"key,openai"
aws-access-token,def456,terraform/main.tf,,AKIAIOSFODNN7EXAMPLE,access_key = AKIAIOSFODNN7EXAMPLE,55,55,20,40,ops,tf update,2026-04-02T09:30:00Z,ops@example.com,def456:terraform/main.tf:aws-access-token:55,"key,aws"
generic-api-key,ghi789,scripts/deploy.sh,,xoxp-abcdefghijklmnopqrstuvwxyz,TOKEN=xoxp-abcdefghijklmnopqrstuvwxyz,3,3,8,50,dev,deploy script,2026-04-03T15:45:00Z,dev@example.com,ghi789:scripts/deploy.sh:generic-api-key:3,"key,generic"
1 RuleID Commit File SymlinkFile Secret Match StartLine EndLine StartColumn EndColumn Author Message Date Email Fingerprint Tags
2 openai-api-key abc123 config/app.yml sk-proj-1234567890abcdef1234 key: sk-proj-1234567890abcdef1234 12 12 10 60 dev add config 2026-04-01T12:00:00Z dev@example.com abc123:config/app.yml:openai-api-key:12 key,openai
3 aws-access-token def456 terraform/main.tf AKIAIOSFODNN7EXAMPLE access_key = AKIAIOSFODNN7EXAMPLE 55 55 20 40 ops tf update 2026-04-02T09:30:00Z ops@example.com def456:terraform/main.tf:aws-access-token:55 key,aws
4 generic-api-key ghi789 scripts/deploy.sh xoxp-abcdefghijklmnopqrstuvwxyz TOKEN=xoxp-abcdefghijklmnopqrstuvwxyz 3 3 8 50 dev deploy script 2026-04-03T15:45:00Z dev@example.com ghi789:scripts/deploy.sh:generic-api-key:3 key,generic