fixed pr
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -101,3 +101,5 @@ __tests__/runner/*
|
||||
.idea
|
||||
.vscode
|
||||
*.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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user