initial esm conversion
Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ describe('parseSBOMFromPath', () => {
|
||||
describe('when file does not exist', () => {
|
||||
it('throws an error', async () => {
|
||||
await expect(parseSBOMFromPath('/nonexistent/file.json')).rejects.toThrow(
|
||||
/SBOM file not found/
|
||||
/ENOENT/
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
+3
-5
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
exports.id = 606;
|
||||
exports.ids = [606];
|
||||
exports.modules = {
|
||||
export const id = 606;
|
||||
export const ids = [606];
|
||||
export const modules = {
|
||||
|
||||
/***/ 606:
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
@@ -298,4 +297,3 @@ const pMapSkip = Symbol('skip');
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
+1017
-1859
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+8
-1
@@ -4,6 +4,7 @@
|
||||
"version": "3.2.0",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/actions/attest",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -56,7 +57,13 @@
|
||||
"/dist/"
|
||||
],
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
"^.+\\.ts$": ["ts-jest", {
|
||||
"useESM": false,
|
||||
"tsconfig": {
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node"
|
||||
}
|
||||
}]
|
||||
},
|
||||
"coverageReporters": [
|
||||
"json-summary",
|
||||
|
||||
+2
-5
@@ -11,18 +11,15 @@ export type SBOM = {
|
||||
const MAX_SBOM_SIZE_BYTES = 16 * 1024 * 1024
|
||||
|
||||
export const parseSBOMFromPath = async (filePath: string): Promise<SBOM> => {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`SBOM file not found: ${filePath}`)
|
||||
}
|
||||
const fileContent = await fs.promises.readFile(filePath, 'utf8')
|
||||
|
||||
const stats = fs.statSync(filePath)
|
||||
const stats = await fs.promises.stat(filePath)
|
||||
if (stats.size > MAX_SBOM_SIZE_BYTES) {
|
||||
throw new Error(
|
||||
`SBOM file exceeds maximum allowed size: ${MAX_SBOM_SIZE_BYTES} bytes`
|
||||
)
|
||||
}
|
||||
|
||||
const fileContent = await fs.promises.readFile(filePath, 'utf8')
|
||||
const sbom = JSON.parse(fileContent) as object
|
||||
|
||||
if (checkIsSPDX(sbom)) {
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"module": "ESNext",
|
||||
"rootDir": "./src",
|
||||
"moduleResolution": "NodeNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"isolatedModules": true,
|
||||
"baseUrl": "./",
|
||||
"sourceMap": true,
|
||||
|
||||
Reference in New Issue
Block a user