feat: Add SDK API and fix critical inconsistencies (v1.7.2)#47
Merged
Conversation
## 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 assessmentsdk.LoadControls(paths...)- Load controls from files (YAML/JSON/CSV)sdk.LoadFramework(name)- Load framework catalogsdk.Report(result, format, output, limit)- Generate reportssdk.SnapshotSave/Load/Diff- Trend analysisBug Fixes (Critical)
Version
Bump: 1.7.1 → 1.7.2
Testing
Example Usage
Files Changed
pkg/sdk/(new package)examples/sdk/(new example)pkg/analyzer/analyzer.go- Exported with error returnspkg/correlator/correlator.go- Exported with error returnspkg/report/csv.go- Added gate/delta sectionspkg/enrich/cli/cli.go- Fixed EPSS handlingpkg/releasegate/gate.go- Added AggregateLimitcmd/evaluate/evaluate.go- Fixed RBAC message