-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenSCAP tailoring: add key/value rule overrides #300
Changes from 1 commit
68fdf42
2e725fc
bd12442
ee3e8c3
a03aaa8
770a6c7
fefcc4c
be317b5
3b6b310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import ( | |
"github.com/osbuild/images/pkg/osbuild" | ||
) | ||
|
||
func CreateRequiredDirectories(createTailoring bool) ([]*fsnode.Directory, error) { | ||
func createRequiredDirectories(createTailoring bool) ([]*fsnode.Directory, error) { | ||
var directories []*fsnode.Directory | ||
|
||
// although the osbuild stage will create this directory, | ||
|
@@ -43,7 +43,7 @@ func CreateTailoringStageOptions(oscapConfig *blueprint.OpenSCAPCustomization, d | |
return nil | ||
} | ||
|
||
datastream := GetDatastream(oscapConfig.Datastream, d) | ||
datastream := getDatastream(oscapConfig.Datastream, d) | ||
|
||
tailoringConfig := oscapConfig.Tailoring | ||
if tailoringConfig == nil { | ||
|
@@ -64,3 +64,38 @@ func CreateTailoringStageOptions(oscapConfig *blueprint.OpenSCAPCustomization, d | |
}, | ||
) | ||
} | ||
|
||
func CreateRemediationStageOptions( | ||
oscapConfig *blueprint.OpenSCAPCustomization, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better if this function would accept some internal abstraction of the OSCAP config, instead of BP customization. |
||
isOSTree bool, | ||
d distro.Distro, | ||
) (*osbuild.OscapRemediationStageOptions, []*fsnode.Directory, error) { | ||
if oscapConfig == nil { | ||
return nil, nil, nil | ||
} | ||
|
||
if isOSTree { | ||
return nil, nil, fmt.Errorf("unexpected oscap options for ostree image type") | ||
} | ||
Comment on lines
+86
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is IMO not the place to check if the image type is ostree or not. This is not the job if a function which generates an osbuild stage options. Instead, this should be checked on a higher-lervel in the distro implementation and we should return an error there in case one wants to use BP customizations with an image type that does not support them. |
||
|
||
datastream := getDatastream(oscapConfig.Datastream, d) | ||
|
||
profileID := oscapConfig.ProfileID | ||
if oscapConfig.Tailoring != nil { | ||
profileID = getTailoringProfileID(profileID) | ||
} | ||
|
||
directories, err := createRequiredDirectories(oscapConfig.Tailoring == nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
return osbuild.NewOscapRemediationStageOptions( | ||
dataDirPath, | ||
osbuild.OscapConfig{ | ||
Datastream: datastream, | ||
ProfileID: profileID, | ||
Compression: true, | ||
}, | ||
), directories, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,39 +161,22 @@ func osCustomizations( | |
osc.YUMRepos = append(osc.YUMRepos, osbuild.NewYumReposStageOptions(filename, repos)) | ||
} | ||
|
||
if oscapConfig := c.GetOpenSCAP(); oscapConfig != nil { | ||
if t.rpmOstree { | ||
panic("unexpected oscap options for ostree image type") | ||
} | ||
|
||
datastream := oscap.GetDatastream(oscapConfig.Datastream, t.arch.distro) | ||
|
||
oscapStageOptions := osbuild.OscapConfig{ | ||
Datastream: datastream, | ||
ProfileID: oscapConfig.ProfileID, | ||
Compression: true, | ||
} | ||
|
||
osc.OpenSCAPTailorConfig = oscap.CreateTailoringStageOptions( | ||
oscapConfig, | ||
t.arch.distro, | ||
) | ||
|
||
if tailorConfig := osc.OpenSCAPTailorConfig; tailorConfig != nil { | ||
oscapStageOptions.ProfileID = tailorConfig.Config.NewProfile | ||
oscapStageOptions.Tailoring = tailorConfig.Filepath | ||
} | ||
|
||
directories, err := oscap.CreateRequiredDirectories(oscapConfig.Tailoring != nil) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if len(directories) > 0 { | ||
osc.Directories = append(osc.Directories, directories...) | ||
} | ||
var directories []*fsnode.Directory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: consider renaming this to something like |
||
osc.OpenSCAPTailorConfig = oscap.CreateTailoringStageOptions( | ||
c.GetOpenSCAP(), | ||
t.arch.distro, | ||
) | ||
osc.OpenSCAPConfig, directories, err = oscap.CreateRemediationStageOptions( | ||
c.GetOpenSCAP(), | ||
t.rpmOstree, | ||
t.arch.distro, | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
osc.OpenSCAPConfig = osbuild.NewOscapRemediationStageOptions(oscapDataDir, oscapStageOptions) | ||
if len(directories) > 0 { | ||
osc.Directories = append(osc.Directories, directories...) | ||
} | ||
|
||
osc.ShellInit = imageConfig.ShellInit | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this should IMO go into the
osbuild
package.