Skip to content

Commit 4751f13

Browse files
Add CI/CD flexibility features for enterprise integration
New features: - --ignore flag to suppress specific pattern IDs (e.g., RSA-001, CERT-*) - --ignore-category flag to suppress entire categories - --fail-on flag for configurable exit codes (info/low/medium/high/critical) - --baseline flag for comparing against previous scan results - --config flag for explicit config file path - Auto-detection of .cryptoscan.yaml configuration files - Pattern-specific inline suppression (cryptoscan:ignore RSA-001) - Wildcard pattern matching in ignore directives New pkg/config package for YAML configuration parsing with: - Ignore patterns, categories, and file globs - failOn and minSeverity settings - baseline file path configuration Updates: - README with comprehensive CI/CD integration documentation - Updated roadmap for v1.3.0 release - Fixed MigrationScore recalculation after baseline filtering
1 parent 0512bf1 commit 4751f13

7 files changed

Lines changed: 832 additions & 40 deletions

File tree

README.md

Lines changed: 123 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ CryptoScan is purpose-built for quantum readiness assessment:
4444
| **Migration Readiness Score** | **Yes** | No | No |
4545
| **Hybrid crypto recognition** | **Yes** | No | Rarely |
4646
| **QRAMM framework mapping** | **Yes** | No | No |
47+
| **CI/CD baseline comparison** | **Yes** | No | Some |
48+
| **Configurable exit codes** | **Yes** | No | Some |
4749
| Context-aware confidence | **Yes** | No | Varies |
4850
| CBOM output | **Yes** | No | Rarely |
4951
| SARIF for GitHub Security | **Yes** | No | Yes |
5052
| Inline ignore comments | **Yes** | No | Some |
53+
| Pattern-specific suppression | **Yes** | No | Rarely |
5154
| Migration guidance | **Yes** | No | Varies |
5255
| Dependency scanning | **Yes** | No | Some |
56+
| Configuration file | **Yes** | N/A | Yes |
5357
| Open source | **Yes** | Yes | No |
5458

5559
### What These Capabilities Mean
@@ -276,18 +280,25 @@ Arguments:
276280
path Local directory, file, or Git URL to scan (default: current directory)
277281
278282
Flags:
279-
-f, --format string Output format: text, json, csv, sarif, cbom (default "text")
280-
-o, --output string Output file path (default: stdout)
281-
-i, --include string File patterns to include (comma-separated globs)
282-
-e, --exclude string File patterns to exclude (comma-separated globs)
283-
-d, --max-depth int Maximum directory depth (0 = unlimited)
284-
-g, --group-by string Group output by: file, severity, category, quantum
285-
-c, --context int Lines of source context to show (default 3)
286-
-p, --progress Show scan progress indicator
287-
--min-severity string Minimum severity to report: info, low, medium, high, critical
288-
--no-color Disable colored output
289-
--pretty Pretty print JSON output
290-
-h, --help Show help
283+
-f, --format string Output format: text, json, csv, sarif, cbom (default "text")
284+
-o, --output string Output file path (default: stdout)
285+
-i, --include string File patterns to include (comma-separated globs)
286+
-e, --exclude string File patterns to exclude (comma-separated globs)
287+
-d, --max-depth int Maximum directory depth (0 = unlimited)
288+
-g, --group-by string Group output by: file, severity, category, quantum
289+
-c, --context int Lines of source context to show (default 3)
290+
-p, --progress Show scan progress indicator
291+
--min-severity string Minimum severity to report: info, low, medium, high, critical
292+
--no-color Disable colored output
293+
--pretty Pretty print JSON output
294+
-h, --help Show help
295+
296+
CI/CD Flags:
297+
--ignore string Pattern IDs to ignore (comma-separated, e.g., "RSA-001,CERT-*")
298+
--ignore-category string Categories to ignore (e.g., "Certificate,Library Import")
299+
--fail-on string Exit non-zero if findings at this severity or higher
300+
--baseline string Baseline JSON file - only report new findings
301+
--config string Config file path (default: auto-detect .cryptoscan.yaml)
291302
```
292303

293304
### Common Workflows
@@ -314,22 +325,96 @@ cryptoscan scan . --min-severity critical --format json | jq '.findings | length
314325
Use inline comments to suppress findings that are intentional or not applicable:
315326

316327
```go
317-
// Suppress a specific line
328+
// Suppress all findings on this line
318329
key := rsa.GenerateKey(rand.Reader, 2048) // cryptoscan:ignore
319330

331+
// Suppress only RSA findings (ECDSA would still be reported)
332+
import "crypto/rsa" // cryptoscan:ignore RSA-001
333+
334+
// Suppress an entire pattern family
335+
legacyAuth() // cryptoscan:ignore CERT-*
336+
320337
// Suppress the next line
321338
// cryptoscan:ignore-next-line
322339
legacyKey := oldCrypto.NewKey()
323340
```
324341

325342
Supported directives:
326-
- `cryptoscan:ignore` — Ignore finding on this line
343+
- `cryptoscan:ignore` — Ignore all findings on this line
344+
- `cryptoscan:ignore RSA-001` — Ignore specific pattern ID
345+
- `cryptoscan:ignore RSA-*` — Ignore pattern family (wildcard)
327346
- `cryptoscan:ignore-next-line` — Ignore finding on the following line
328347
- `crypto-scan:ignore` — Alternative format
329-
- `noscan` — Quick ignore
348+
- `noscan` — Quick ignore all
330349

331350
### CI/CD Integration
332351

352+
CryptoScan provides enterprise-grade CI/CD flexibility with ignore mechanisms, baseline comparison, and configurable exit codes.
353+
354+
#### Configuration File
355+
356+
Create a `.cryptoscan.yaml` in your project root to configure default behavior:
357+
358+
```yaml
359+
# .cryptoscan.yaml - CryptoScan configuration
360+
ignore:
361+
patterns:
362+
- CERT-SELFSIGNED-001 # Known dev certificates
363+
- RSA-001 # Legacy auth, migration tracked in JIRA-123
364+
categories:
365+
- Library Import # Don't report import statements
366+
files:
367+
- "vendor/*"
368+
- "testdata/*"
369+
370+
failOn: high # Exit non-zero on HIGH or CRITICAL findings
371+
minSeverity: low # Report LOW and above
372+
baseline: baseline.json # Only report new findings vs baseline
373+
```
374+
375+
#### Baseline Workflow
376+
377+
Use baselines to track progress and only fail on **new** issues:
378+
379+
```bash
380+
# 1. Generate initial baseline (stores current known issues)
381+
cryptoscan scan . --format json --output baseline.json
382+
383+
# 2. In CI, compare against baseline - only new issues cause failure
384+
cryptoscan scan . --baseline baseline.json --fail-on high
385+
386+
# 3. After fixing issues, regenerate baseline
387+
cryptoscan scan . --format json --output baseline.json
388+
```
389+
390+
#### Exit Code Control
391+
392+
Control when CI fails based on finding severity:
393+
394+
```bash
395+
# Fail on any HIGH or CRITICAL findings
396+
cryptoscan scan . --fail-on high
397+
398+
# Fail only on CRITICAL findings (most permissive)
399+
cryptoscan scan . --fail-on critical
400+
401+
# Fail on MEDIUM and above (stricter)
402+
cryptoscan scan . --fail-on medium
403+
```
404+
405+
#### Suppressing Known Issues
406+
407+
```bash
408+
# Ignore specific pattern IDs
409+
cryptoscan scan . --ignore "RSA-001,CERT-SELFSIGNED-001"
410+
411+
# Ignore entire categories
412+
cryptoscan scan . --ignore-category "Certificate,Library Import"
413+
414+
# Combine with baseline for maximum flexibility
415+
cryptoscan scan . --ignore "RSA-*" --baseline baseline.json --fail-on high
416+
```
417+
333418
#### GitHub Actions with SARIF
334419

335420
```yaml
@@ -359,10 +444,17 @@ jobs:
359444
run: go install github.com/csnp/cryptoscan/cmd/cryptoscan@latest
360445

361446
- name: Run Scan
362-
run: cryptoscan scan . --format sarif --output results.sarif
447+
run: |
448+
# Use baseline if it exists, fail on new HIGH+ findings
449+
if [ -f baseline.json ]; then
450+
cryptoscan scan . --baseline baseline.json --fail-on high --format sarif --output results.sarif
451+
else
452+
cryptoscan scan . --fail-on critical --format sarif --output results.sarif
453+
fi
363454
364455
- name: Upload SARIF to GitHub Security
365456
uses: github/codeql-action/upload-sarif@v3
457+
if: always()
366458
with:
367459
sarif_file: results.sarif
368460
```
@@ -375,12 +467,13 @@ crypto-scan:
375467
image: golang:1.21
376468
script:
377469
- go install github.com/csnp/cryptoscan/cmd/cryptoscan@latest
378-
- cryptoscan scan . --format json --output crypto-findings.json
470+
- cryptoscan scan . --baseline baseline.json --fail-on high --format json --output crypto-findings.json
379471
artifacts:
380472
reports:
381473
sast: crypto-findings.json
382474
paths:
383475
- crypto-findings.json
476+
allow_failure: false
384477
```
385478
386479
#### Pre-commit Hook
@@ -390,7 +483,8 @@ crypto-scan:
390483
# .git/hooks/pre-commit
391484

392485
if command -v cryptoscan &> /dev/null; then
393-
cryptoscan scan . --min-severity critical --format text
486+
# Only check staged files, fail on critical
487+
cryptoscan scan . --fail-on critical --min-severity high
394488
if [ $? -ne 0 ]; then
395489
echo "Critical cryptographic issues found. Commit blocked."
396490
exit 1
@@ -479,7 +573,7 @@ cryptoscan/
479573

480574
## Roadmap
481575

482-
### v1.2 (Current Release)
576+
### v1.3 (Current Release)
483577
- [x] Local and remote repository scanning
484578
- [x] 90+ cryptographic patterns
485579
- [x] Multiple output formats (text, JSON, CSV, SARIF, CBOM)
@@ -493,16 +587,19 @@ cryptoscan/
493587
- [x] KDF detection (HKDF, PBKDF2, Argon2id, scrypt, bcrypt)
494588
- [x] Migration Readiness Score with visual dashboard
495589
- [x] QRAMM framework integration (CVI Dimension mapping)
496-
- [x] **NEW: Certificate detection (X.509, CSR, PKCS#12, chains, mTLS, JWK)**
497-
- [x] **NEW: Certificate validation bypass detection (CRITICAL severity)**
498-
- [x] **NEW: Weak certificate signature detection (SHA-1/MD5)**
499-
- [x] **NEW: Enhanced false positive reduction with smart context analysis**
500-
501-
### v1.3 (Next)
590+
- [x] Certificate detection (X.509, CSR, PKCS#12, chains, mTLS, JWK)
591+
- [x] Certificate validation bypass detection (CRITICAL severity)
592+
- [x] Weak certificate signature detection (SHA-1/MD5)
593+
- [x] Enhanced false positive reduction with smart context analysis
594+
- [x] **NEW: CI/CD flexibility with `--ignore`, `--ignore-category`, `--fail-on`, `--baseline`**
595+
- [x] **NEW: Configuration file support (`.cryptoscan.yaml`)**
596+
- [x] **NEW: Pattern-specific inline suppression (`cryptoscan:ignore RSA-001`)**
597+
- [x] **NEW: Baseline comparison for tracking new findings only**
598+
599+
### v1.4 (Next)
502600
- [ ] Smart remediation engine with language-specific recommendations
503601
- [ ] Enhanced CBOM output (CycloneDX 1.6 cryptoProperties)
504602
- [ ] Git history scanning (find crypto in past commits)
505-
- [ ] Configuration file templates
506603

507604
### v2.0 (Future)
508605
- [ ] AWS resource scanning (KMS, ACM, Secrets Manager)

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ module github.com/csnp/cryptoscan
22

33
go 1.21
44

5-
require github.com/spf13/cobra v1.10.2
5+
require (
6+
github.com/spf13/cobra v1.10.2
7+
gopkg.in/yaml.v3 v3.0.1
8+
)
69

710
require (
811
github.com/inconshreveable/mousetrap v1.1.0 // indirect

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT
77
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
88
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
99
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1011
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
12+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
13+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)