File tree Expand file tree Collapse file tree 5 files changed +74
-1
lines changed
Expand file tree Collapse file tree 5 files changed +74
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ func (a Algorithm) String() string {
2121const (
2222 SHA1 Algorithm = "sha1" // sha1 with hex encoding (lower case only)
2323 SHA256 Algorithm = "sha256" // sha256 with hex encoding (lower case only)
24- MD5 Algorithm = "md5" // md5 with hex encoding (lower case only)
24+ SHA512 Algorithm = "sha512"
25+ MD5 Algorithm = "md5" // md5 with hex encoding (lower case only)
2526)
2627
2728// Digest allows simple protection of hex formatted digest strings, prefixed by their algorithm.
Original file line number Diff line number Diff line change @@ -273,6 +273,8 @@ func (m *Marshaler) Hashes(files []core.File) *[]cdx.Hash {
273273 alg = cdx .HashAlgoSHA1
274274 case digest .SHA256 :
275275 alg = cdx .HashAlgoSHA256
276+ case digest .SHA512 :
277+ alg = cdx .HashAlgoSHA512
276278 case digest .MD5 :
277279 alg = cdx .HashAlgoMD5
278280 default :
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " http://cyclonedx.org/schema/bom-1.5.schema.json" ,
3+ "bomFormat" : " CycloneDX" ,
4+ "specVersion" : " 1.5" ,
5+ "serialNumber" : " urn:uuid:379ddfdb-306b-44e4-bff3-9bfb9bbc5fa5" ,
6+ "version" : 1 ,
7+ "metadata" : {
8+ "timestamp" : " 2022-05-28T10:20:03.79527Z" ,
9+ "tools" : [
10+ {
11+ "vendor" : " aquasecurity" ,
12+ "name" : " trivy" ,
13+ "version" : " dev"
14+ }
15+ ],
16+ "component" : {
17+ "bom-ref" : " 0f585d64-4815-4b72-92c5-97dae191fa4a" ,
18+ "type" : " container" ,
19+ "name" : " maven-test-project"
20+ }
21+ },
22+ "components" : [
23+ {
24+ "bom-ref" : " @angular/animations@19.2.10" ,
25+ "type" : " library" ,
26+ "name" : " @angular/animations" ,
27+ "version" : " 19.2.10" ,
28+ "scope" : " required" ,
29+ "author" : " angular" ,
30+ "description" : " Angular - animations integration with web-animations" ,
31+ "purl" : " pkg:npm/%40angular/animations@19.2.10" ,
32+ "hashes" : [
33+ {
34+ "alg" : " SHA-512" ,
35+ "content" : " 2e51fa9add03f3e308d0b57c40dc7dfeba8b2efd1609f60f4bfe625d21a92327ec7e52e83b97511a1b52e297506eee60aa69cb75ff62eebe257512637fbc1bfa"
36+ }
37+ ]
38+ }
39+ ]
40+ }
Original file line number Diff line number Diff line change @@ -257,6 +257,8 @@ func (b *BOM) unmarshalHashes(hashes *[]cdx.Hash) []digest.Digest {
257257 alg = digest .SHA1
258258 case cdx .HashAlgoSHA256 :
259259 alg = digest .SHA256
260+ case cdx .HashAlgoSHA512 :
261+ alg = digest .SHA512
260262 case cdx .HashAlgoMD5 :
261263 alg = digest .MD5
262264 default :
Original file line number Diff line number Diff line change @@ -848,6 +848,34 @@ func TestUnmarshaler_Unmarshal(t *testing.T) {
848848 },
849849 },
850850 },
851+ {
852+ name : "SHA-512" ,
853+ inputFile : "testdata/happy/package-hashes.json" ,
854+ want : types.SBOM {
855+ Applications : []ftypes.Application {
856+ {
857+ Type : ftypes .NodePkg ,
858+ Packages : ftypes.Packages {
859+ {
860+ ID : "@angular/animations@19.2.10" ,
861+ Name : "@angular/animations" ,
862+ Version : "19.2.10" ,
863+ Identifier : ftypes.PkgIdentifier {
864+ PURL : & packageurl.PackageURL {
865+ Type : packageurl .TypeNPM ,
866+ Namespace : "@angular" ,
867+ Name : "animations" ,
868+ Version : "19.2.10" ,
869+ },
870+ BOMRef : "@angular/animations@19.2.10" ,
871+ },
872+ Digest : "sha512:2e51fa9add03f3e308d0b57c40dc7dfeba8b2efd1609f60f4bfe625d21a92327ec7e52e83b97511a1b52e297506eee60aa69cb75ff62eebe257512637fbc1bfa" ,
873+ },
874+ },
875+ },
876+ },
877+ },
878+ },
851879 {
852880 name : "invalid serial" ,
853881 inputFile : "testdata/sad/invalid-serial.json" ,
You can’t perform that action at this time.
0 commit comments