Skip to content

feat: Add SDK API and fix critical inconsistencies (v1.7.2)#47

Merged
had-nu merged 3 commits intodevfrom
feat/sdk-api-and-bugfixes
Apr 20, 2026
Merged

feat: Add SDK API and fix critical inconsistencies (v1.7.2)#47
had-nu merged 3 commits intodevfrom
feat/sdk-api-and-bugfixes

Conversation

@had-nu
Copy link
Copy Markdown
Owner

@had-nu had-nu commented Apr 20, 2026

Summary

This PR introduces a programmatic SDK for Wardex that enables security engineers to integrate compliance gap analysis into custom tools, CI/CD pipelines, and automated workflows without relying on CLI invocations.

Changes

New Feature: SDK API (pkg/sdk/)

  • sdk.Analyze(controls, framework) - Run compliance assessment
  • sdk.LoadControls(paths...) - Load controls from files (YAML/JSON/CSV)
  • sdk.LoadFramework(name) - Load framework catalog
  • sdk.Report(result, format, output, limit) - Generate reports
  • sdk.SnapshotSave/Load/Diff - Trend analysis

Bug Fixes (Critical)

  1. EPSS 1.0 handling - EPSS score 1.0 is valid (100% probability), not "missing"
  2. CSV output - Added missing gate decisions and delta sections
  3. AggregateLimit - Now used in aggregate mode
  4. RBAC consistency - Aligned error messages

Version

Bump: 1.7.1 → 1.7.2

Testing

go test ./...       ✓ All tests pass
go vet ./...       ✓ No static analysis errors
go build          ✓ Compiles successfully

Example Usage

import "github.com/had-nu/wardex/pkg/sdk"

func main() {
    controls, _ := sdk.LoadControls("./controls.yaml")
    result, _ := sdk.Analyze(controls, "iso27001")
    fmt.Printf("Coverage: %.1f%%\n", result.Summary.GlobalCoverage)
}

Files Changed

  • pkg/sdk/ (new package)
  • examples/sdk/ (new example)
  • pkg/analyzer/analyzer.go - Exported with error returns
  • pkg/correlator/correlator.go - Exported with error returns
  • pkg/report/csv.go - Added gate/delta sections
  • pkg/enrich/cli/cli.go - Fixed EPSS handling
  • pkg/releasegate/gate.go - Added AggregateLimit
  • cmd/evaluate/evaluate.go - Fixed RBAC message
  • Tests updated

had-nu and others added 3 commits April 15, 2026 18:00
## Version 1.7.2

### New Feature: SDK API
This commit introduces a programmatic SDK for integrating Wardex into
custom tools, CI/CD pipelines, and security workflows without CLI calls.

- NEW pkg/sdk package with public API:
  - sdk.Analyze(controls, framework) -> *AssessmentResult
  - sdk.LoadControls(paths...) -> []ExistingControl
  - sdk.LoadFramework(name) -> []CatalogControl
  - sdk.Report(result, format, output, limit)
  - sdk.SnapshotSave/Load/Diff functions

- Added comprehensive godoc documentation
- Added SDK example in examples/sdk/
- Exported analyzer.Analyze() and correlator.Correlate() with error returns

### Bug Fixes (Critical)

1. EPSS score handling (pkg/enrich/cli/cli.go:75)
   - Fixed: EPSS score of 1.0 is VALID (100% probability)
   - Changed condition from `== 0.0 || == 1.0` to only `== 0.0`
   - This prevents infinite re-fetch loops

2. CSV report missing gate/delta (pkg/report/csv.go)
   - Added Release Gate section with CVE decisions
   - Added Snapshot Delta section with trend data
   - Now matches markdown output completeness

3. Unused AggregateLimit config (pkg/releasegate/gate.go)
   - Added AggregateLimit field to Gate struct
   - Used in aggregate mode for total risk threshold
   - Updated main.go and cmd/evaluate callers

4. RBAC error message consistency (cmd/evaluate/evaluate.go)
   - Made evaluate.go match main.go error format
   - Both now show consistent violation messages

### Refactoring
- analyzer.Analyze() now returns ([]Finding, error)
- correlator.Correlate() now returns ([]Mapping, error)
- Updated all callers to handle new return values
- Updated tests to handle error returns

### Testing
- All existing tests pass
- New SDK tests added (TestSDK_Analyze, TestSDK_LoadFramework)
- Verified build with go vet and go build

Co-authored-by: opencode <assistant@opencode.ai>
@had-nu had-nu merged commit 5ac1a9d into dev Apr 20, 2026
1 check passed
@had-nu had-nu deleted the feat/sdk-api-and-bugfixes branch April 20, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant