feat: add --crosswalk-output flag for reverse framework crosswalk#504
Merged
Conversation
Signed-off-by: liketosweep <liketosweep@gmail.com>
Signed-off-by: liketosweep <liketosweep@gmail.com>
888fb83 to
20f6448
Compare
funnelfiasco
approved these changes
Apr 29, 2026
Contributor
funnelfiasco
left a comment
There was a problem hiding this comment.
Looks good. Thanks for taking this on.
Contributor
|
@kusari-inspector rerun |
|
🔄 Run triggered at 18:50:37 UTC. Starting fresh analysis... |
SecurityCRob
approved these changes
May 6, 2026
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.
What the Issue Was
The
baseline-compileronly supports forward-facing generation - exportingcontrols and their associated framework mappings. Auditors and security engineers
working in reverse (starting from a NIST or CIS sub-control and identifying which
OSPS controls satisfy it) had no automated path. Manually tracing these
relationships through YAML source files is inefficient and error-prone.
Why It Was There
The generation logic was previously coupled with standard template rendering, with
no inversion step. The data structure was
Control -> []Requirement, with nomechanism to pivot to a
Framework -> Requirement -> []Control_IDhierarchyneeded for audit crosswalk artifacts. There was also no CLI entry point to trigger
such a generation path.
Solution
Introduced a
--crosswalk-outputstring flag to thecompilecommand. When apath is provided,
RunEtriggers a dedicated crosswalk generator rather than thestandard template renderer. The generator inverts the mapping data via
buildReverseCrosswalkand writes the result usingExportReverseCrosswalkwithan
io.Writerfor flexibility. Lexicographical sorting is applied to Frameworknames, Requirement IDs, and Control IDs to ensure byte-for-byte stable output
across runs and environments.
Changes
cmd/internal/cmd/compile.go- Introduced--crosswalk-outputstring flag;added logic in
RunEto trigger the crosswalk generator when a path is provided;added a success indicator (✅) to terminal output consistent with existing UX.
pkg/baseline/generator_crosswalk.go- CreatedbuildReverseCrosswalktoperform mapping inversion; implemented
ExportReverseCrosswalkviaio.Writer;applied deterministic lexicographical sorting across all output dimensions.
pkg/baseline/generator_crosswalk_test.go- Added unit tests using theproject's internal
typesto mock a baseline catalog; verified correct groupingof requirements under frameworks and byte-for-byte output stability across runs.
Result
The
baseline-compilercan now generate a reverse crosswalk artifact as afirst-class CLI operation. Auditors can map from any regulatory requirement
(NIST, CIS) back to the OSPS controls that satisfy it - automatically, and as
part of any CI/CD pipeline or local dev workflow - without manually tracing YAML
source files.
Conducted Tests
Testing Note: Verified generation logic via 100% unit test coverage. During manual CLI testing on Windows (MinGW64), I discovered that the existing loader.go currently fails during local URI fetching (unsupported URI scheme / invalid port errors) because fetcher.URI{} struggles to parse native Windows file paths. I have kept this PR strictly scoped to the crosswalk generation logic, but I would love to tackle that cross-platform URI bug in a separate issue!
Example Output
Running
./baseline-compiler compile --crosswalk-output reverse.mdgenerates the following artifact structure:Resolves #379