ESM Conversion (#347)

* initial esm conversion

Signed-off-by: Brian DeHamer <[email protected]>

* esm'ify jest tests

Signed-off-by: Brian DeHamer <[email protected]>

* lint issues

Signed-off-by: Brian DeHamer <[email protected]>

* debug mock

Signed-off-by: Brian DeHamer <[email protected]>

* glob updated

Signed-off-by: Brian DeHamer <[email protected]>

* async all file functions

Signed-off-by: Brian DeHamer <[email protected]>

* update @actions/github

Signed-off-by: Brian DeHamer <[email protected]>

* update @actions/attest

Signed-off-by: Brian DeHamer <[email protected]>

* rebuild package-lock.json

Signed-off-by: Brian DeHamer <[email protected]>

* use experimental flag for jest in ci

Signed-off-by: Brian DeHamer <[email protected]>

* remove stray istanbul ignore

Signed-off-by: Brian DeHamer <[email protected]>

* Optimize getSubjectFromPath to avoid concurrent stat calls

Co-authored-by: bdehamer <[email protected]>

* Fix boundary condition for MAX_SUBJECT_COUNT check

Co-authored-by: bdehamer <[email protected]>

* Improve error message clarity for subject count limit

Co-authored-by: bdehamer <[email protected]>

* Update test to match new error message format

Co-authored-by: bdehamer <[email protected]>

* rebuild dist

Signed-off-by: Brian DeHamer <[email protected]>

* Fix parseSBOMFromPath to check file size before reading

Co-authored-by: bdehamer <[email protected]>

* Build package with updated changes

Co-authored-by: bdehamer <[email protected]>

---------

Signed-off-by: Brian DeHamer <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: bdehamer <[email protected]>
This commit is contained in:
Brian DeHamer
2026-02-18 08:52:30 -08:00
committed by GitHub
co-authored by bdehamer copilot-swe-agent[bot] <198982749+[email protected]>
parent dc4ad3cc6c
commit 7d7ff4475a
17 changed files with 39433 additions and 48804 deletions
+11 -5
View File
@@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'fs/promises'
import type { Predicate } from '@actions/attest'
@@ -12,7 +12,9 @@ const MAX_PREDICATE_SIZE_BYTES = 16 * 1024 * 1024
// Returns the predicate specified by the action's inputs. The predicate value
// may be specified as a path to a file or as a string.
export const predicateFromInputs = (inputs: PredicateInputs): Predicate => {
export const predicateFromInputs = async (
inputs: PredicateInputs
): Promise<Predicate> => {
const { predicateType, predicate, predicatePath } = inputs
if (!predicateType) {
@@ -30,18 +32,22 @@ export const predicateFromInputs = (inputs: PredicateInputs): Predicate => {
let params: string = predicate
if (predicatePath) {
if (!fs.existsSync(predicatePath)) {
try {
await fs.access(predicatePath)
} catch {
throw new Error(`predicate file not found: ${predicatePath}`)
}
const stat = await fs.stat(predicatePath)
/* istanbul ignore next */
if (fs.statSync(predicatePath).size > MAX_PREDICATE_SIZE_BYTES) {
if (stat.size > MAX_PREDICATE_SIZE_BYTES) {
throw new Error(
`predicate file exceeds maximum allowed size: ${MAX_PREDICATE_SIZE_BYTES} bytes`
)
}
params = fs.readFileSync(predicatePath, 'utf-8')
params = await fs.readFile(predicatePath, 'utf-8')
} else {
if (predicate.length > MAX_PREDICATE_SIZE_BYTES) {
throw new Error(