213213 INPUT=$( ls)
214214 OUTFILE=${INPUT} .${FORMAT} .sbom
215215 OUTPUT=" ${TEMPDIR} /${OUTFILE} "
216- syft -q packages --scope all-layers -o " ${FORMAT} " " file:${INPUT} " > " ${OUTPUT} "
216+ syftjar -q packages --scope all-layers -o " ${FORMAT} " " file:${INPUT} " > " ${OUTPUT} "
217217 popd > /dev/null
218218
219219 COMPONENT_NAME=$( xq -r .bom.metadata.component.name " $OUTPUT " )
@@ -403,11 +403,14 @@ et = ET.parse(sys.stdin)
403403root = et.getroot()
404404
405405metadata = root.find('metadata', ns)
406+ if not metadata:
407+ metadata = ET.SubElement(root, 'metadata')
406408
407409# Add this tool
408410tools = metadata.find('tools', ns)
409411if not tools:
410412 tools = ET.SubElement(metadata, 'tools')
413+
411414tool = ET.SubElement(tools, 'tool')
412415ET.SubElement(tool, 'vendor').text = '$TOOL_VENDOR '
413416ET.SubElement(tool, 'name').text = '$TOOL_NAME '
@@ -426,6 +429,8 @@ ET.SubElement(author, 'name').text = '$AUTHOR_NAME'
426429ET.SubElement(author, 'email').text = '$AUTHOR_EMAIL '
427430
428431component = metadata.find('component', ns)
432+ if not component:
433+ component = ET.SubElement(metadata, 'component')
429434
430435# Update component publisher and author
431436publisher = component.find('publisher', ns)
@@ -436,14 +441,21 @@ publisher.text = '$COMPONENT_AUTHOR_NAME'
436441author = component.find('author', ns)
437442if not author:
438443 author = ET.Element('author')
439- component.insert(0 , author)
444+ component.insert(1 , author)
440445author.text = '$COMPONENT_AUTHOR_NAME '
441446
442447# Update component name and version
443- component.find('name', ns).text = '$COMPONENT_NAME '
448+ name = component.find('name', ns)
449+ if not name:
450+ name = ET.SubElement(component, 'name')
451+
452+ name.text = '$COMPONENT_NAME '
444453component_version = '$COMPONENT_VERSION '
445454if component_version:
446- component.find('version', ns).text = component_version
455+ version = component.find('version', ns)
456+ if not version:
457+ version = ET.SubElement(component, 'version')
458+ version.text = component_version
447459
448460# Update component hash
449461component_hash_alg = '${COMPONENT_HASH_ALG} '
@@ -458,7 +470,7 @@ if component_hash_alg:
458470supplier = component.find('supplier', ns)
459471if not supplier:
460472 supplier = ET.Element('supplier')
461- component.insert(0 , supplier)
473+ component.insert(4 , supplier)
462474ET.SubElement(supplier, 'name').text = '$SUPPLIER_NAME '
463475ET.SubElement(supplier, 'url').text = '$SUPPLIER_URL '
464476
0 commit comments