internal/cloudapi: add OpenSCAP tailoring

Add support to the cloudapi for generating the tailoring file used
to customize the OpenSCAP remediation. This allows users to select and
unselect rules for the remediation and the `autotailor` stage generates
the tailoring file.
This commit is contained in:
Gianluca Zuccarelli 2023-08-11 14:28:13 +01:00 committed by Tomáš Hozza
parent 360df12548
commit 0ce4ec7fc4
3 changed files with 162 additions and 131 deletions

View file

@ -212,6 +212,16 @@ func (request *ComposeRequest) GetBlueprintWithCustomizations() (blueprint.Bluep
openSCAPCustomization := &blueprint.OpenSCAPCustomization{
ProfileID: request.Customizations.Openscap.ProfileId,
}
if tailoring := request.Customizations.Openscap.Tailoring; tailoring != nil {
tailoringCustomizations := blueprint.OpenSCAPTailoringCustomizations{}
if tailoring.Selected != nil && len(*tailoring.Selected) > 0 {
tailoringCustomizations.Selected = *tailoring.Selected
}
if tailoring.Unselected != nil && len(*tailoring.Unselected) > 0 {
tailoringCustomizations.Unselected = *tailoring.Unselected
}
openSCAPCustomization.Tailoring = &tailoringCustomizations
}
if bp.Customizations == nil {
bp.Customizations = &blueprint.Customizations{
OpenSCAP: openSCAPCustomization,