Compare commits
16 Commits
v2
...
predicate@
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55e972012f | ||
|
|
c2dd1df1ec | ||
|
|
87ab9bb01b | ||
|
|
24900ce153 | ||
|
|
484c81f0bd | ||
|
|
eec1ec9904 | ||
|
|
b06100ab07 | ||
|
|
ccb8edd7db | ||
|
|
9a005994da | ||
|
|
57a8b1e21b | ||
|
|
0d73e3f2be | ||
|
|
2548367d4f | ||
|
|
f4e8bae046 | ||
|
|
0486c4aa49 | ||
|
|
e9b2cefbdf | ||
|
|
45bb4038a3 |
10
.github/linters/.yaml-lint.yml
vendored
10
.github/linters/.yaml-lint.yml
vendored
@@ -1,10 +0,0 @@
|
|||||||
rules:
|
|
||||||
document-end: disable
|
|
||||||
document-start:
|
|
||||||
level: warning
|
|
||||||
present: false
|
|
||||||
line-length:
|
|
||||||
level: warning
|
|
||||||
max: 80
|
|
||||||
allow-non-breakable-words: true
|
|
||||||
allow-non-breakable-inline-mappings: true
|
|
||||||
9
.github/linters/tsconfig.json
vendored
9
.github/linters/tsconfig.json
vendored
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"extends": "../../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"noEmit": true
|
|
||||||
},
|
|
||||||
"include": ["../../__tests__/**/*", "../../src/**/*"],
|
|
||||||
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
|
|
||||||
}
|
|
||||||
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -28,11 +28,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
id: setup-node
|
id: setup-node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version-file: .node-version
|
node-version-file: .node-version
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
|
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
|
||||||
name: Upload Artifact
|
name: Upload Artifact
|
||||||
id: upload
|
id: upload
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist/
|
path: dist/
|
||||||
|
|||||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -21,11 +21,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
id: setup-node
|
id: setup-node
|
||||||
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version-file: .node-version
|
node-version-file: .node-version
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
- name: Run attest-sbom
|
- name: Run attest-sbom
|
||||||
id: attest-sbom
|
id: attest-sbom
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -32,19 +32,19 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
id: initialize
|
id: initialize
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@df559355d593797519d70b90fc8edd5db049e7a2 # v3.29.9
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
source-root: src
|
source-root: src
|
||||||
|
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
id: autobuild
|
id: autobuild
|
||||||
uses: github/codeql-action/autobuild@v3
|
uses: github/codeql-action/autobuild@df559355d593797519d70b90fc8edd5db049e7a2 # v3.29.9
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
id: analyze
|
id: analyze
|
||||||
uses: github/codeql-action/analyze@v3
|
uses: github/codeql-action/analyze@df559355d593797519d70b90fc8edd5db049e7a2 # v3.29.9
|
||||||
|
|||||||
54
.github/workflows/linter.yml
vendored
54
.github/workflows/linter.yml
vendored
@@ -1,54 +0,0 @@
|
|||||||
name: Lint Codebase
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: read
|
|
||||||
statuses: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint Codebase
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
id: checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
id: setup-node
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version-file: .node-version
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
id: install
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Lint Codebase
|
|
||||||
id: super-linter
|
|
||||||
uses: super-linter/super-linter/slim@12150456a73e248bdc94d0794898f94e23127c88 # v7.4.0
|
|
||||||
env:
|
|
||||||
DEFAULT_BRANCH: main
|
|
||||||
FILTER_REGEX_EXCLUDE: dist/**/*
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TYPESCRIPT_DEFAULT_STYLE: prettier
|
|
||||||
VALIDATE_ALL_CODEBASE: true
|
|
||||||
VALIDATE_JAVASCRIPT_STANDARD: false
|
|
||||||
VALIDATE_TYPESCRIPT_ES: false
|
|
||||||
VALIDATE_TYPESCRIPT_STANDARD: false
|
|
||||||
VALIDATE_JSCPD: false
|
|
||||||
|
|
||||||
- name: Run eslint
|
|
||||||
run: npm run lint:eslint
|
|
||||||
22
.github/workflows/publish-immutable-actions.yml
vendored
22
.github/workflows/publish-immutable-actions.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
name: 'Publish Immutable Action Version'
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checking out
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Publish
|
|
||||||
id: publish
|
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
|
||||||
@@ -1 +1 @@
|
|||||||
20.6.0
|
24.5.0
|
||||||
|
|||||||
@@ -108,6 +108,13 @@ describe('generateSBOMPredicate', () => {
|
|||||||
expect(result.params).toEqual(sbom.object)
|
expect(result.params).toEqual(sbom.object)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('throws an error for missing SPDX version', () => {
|
||||||
|
const sbom = { type: 'spdx' } as SBOM
|
||||||
|
expect(() => generateSBOMPredicate(sbom)).toThrow(
|
||||||
|
'Cannot find spdxVersion in the SBOM'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('generates CycloneDX predicate correctly', () => {
|
it('generates CycloneDX predicate correctly', () => {
|
||||||
const sbom = { type: 'cyclonedx', object: {} } as SBOM
|
const sbom = { type: 'cyclonedx', object: {} } as SBOM
|
||||||
const result = generateSBOMPredicate(sbom)
|
const result = generateSBOMPredicate(sbom)
|
||||||
@@ -116,10 +123,8 @@ describe('generateSBOMPredicate', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws error for unsupported SBOM formats', () => {
|
it('throws error for unsupported SBOM formats', () => {
|
||||||
const sbom = { type: 'spdx', object: {} }
|
const sbom = { type: 'foo', object: {} }
|
||||||
// @ts-expect-error test error case
|
// @ts-expect-error test error case
|
||||||
expect(() => generateSBOMPredicate(sbom)).toThrow(
|
expect(() => generateSBOMPredicate(sbom)).toThrow('Unsupported SBOM format')
|
||||||
'Cannot find spdxVersion in the SBOM'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -71,8 +71,10 @@ runs:
|
|||||||
id: generate-sbom-predicate
|
id: generate-sbom-predicate
|
||||||
with:
|
with:
|
||||||
sbom-path: ${{ inputs.sbom-path }}
|
sbom-path: ${{ inputs.sbom-path }}
|
||||||
- uses: actions/attest@ce27ba3b4a9a139d9a20a4a07d69fabb52f1e5bc # v2.4.0
|
- uses: actions/attest@daf44fb950173508f38bd2406030372c1d1162b1 # v3.0.0
|
||||||
id: attest
|
id: attest
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: '--max-http-header-size=32768'
|
||||||
with:
|
with:
|
||||||
subject-path: ${{ inputs.subject-path }}
|
subject-path: ${{ inputs.subject-path }}
|
||||||
subject-digest: ${{ inputs.subject-digest }}
|
subject-digest: ${{ inputs.subject-digest }}
|
||||||
|
|||||||
9
dist/index.js
generated
vendored
9
dist/index.js
generated
vendored
@@ -25800,13 +25800,14 @@ const storePredicate = (predicate) => {
|
|||||||
};
|
};
|
||||||
exports.storePredicate = storePredicate;
|
exports.storePredicate = storePredicate;
|
||||||
const generateSBOMPredicate = (sbom) => {
|
const generateSBOMPredicate = (sbom) => {
|
||||||
if (sbom.type === 'spdx') {
|
switch (sbom.type) {
|
||||||
|
case 'spdx':
|
||||||
return generateSPDXIntoto(sbom.object);
|
return generateSPDXIntoto(sbom.object);
|
||||||
}
|
case 'cyclonedx':
|
||||||
if (sbom.type === 'cyclonedx') {
|
|
||||||
return generateCycloneDXIntoto(sbom.object);
|
return generateCycloneDXIntoto(sbom.object);
|
||||||
}
|
default:
|
||||||
throw new Error('Unsupported SBOM format');
|
throw new Error('Unsupported SBOM format');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
exports.generateSBOMPredicate = generateSBOMPredicate;
|
exports.generateSBOMPredicate = generateSBOMPredicate;
|
||||||
// ref: https://github.com/in-toto/attestation/blob/main/spec/predicates/spdx.md
|
// ref: https://github.com/in-toto/attestation/blob/main/spec/predicates/spdx.md
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default tseslint.config(
|
|||||||
// Ignore non-project files
|
// Ignore non-project files
|
||||||
{
|
{
|
||||||
name: 'ignore',
|
name: 'ignore',
|
||||||
ignores: ['.github', 'dist', 'coverage', '**/*.json', 'jest.setup.js']
|
ignores: ['.github', 'dist', 'coverage', '**/*.json', 'jest.setup.js', 'eslint.config.mjs']
|
||||||
},
|
},
|
||||||
// Use recommended rules from ESLint, TypeScript, and other plugins
|
// Use recommended rules from ESLint, TypeScript, and other plugins
|
||||||
eslint.configs.recommended,
|
eslint.configs.recommended,
|
||||||
@@ -21,7 +21,7 @@ export default tseslint.config(
|
|||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: 2023,
|
ecmaVersion: 2023,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: ['./.github/linters/tsconfig.json', './tsconfig.json']
|
project: ['./tsconfig.lint.json']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
3861
package-lock.json
generated
3861
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "actions/attest-sbom",
|
"name": "actions/attest-sbom",
|
||||||
"description": "Generate signed SBOM attestations",
|
"description": "Generate signed SBOM attestations",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://github.com/actions/attest-sbom",
|
"homepage": "https://github.com/actions/attest-sbom",
|
||||||
@@ -21,15 +21,15 @@
|
|||||||
".": "./dist/index.js"
|
".": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=24"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bundle": "npm run format:write && npm run package",
|
"bundle": "npm run format:write && npm run package",
|
||||||
"ci-test": "jest",
|
"ci-test": "jest",
|
||||||
"format:write": "prettier --write **/*.ts",
|
"format:write": "prettier --write **/*.ts",
|
||||||
"format:check": "prettier --check **/*.ts",
|
"format:check": "prettier --check **/*.ts",
|
||||||
"lint:eslint": "npx eslint . -c ./.github/linters/eslint.config.mjs",
|
"lint:eslint": "npx eslint",
|
||||||
"lint:markdown": "npx markdownlint --config .github/linters/.markdown-lint.yml \"*.md\"",
|
"lint:markdown": "npx markdownlint --config .markdown-lint.yml \"*.md\"",
|
||||||
"lint": "npm run lint:eslint && npm run lint:markdown",
|
"lint": "npm run lint:eslint && npm run lint:markdown",
|
||||||
"package": "ncc build src/index.ts --license licenses.txt",
|
"package": "ncc build src/index.ts --license licenses.txt",
|
||||||
"package:watch": "npm run package -- --watch",
|
"package:watch": "npm run package -- --watch",
|
||||||
@@ -74,18 +74,18 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/attest": "^1.6.0",
|
"@actions/attest": "^1.6.0",
|
||||||
"@eslint/js": "^9.28.0",
|
"@eslint/js": "^9.34.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/node": "^22.15.29",
|
"@types/node": "^24.3.0",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.34.0",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest": "^28.12.0",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^30.1.1",
|
||||||
"markdownlint-cli": "^0.45.0",
|
"markdownlint-cli": "^0.45.0",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.6.2",
|
||||||
"ts-jest": "^29.3.4",
|
"ts-jest": "^29.4.1",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.9.2",
|
||||||
"typescript-eslint": "^8.33.0"
|
"typescript-eslint": "^8.41.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ outputs:
|
|||||||
description: >
|
description: >
|
||||||
URI identifying the type of the predicate.
|
URI identifying the type of the predicate.
|
||||||
runs:
|
runs:
|
||||||
using: node20
|
using: node24
|
||||||
main: ../dist/index.js
|
main: ../dist/index.js
|
||||||
|
|||||||
@@ -66,13 +66,14 @@ export const storePredicate = (predicate: Predicate): string => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const generateSBOMPredicate = (sbom: SBOM): Predicate => {
|
export const generateSBOMPredicate = (sbom: SBOM): Predicate => {
|
||||||
if (sbom.type === 'spdx') {
|
switch (sbom.type) {
|
||||||
|
case 'spdx':
|
||||||
return generateSPDXIntoto(sbom.object)
|
return generateSPDXIntoto(sbom.object)
|
||||||
}
|
case 'cyclonedx':
|
||||||
if (sbom.type === 'cyclonedx') {
|
|
||||||
return generateCycloneDXIntoto(sbom.object)
|
return generateCycloneDXIntoto(sbom.object)
|
||||||
}
|
default:
|
||||||
throw new Error('Unsupported SBOM format')
|
throw new Error('Unsupported SBOM format')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ref: https://github.com/in-toto/attestation/blob/main/spec/predicates/spdx.md
|
// ref: https://github.com/in-toto/attestation/blob/main/spec/predicates/spdx.md
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"isolatedModules": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
|
|||||||
9
tsconfig.lint.json
Normal file
9
tsconfig.lint.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"noEmit": true
|
||||||
|
},
|
||||||
|
"include": ["./__tests__/**/*", "./src/**/*"],
|
||||||
|
"exclude": ["./dist", "./node_modules", "./coverage", "*.json"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user