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

Move data stream component references #12557

Merged
merged 3 commits into from
Nov 4, 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
8 changes: 4 additions & 4 deletions build-scripts/compose_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ 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, build_dir):
def embed_sce_checks_in_datastream(datastreamtree, checklists, checks, build_dir):
sce_files = collect_sce_checks(datastreamtree)
for file in sce_files:
path = os.path.join(build_dir, file)
mangled_path = mangle_path(file)
Expand All @@ -55,7 +56,7 @@ def embed_sce_checks_in_datastream(datastreamtree, checklists, sce_files, build_
# Create a component reference to map the checklist to the extended component
component_ref_id = "scap_{}_cref_{}".format(ID_NS, mangled_path)
component_ref = ET.SubElement(
checklists, '{%s}component-ref' % datastream_namespace,
checks, '{%s}component-ref' % datastream_namespace,
attrib={
'id': component_ref_id,
('{%s}href' % xlink_namespace): '#' + component_id
Expand Down Expand Up @@ -259,8 +260,7 @@ def compose_ds(
add_component(ds_collection, checks, ocil_file_name)
add_component(ds_collection, checks, cpe_oval_file_name)
if sce_enabled:
sce_check_files = collect_sce_checks(ds_collection)
embed_sce_checks_in_datastream(ds_collection, checklists, sce_check_files, build_dir)
embed_sce_checks_in_datastream(ds_collection, checklists, checks, build_dir)

if hasattr(ET, "indent"):
ET.indent(ds_collection, space=" ", level=0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ds_sce.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def verify_file(ds, catalog_uris, file, build_dir):
component_ref = ds.find(str.format(
".//{{{ds_ns}}}checklists/{{{ds_ns}}}component-ref[@id='{cid}']",
".//{{{ds_ns}}}checks/{{{ds_ns}}}component-ref[@id='{cid}']",
ds_ns=datastream_namespace,
cid=catalog_uris[file]
))
Expand Down
Loading