@@ -15,6 +15,8 @@ import * as ghcr from '../src/ghcr-client'
1515import * as ociContainer from '../src/oci-container'
1616
1717const ghcrUrl = new URL ( 'https://ghcr.io' )
18+ const predicateType = 'https://slsa.dev/provenance/v1'
19+ const bundleMediaType = 'application/vnd.dev.sigstore.bundle.v0.3+json'
1820
1921// Mock the GitHub Actions core library
2022let setFailedMock : jest . SpyInstance
@@ -302,11 +304,14 @@ describe('run', () => {
302304 attestationID : 'test-attestation-id' ,
303305 certificate : 'test' ,
304306 bundle : {
305- mediaType : 'application/vnd.cncf.notary.v2+jwt' ,
307+ mediaType : bundleMediaType ,
306308 verificationMaterial : {
307309 publicKey : {
308310 hint : 'test-hint'
309311 }
312+ } ,
313+ dsseEnvelope : {
314+ payload : btoa ( `{"predicateType": "${ predicateType } "}` )
310315 }
311316 }
312317 }
@@ -360,11 +365,14 @@ describe('run', () => {
360365 attestationID : 'test-attestation-id' ,
361366 certificate : 'test' ,
362367 bundle : {
363- mediaType : 'application/vnd.cncf.notary.v2+jwt' ,
368+ mediaType : bundleMediaType ,
364369 verificationMaterial : {
365370 publicKey : {
366371 hint : 'test-hint'
367372 }
373+ } ,
374+ dsseEnvelope : {
375+ payload : btoa ( `{"predicateType": "${ predicateType } "}` )
368376 }
369377 }
370378 }
@@ -426,11 +434,14 @@ describe('run', () => {
426434 attestationID : 'test-attestation-id' ,
427435 certificate : 'test' ,
428436 bundle : {
429- mediaType : 'application/vnd.cncf.notary.v2+jwt' ,
437+ mediaType : bundleMediaType ,
430438 verificationMaterial : {
431439 publicKey : {
432440 hint : 'test-hint'
433441 }
442+ } ,
443+ dsseEnvelope : {
444+ payload : btoa ( `{"predicateType": "${ predicateType } "}` )
434445 }
435446 }
436447 }
@@ -568,11 +579,14 @@ describe('run', () => {
568579 attestationID : 'test-attestation-id' ,
569580 certificate : 'test' ,
570581 bundle : {
571- mediaType : 'application/vnd.cncf.notary.v2+jwt' ,
582+ mediaType : bundleMediaType ,
572583 verificationMaterial : {
573584 publicKey : {
574585 hint : 'test-hint'
575586 }
587+ } ,
588+ dsseEnvelope : {
589+ payload : btoa ( `{"predicateType": "${ predicateType } "}` )
576590 }
577591 }
578592 }
@@ -583,6 +597,21 @@ describe('run', () => {
583597 expect ( repository ) . toBe ( options . nameWithOwner )
584598 expect ( tag ) . toBe ( 'sha256-my-test-digest' )
585599 expect ( manifest . mediaType ) . toBe ( ociContainer . imageIndexMediaType )
600+ expect ( manifest . annotations [ 'com.github.package.type' ] ) . toBe (
601+ ociContainer . actionPackageReferrerTagAnnotationValue
602+ )
603+ expect ( manifest . manifests . length ) . toBe ( 1 )
604+ expect ( manifest . manifests [ 0 ] . mediaType ) . toBe (
605+ ociContainer . imageManifestMediaType
606+ )
607+ expect ( manifest . manifests [ 0 ] . artifactType ) . toBe ( bundleMediaType )
608+ expect (
609+ manifest . manifests [ 0 ] . annotations [ 'dev.sigstore.bundle.predicateType' ]
610+ ) . toBe ( predicateType )
611+ expect (
612+ manifest . manifests [ 0 ] . annotations [ 'com.github.package.type' ]
613+ ) . toBe ( ociContainer . actionPackageAttestationAnnotationValue )
614+
586615 return 'sha256:referrer-index-digest'
587616 }
588617 )
@@ -593,16 +622,23 @@ describe('run', () => {
593622 let expectedAnnotationValue = ''
594623 let expectedTagValue : string | undefined = undefined
595624 let returnValue = ''
625+ let expectedPredicateTypeValue : string | undefined = undefined
626+
627+ let expectedSubjectMediaType : string | undefined = undefined
596628
597629 if ( tag === undefined ) {
598630 expectedAnnotationValue =
599631 ociContainer . actionPackageAttestationAnnotationValue
600632 const sigStoreLayer = manifest . layers . find (
601633 ( layer : ociContainer . Descriptor ) =>
602- layer . mediaType === ociContainer . sigstoreBundleMediaType
634+ layer . mediaType === bundleMediaType
603635 )
636+ expectedPredicateTypeValue = predicateType
604637
605638 expectedBlobKeys = [ sigStoreLayer . digest , ociContainer . emptyConfigSha ]
639+
640+ expectedSubjectMediaType = ociContainer . imageManifestMediaType
641+
606642 returnValue = 'sha256:attestation-digest'
607643 } else {
608644 expectedAnnotationValue = ociContainer . actionPackageAnnotationValue
@@ -616,7 +652,12 @@ describe('run', () => {
616652 expect ( manifest . annotations [ 'com.github.package.type' ] ) . toBe (
617653 expectedAnnotationValue
618654 )
655+ expect ( manifest . annotations [ 'dev.sigstore.bundle.predicateType' ] ) . toBe (
656+ expectedPredicateTypeValue
657+ )
619658 expect ( tag ) . toBe ( expectedTagValue )
659+ expect ( manifest . subject ?. mediaType ) . toBe ( expectedSubjectMediaType )
660+
620661 expect ( manifest . layers . length ) . toBe ( expectedBlobKeys . length - 1 ) // Minus config layer
621662 expect ( blobs . size ) . toBe ( expectedBlobKeys . length )
622663 for ( const expectedBlobKey of expectedBlobKeys ) {
0 commit comments