Skip to content

Commit d5204de

Browse files
committed
Fix Blueprint template to be self-contained
Now the generated Blueprint file will be ready-to-use right after generation unless a custom data stream is used for hardening. There are also instructions on how to adapt the Blueprint for a custom data stream.
1 parent 6506089 commit d5204de

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/XCCDF_POLICY/xccdf_policy_remediate.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,23 @@ static int _write_script_header_to_fd(struct xccdf_policy *policy, struct xccdf_
11431143
} else if (oscap_streq(sys, "urn:redhat:osbuild:blueprint")) {
11441144
char *blueprint_fix_header = oscap_sprintf(
11451145
"%s"
1146-
"name = \"%s\"\n"
1146+
"name = \"hardened_%s\"\n"
11471147
"description = \"%s\"\n"
1148-
"version = \"%s\"\n",
1149-
fix_header, profile_id, profile_title, benchmark_version_info);
1148+
"version = \"%s\"\n\n"
1149+
"[customizations.openscap]\n"
1150+
"profile_id = \"%s\"\n"
1151+
"# If your hardening data stream is not part of the 'scap-security-guide' package\n"
1152+
"# provide the absolute path to it (from the root of the image filesystem).\n"
1153+
"# datastream = \"/usr/share/xml/scap/ssg/content/ssg-xxxxx-ds.xml\"\n\n"
1154+
"# If your hardening data stream is not part of the 'scap-security-guide' package\n"
1155+
"# you don't need this package to be installed in the image (section can be removed).\n"
1156+
"[[packages]]\n"
1157+
"name = \"scap-security-guide\"\n"
1158+
"version = \"*\"\n\n"
1159+
"[[packages]]\n"
1160+
"name = \"openscap-scanner\"\n"
1161+
"version = \"*\"\n\n",
1162+
fix_header, profile_id, profile_title, benchmark_version_info, profile_id);
11501163
free(fix_header);
11511164
free(profile_title);
11521165
return _write_text_to_fd_and_free(output_fd, blueprint_fix_header);

tests/API/XCCDF/unittests/test_remediation_blueprint.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@
1919
#
2020
###############################################################################
2121

22-
name = "xccdf_moc.elpmaxe.www_profile_common"
22+
name = "hardened_xccdf_moc.elpmaxe.www_profile_common"
2323
description = "Profile title on one line"
2424
version = "1.0"
25+
26+
[customizations.openscap]
27+
profile_id = "xccdf_moc.elpmaxe.www_profile_common"
28+
# If your hardening data stream is not part of the 'scap-security-guide' package
29+
# provide the absolute path to it (from the root of the image filesystem).
30+
# datastream = "/usr/share/xml/scap/ssg/content/ssg-xxxxx-ds.xml"
31+
32+
# If your hardening data stream is not part of the 'scap-security-guide' package
33+
# you don't need this package to be installed in the image (section can be removed).
34+
[[packages]]
35+
name = "scap-security-guide"
36+
version = "*"
37+
38+
[[packages]]
39+
name = "openscap-scanner"
40+
version = "*"
41+
2542
distro = rhel-80
2643

2744
[[packages]]

0 commit comments

Comments
 (0)