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

update generated code to reflect new required fields in intoto v0.0.2 #525

Merged
merged 2 commits into from
May 31, 2023
Merged
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
6 changes: 3 additions & 3 deletions packages/client/src/__tests__/tlog/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('format', () => {
// This hard-coded hash value helps us detect if we've unintentionally
// changed the hashing algorithm.
expect(entry.spec.content.hash?.value).toBe(
'91a5eb7452452720d704da5442acb9703252b3ab7be51ec155a244f5c9aa5ec8'
'37d47ab456ca63a84f6457be655dd49799542f2e1db5d05160b214fb0b9a7f55'
);
});
});
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('format', () => {
// This hard-coded hash value helps us detect if we've unintentionally
// changed the hashing algorithm.
expect(entry.spec.content.hash?.value).toBe(
'295fd391f3b3f349cdaa686befaa765d90c0b411a0811e45f8bc481338a51622'
'f39ab279af9d9be421342ce4c8e5c422b5bc3dd20602703b1893283a934fbe72'
);
});
});
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('format', () => {
// This hard-coded hash value helps us detect if we've unintentionally
// changed the hashing algorithm.
expect(entry.spec.content.hash?.value).toBe(
'91a5eb7452452720d704da5442acb9703252b3ab7be51ec155a244f5c9aa5ec8'
'37d47ab456ca63a84f6457be655dd49799542f2e1db5d05160b214fb0b9a7f55'
);
});
});
Expand Down
14 changes: 11 additions & 3 deletions packages/client/src/tlog/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function toProposedIntotoV002Entry(
const payloadHash = crypto.hash(envelope.payload).toString('hex');

// Calculate the value for the hash field in the Rekor entry
const envelopeHash = calculateDSSEHash(envelope);
const envelopeHash = calculateDSSEHash(envelope, signature);

// Collect values for re-creating the DSSE envelope.
// Double-encode payload and signature cause that's what Rekor expects
Expand Down Expand Up @@ -123,11 +123,19 @@ function toProposedIntotoV002Entry(
// * signature is base64 encoded (only the first signature is used)
// * keyid is included ONLY if it is NOT an empty string
// * The resulting JSON is canonicalized and hashed to a hex string
function calculateDSSEHash(envelope: Envelope): string {
function calculateDSSEHash(
envelope: Envelope,
signature: SignatureMaterial
): string {
const dsse: ProposedIntotoEntry['spec']['content']['envelope'] = {
payloadType: envelope.payloadType,
payload: envelope.payload.toString('base64'),
signatures: [{ sig: envelope.signatures[0].sig.toString('base64') }],
signatures: [
{
sig: envelope.signatures[0].sig.toString('base64'),
publicKey: toPublicKey(signature),
},
],
};

// If the keyid is an empty string, Rekor seems to remove it altogether.
Expand Down
2 changes: 1 addition & 1 deletion packages/rekor-types/hack/generate-rekor-types
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -ex

# Check-out Rekor repo
REF=4bb6f441c1b27ccc7e625c721c7d3203acc7b313
REF=576458cb53269ed54dccf8a43271ee02a785c191
REKOR_DIR=/tmp/rekor

rm -rf ${REKOR_DIR}
Expand Down
2 changes: 1 addition & 1 deletion packages/rekor-types/src/__generated__/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions packages/rekor-types/src/__generated__/intoto.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions packages/rekor-types/src/__generated__/models/RekorVersion.ts

This file was deleted.

11 changes: 11 additions & 0 deletions packages/rekor-types/src/__generated__/models/dsse.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.