Skip to content

Commit

Permalink
Merge pull request #1487 from DataDog/tdubey/STAL-3069/specify-missin…
Browse files Browse the repository at this point in the history
…g-fields

Remove git checks in SBOM payload generation
  • Loading branch information
tanishq-dubey authored Nov 18, 2024
2 parents f624731 + f063dd5 commit ae9ebab
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/commands/sbom/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ export const generatePayload = (
service: string,
env: string
): ScaRequest | undefined => {
if (
!tags[GIT_COMMIT_AUTHOR_EMAIL] ||
!tags[GIT_COMMIT_AUTHOR_NAME] ||
!tags[GIT_COMMIT_COMMITTER_EMAIL] ||
!tags[GIT_COMMIT_COMMITTER_NAME] ||
!tags[GIT_SHA] ||
!tags[GIT_BRANCH] ||
!tags[GIT_REPOSITORY_URL]
) {
return undefined
}

const dependencies: Dependency[] = []
const files: File[] = []
const relations: Relations[] = []
Expand Down Expand Up @@ -135,18 +123,20 @@ export const generatePayload = (
}
}

// The tags dictionary is validated prior to generatePayload being called
// see upload.ts missingGitFields
return {
id: crypto.randomUUID(),
commit: {
author_name: tags[GIT_COMMIT_AUTHOR_NAME],
author_email: tags[GIT_COMMIT_AUTHOR_EMAIL],
committer_name: tags[GIT_COMMIT_COMMITTER_NAME],
committer_email: tags[GIT_COMMIT_COMMITTER_EMAIL],
sha: tags[GIT_SHA],
branch: tags[GIT_BRANCH],
author_name: tags[GIT_COMMIT_AUTHOR_NAME] ?? '',
author_email: tags[GIT_COMMIT_AUTHOR_EMAIL] ?? '',
committer_name: tags[GIT_COMMIT_COMMITTER_NAME] ?? '',
committer_email: tags[GIT_COMMIT_COMMITTER_EMAIL] ?? '',
sha: tags[GIT_SHA] ?? '',
branch: tags[GIT_BRANCH] ?? '',
},
repository: {
url: tags[GIT_REPOSITORY_URL],
url: tags[GIT_REPOSITORY_URL] ?? '',
},
tags,
dependencies,
Expand Down

0 comments on commit ae9ebab

Please sign in to comment.