This commit is contained in:
ejahnGithub
2024-02-23 08:41:44 -08:00
parent a801b62e6f
commit d83c83490f
6 changed files with 5 additions and 46 deletions

2
.gitignore vendored
View File

@@ -101,3 +101,5 @@ __tests__/runner/*
.idea
.vscode
*.code-workspace
packages/**/dist

View File

@@ -1,43 +0,0 @@
import fs from 'fs'
import { SBOM } from '@actions/attest'
export async function parseSBOMFromPath(path: string): Promise<SBOM> {
// Read the file content
const fileContent = await fs.promises.readFile(path, 'utf8')
const sbom = JSON.parse(fileContent)
if (checkIsSPDX(sbom)) {
return { type: 'spdx', object: sbom }
} else if (checkIsCycloneDX(sbom)) {
return { type: 'cyclonedx', object: sbom }
}
throw new Error('Unsupported SBOM format')
}
function checkIsSPDX(sbomObject: {
spdxVersion?: string
SPDXID?: string
}): boolean {
if (sbomObject?.spdxVersion && sbomObject?.SPDXID) {
return true
} else {
return false
}
}
function checkIsCycloneDX(sbomObject: {
bomFormat?: string
serialNumber?: string
specVersion?: string
}): boolean {
if (
sbomObject?.bomFormat &&
sbomObject?.serialNumber &&
sbomObject?.specVersion
) {
return true
} else {
return false
}
}

View File

@@ -12,9 +12,9 @@ import {
REKOR_PUBLIC_GOOD_URL,
SEARCH_PUBLIC_GOOD_URL,
TSA_INTERNAL_URL
} from './helper/endpoints'
import { predicateFromInputs } from './helper/predicate'
import { subjectFromInputs } from './helper/subject'
} from './endpoints'
import { predicateFromInputs } from './predicate'
import { subjectFromInputs } from './subject'
type Endpoints = {
fulcioURL: string