fixed pr
This commit is contained in:
@@ -101,3 +101,5 @@ __tests__/runner/*
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
|
|
||||||
|
packages/**/dist
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -12,9 +12,9 @@ import {
|
|||||||
REKOR_PUBLIC_GOOD_URL,
|
REKOR_PUBLIC_GOOD_URL,
|
||||||
SEARCH_PUBLIC_GOOD_URL,
|
SEARCH_PUBLIC_GOOD_URL,
|
||||||
TSA_INTERNAL_URL
|
TSA_INTERNAL_URL
|
||||||
} from './helper/endpoints'
|
} from './endpoints'
|
||||||
import { predicateFromInputs } from './helper/predicate'
|
import { predicateFromInputs } from './predicate'
|
||||||
import { subjectFromInputs } from './helper/subject'
|
import { subjectFromInputs } from './subject'
|
||||||
|
|
||||||
type Endpoints = {
|
type Endpoints = {
|
||||||
fulcioURL: string
|
fulcioURL: string
|
||||||
|
|||||||
Reference in New Issue
Block a user