Skip to content

Commit

Permalink
Merge pull request #85 from LaurentGoderre/jq-template-functions
Browse files Browse the repository at this point in the history
Added shared module for jq template with SBOM generator
  • Loading branch information
LaurentGoderre authored Oct 3, 2023
2 parents a226be9 + 08c9261 commit a9fce37
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/template-helper-functions.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#input package
# {
# name: "packageName",
# version: "packageVersion",
# params: {
# "foo": "bar"
# }
# licenses: ["packageLicense" ... ]
# }
#output: object
def sbom:
{
spdxVersion: "SPDX-2.3",
SPDXID: "SPDXRef-DOCUMENT",
name: (.name + "-sbom"),
packages: [
{
name: .name,
versionInfo: .version,
SPDXID: ("SPDXRef-Package--" + .name),
externalRefs: [
{
referenceCategory: "PACKAGE-MANAGER",
referenceType: "purl",
referenceLocator: ("pkg:generic/" + .name + "@" + .version + "?" + (.params | [to_entries[] | .key + "=" + .value] | join("\u0026")))
}
],
licenseDeclared: (if .licenses | length > 0 then
(.licenses | join(" AND "))
else
"NOASSERTION"
end)
}
]
}
;

0 comments on commit a9fce37

Please sign in to comment.