blueprint/customizations: oscap config

Add the required configuration options needed
to run the oscap first boot remediation.
This commit is contained in:
Gianluca Zuccarelli 2022-05-05 14:44:17 +01:00 committed by Christian Kellner
parent 7767f16e31
commit 0ef6789cd9
2 changed files with 29 additions and 0 deletions

View file

@ -22,6 +22,7 @@ type Customizations struct {
Filesystem []FilesystemCustomization `json:"filesystem,omitempty" toml:"filesystem,omitempty"`
InstallationDevice string `json:"installation_device,omitempty" toml:"installation_device,omitempty"`
FDO *FDOCustomization `json:"fdo,omitempty" toml:"fdo,omitempty"`
OpenSCAP *OpenSCAPCustomization `json:"openscap,omitempty" toml:"openscap,omitempty"`
}
type FDOCustomization struct {
@ -90,6 +91,11 @@ type FilesystemCustomization struct {
MinSize uint64 `json:"minsize,omitempty" toml:"size,omitempty"`
}
type OpenSCAPCustomization struct {
DataStream string `json:"datastream,omitempty" toml:"datastream,omitempty"`
ProfileID string `json:"profile_id,omitempty" toml:"profile_id,omitempty"`
}
func (fsc *FilesystemCustomization) UnmarshalTOML(data interface{}) error {
d, _ := data.(map[string]interface{})
@ -367,3 +373,10 @@ func (c *Customizations) GetFDO() *FDOCustomization {
}
return c.FDO
}
func (c *Customizations) GetOpenSCAP() *OpenSCAPCustomization {
if c == nil {
return nil
}
return c.OpenSCAP
}

View file

@ -371,3 +371,19 @@ func TestGetFilesystemsMinSizeNonSectorSize(t *testing.T) {
assert.EqualValues(t, uint64(5632), retFilesystemsSize)
}
func TestGetOpenSCAPConfig(t *testing.T) {
expectedOscap := OpenSCAPCustomization{
DataStream: "test-data-stream.xml",
ProfileID: "test_profile",
}
TestCustomizations := Customizations{
OpenSCAP: &expectedOscap,
}
retOpenSCAPCustomiztions := TestCustomizations.GetOpenSCAP()
assert.EqualValues(t, expectedOscap, *retOpenSCAPCustomiztions)
}