Skip to content

Refactor baseline compiler#187

Merged
eddie-knight merged 6 commits intoossf:mainfrom
puerco:refactor-compiler
Feb 18, 2025
Merged

Refactor baseline compiler#187
eddie-knight merged 6 commits intoossf:mainfrom
puerco:refactor-compiler

Conversation

@puerco
Copy link
Member

@puerco puerco commented Feb 18, 2025

This PR refactors the baseline compiler code to separate the cli from the generation/loading logic. This allows us to extend the cli to support more use cases and makes the loader and generator easier to use.

In summary, this PR:

  • Introduces new baseline.Loader and baseline.Generator objects that house the existing logic.
  • Moves the CLI code into an internal package
  • Creates an independent types package with the yaml data structures

The CLI itself has the same interface as before:

Baseline Compiler reads the Basline YAML and outputs it as a markdown document.

Usage:
  baseline-compiler [flags]
  baseline-compiler [command]

Available Commands:
  compile     Compile a YAML file of security criteria
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command

Flags:
  -h, --help   help for baseline-compiler

Use "baseline-compiler [command] --help" for more information about a command.
[puerco@babieco security-baseline/cmd] on  refactor-compiler 🦆❯ go run . compile --help
Compile a YAML file of security criteria

Usage:
  baseline-compiler compile [file] [flags]

Flags:
  -b, --baseline string   path to directory containing the baseline YAML data (default "../baseline")
  -h, --help              help for compile
  -o, --output string     path to output file (defaults to STDOUT)
  -t, --template string   path to the markdown template file (default "template.md")

I'll follow up with PR with a validation command.

Signed-off-by: Adolfo García Veytia (Puerco) adolfo.garcia@uservers.net

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
@puerco
Copy link
Member Author

puerco commented Feb 18, 2025

OK, fixed the merge conflict we discussed in the feb 18th meeting, PTAL

Copy link
Contributor

@funnelfiasco funnelfiasco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I ran it through some general usage and everything worked as expected.

@eddie-knight eddie-knight merged commit ec2d100 into ossf:main Feb 18, 2025
2 checks passed
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.

3 participants