Skip to content
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

Fix thin data streams with SCE #12503

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions build-scripts/compose_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def mangle_path(path):

# From the list generated by collect_sce_checks, extract the path to the check content,
# and embed the script into the data stream
def embed_sce_checks_in_datastream(datastreamtree, checklists, sce_files, refdir):
def embed_sce_checks_in_datastream(datastreamtree, checklists, sce_files, build_dir):
for file in sce_files:
path = os.path.join(refdir, file)
path = os.path.join(build_dir, file)
mangled_path = mangle_path(file)

with open(path, 'rt', encoding='utf8') as fd:
Expand Down Expand Up @@ -169,6 +169,7 @@ def move_patches_up_to_date_to_source_data_stream_component(datastreamtree):
def parse_args():
parser = argparse.ArgumentParser(description="Compose an SCAP source data \
stream from individual SCAP components")
parser.add_argument("--build-dir", help="the '/build' directory")
parser.add_argument("--xccdf", help="XCCDF 1.2 checklist file name")
parser.add_argument("--oval", help="OVAL file name")
parser.add_argument("--ocil", help="OCIL file name")
Expand Down Expand Up @@ -234,7 +235,7 @@ def create_catalog(component_ref, dependencies):


def compose_ds(
xccdf_file_name, oval_file_name, ocil_file_name,
build_dir, xccdf_file_name, oval_file_name, ocil_file_name,
cpe_dict_file_name, cpe_oval_file_name, sce_enabled):
ds_collection = ET.Element(
"{%s}data-stream-collection" % datastream_namespace)
Expand All @@ -259,8 +260,7 @@ def compose_ds(
add_component(ds_collection, checks, cpe_oval_file_name)
if sce_enabled:
sce_check_files = collect_sce_checks(ds_collection)
refdir = os.path.dirname(oval_file_name)
embed_sce_checks_in_datastream(ds_collection, checklists, sce_check_files, refdir)
embed_sce_checks_in_datastream(ds_collection, checklists, sce_check_files, build_dir)

if hasattr(ET, "indent"):
ET.indent(ds_collection, space=" ", level=0)
Expand Down Expand Up @@ -301,7 +301,7 @@ def _compose_multiple_ds(args):
cpe_oval = xccdf.replace("xccdf", "cpe_oval")

ds = compose_ds(
xccdf, oval, ocil, cpe_dict, cpe_oval, args.enable_sce
args.build_dir, xccdf, oval, ocil, cpe_dict, cpe_oval, args.enable_sce
)
output = _get_thin_ds_output_path(args.output, xccdf.replace("xccdf_", ""))

Expand All @@ -319,6 +319,7 @@ def _compose_multiple_ds(args):
_compose_multiple_ds(args)

ds = compose_ds(
args.xccdf, args.oval, args.ocil, args.cpe_dict, args.cpe_oval, args.enable_sce
args.build_dir, args.xccdf, args.oval, args.ocil, args.cpe_dict,
args.cpe_oval, args.enable_sce
)
_store_ds(ds, args.output)
2 changes: 1 addition & 1 deletion cmake/SSGCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ macro(ssg_build_sds PRODUCT)

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${SSG_BUILD_SCRIPTS}/compose_ds.py" --xccdf "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml" --oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml" --ocil "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ocil.xml" --cpe-dict "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-dictionary.xml" --cpe-oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-oval.xml" --output "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" --multiple-ds "${SSG_THIN_DS_COMPONENTS_DIR}" ${COMPOSE_EXTRA_ARGS}
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${SSG_BUILD_SCRIPTS}/compose_ds.py" --build-dir "${CMAKE_BINARY_DIR}" --xccdf "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml" --oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml" --ocil "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ocil.xml" --cpe-dict "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-dictionary.xml" --cpe-oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-oval.xml" --output "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" --multiple-ds "${SSG_THIN_DS_COMPONENTS_DIR}" ${COMPOSE_EXTRA_ARGS}
COMMAND "${XMLLINT_EXECUTABLE}" --nsclean --format --output "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml"
DEPENDS generate-ssg-${PRODUCT}-xccdf.xml "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml"
DEPENDS generate-ssg-${PRODUCT}-oval.xml "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml"
Expand Down
Loading