From ad69841cdb23bdfb9eaa0ed5d5e158166f622ef0 Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Wed, 8 Jun 2022 13:41:16 +0100 Subject: [PATCH] V0.4.0 errored on uploading cdx file Problem: Uploading cdx file caused an error - no element found. Solution: There were 2 mistakes: 1. the redirect from the input file to the patched output files had been deleted. Added back redirection. 2. The embedded python refenced component.find() when component had not been yet created. Moved the component definition to earlier in the python code. Signed-off-by: Paul Hewlett --- scripts/sbom_scraper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/sbom_scraper.sh b/scripts/sbom_scraper.sh index efae217..21f5206 100755 --- a/scripts/sbom_scraper.sh +++ b/scripts/sbom_scraper.sh @@ -425,6 +425,8 @@ author = ET.SubElement(authors, 'author') ET.SubElement(author, 'name').text = '$AUTHOR_NAME' ET.SubElement(author, 'email').text = '$AUTHOR_EMAIL' +component = metadata.find('component', ns) + # Update component publisher and author publisher = component.find('publisher', ns) if not publisher: @@ -437,8 +439,6 @@ if not author: component.insert(0, author) author.text = '$COMPONENT_AUTHOR_NAME' -component = metadata.find('component', ns) - # Update component name and version component.find('name', ns).text = '$COMPONENT_NAME' component_version = '$COMPONENT_VERSION' @@ -472,7 +472,7 @@ ET.SubElement(supplier, 'url').text = '$SUPPLIER_URL' indent(root) et.write(sys.stdout, encoding='unicode', xml_declaration=True, default_namespace='') END -) +) < "$OUTPUT" > "$PATCHED_OUTPUT" fi # ----------------------------------------------------------------------------