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

add initial python version of script to add metadata to sbom #4082

Closed
wants to merge 2 commits into from
Closed
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
32 changes: 32 additions & 0 deletions combiner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json

with open("sample-metadata.json", "r") as metadata_file:
with open("workspace/target/OpenJDK-sbom.json", "r") as sbom_file:
metadata = json.loads(metadata_file.read())
sbom = json.loads(sbom_file.read())
if "metadata" not in sbom:
sbom["metadata"] = {}
if "properties" not in sbom["metadata"]:
sbom["metadata"]["properties"] = []
properties_to_skip = [
"version"
] # todo: do we flatten this? or put it somewhere else in some meaningful way? cyclone dx wasn't expecting a dict
properties_to_flatten = [
""
] # todo: BUILD_CONFIGURATION_param - are these redundant/should we just skip this, or is this what andrew means we should add to that bash script arg
for property in metadata:
if property in properties_to_skip:
continue
if property in properties_to_flatten:
for sub in metadata[property]:
sbom["metadata"]["properties"].append(
{"name": sub, "value": json.dumps(metadata[property])}
)
print(property)
print(metadata[property])
print("\n\n\n")
sbom["metadata"]["properties"].append(
{"name": property, "value": metadata[property]}
)
with open("sbom_modified.json", "w") as out:
out.write(json.dumps(sbom, indent=True))
1 change: 1 addition & 0 deletions configureBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ setVariablesForConfigure() {
BUILD_CONFIG[TEST_IMAGE_PATH]=$openjdk_test_image_path
BUILD_CONFIG[DEBUG_IMAGE_PATH]=$openjdk_debug_image_path
BUILD_CONFIG[STATIC_LIBS_IMAGE_PATH]=$static_libs_path
BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS]="--build=x86_64-unknown-linux-gnu --openjdk-target=x86_64-unknown-linux-gnu"
}

# Set the repository to build from, defaults to adoptium if not set by the user
Expand Down
Loading
Loading