Compare commits

..
Author SHA1 Message Date
Leyla Azizova 907a6e9569 Merge pull request #1173 from actions/dependabot/npm_and_yarn/handlebars-4.7.10
Bump handlebars from 4.7.9 to 4.7.10
2026-10-16 09:37:24 -07:00
dependabot[bot] f4fc8069af Bump handlebars from 4.7.9 to 4.7.10
Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.9 to 4.7.10.
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.10/release-notes.md)
- [Commits](https://github.com/handlebars-lang/handlebars.js/compare/v4.7.9...v4.7.10)

---
updated-dependencies:
- dependency-name: handlebars
  dependency-version: 4.7.10
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-16 16:29:27 +00:00
Leyla Azizova c15ec0f451 Merge pull request #1165 from actions/dependabot/npm_and_yarn/brace-expansion-2.1.7
Bump brace-expansion from 2.1.4 to 2.1.7
2026-10-16 09:27:58 -07:00
dependabot[bot] 72aaca2ab0 Bump brace-expansion from 2.1.4 to 2.1.7
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 2.1.4 to 2.1.7.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v2.1.4...v2.1.7)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 2.1.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-30 20:08:23 +00:00
Kevin Dangoor 2f920dad77 Merge pull request #1162 from actions/dependabot/npm_and_yarn/undici-6.29.0
Bump undici from 6.28.0 to 6.29.0
2026-09-30 16:07:56 -04:00
Kevin Dangoor 46b39ef136 Merge pull request #1163 from actions/dependabot/npm_and_yarn/js-yaml-5.4.2
Bump js-yaml from 3.14.2 to 5.4.2
2026-09-30 16:07:05 -04:00
dependabot[bot] 41184d6995 Bump js-yaml from 3.14.2 to 5.4.2
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.14.2 to 5.4.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.14.2...5.4.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 5.4.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-30 18:48:02 +00:00
dependabot[bot] 108c8ecde0 Bump undici from 6.28.0 to 6.29.0
Bumps [undici](https://github.com/nodejs/undici) from 6.28.0 to 6.29.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.28.0...v6.29.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.29.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-29 04:37:15 +00:00
Kevin Dangoor 5dd1a81845 Merge pull request #1155 from actions/dependabot/npm_and_yarn/js-yaml-5.4.1
Bump js-yaml from 4.3.1 to 5.4.1
2026-09-28 16:26:01 -04:00
dependabot[bot] a1f042c02b Bump js-yaml from 4.3.1 to 5.4.1
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.3.1 to 5.4.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.3.1...5.4.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 5.4.1
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-10 01:43:37 +00:00
Eric Sorenson 284c089a1c Merge pull request #1150 from actions/dependabot/npm_and_yarn/typescript-eslint/parser-8.68.0
Bump @typescript-eslint/parser from 6.21.0 to 8.69.0
2026-09-04 17:06:53 -07:00
Eric SorensonandCopilot ba5451defb Merge upstream main into Dependabot branch
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-04 15:26:49 -07:00
Eric SorensonandCopilot ecb589c3c7 Resolve TypeScript ESLint dependency conflicts
Align the parser and plugin on v8, migrate removed lint rules, and constrain transitive overrides to compatible major versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-04 15:25:50 -07:00
Eric Sorenson cc619a78a7 Merge pull request #941 from sgmurphy/update-pr-comment
Update PR comment behavior for `on-failure` mode
2026-09-04 13:54:08 -07:00
dependabot[bot] 0cf05d1048 Bump @typescript-eslint/parser from 6.21.0 to 8.69.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.21.0 to 8.69.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.69.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-version: 8.68.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-04 20:47:09 +00:00
Eric Sorenson 478e8f1efb Merge pull request #1149 from actions/dependabot/github_actions/github/codeql-action-4.37.9
Bump github/codeql-action from 4.37.1 to 4.37.9
2026-09-04 13:45:42 -07:00
Eric Sorenson 799981d143 Merge pull request #1148 from actions/dependabot/npm_and_yarn/eslint-plugin-jest-29.16.6
Bump eslint-plugin-jest from 28.8.3 to 29.16.6
2026-09-04 13:45:32 -07:00
Eric Sorenson 8725015b0b Merge pull request #1147 from actions/dependabot/npm_and_yarn/minor-updates-3828aecea6
Bump the minor-updates group with 4 updates
2026-09-04 13:45:24 -07:00
Eric Sorenson 24f1d4c629 Merge pull request #1146 from actions/dependabot/npm_and_yarn/browserslist-4.28.8
Bump browserslist from 4.22.1 to 4.28.8
2026-09-04 13:45:16 -07:00
Eric Sorenson 2bb8ee2515 Merge pull request #1139 from actions/dependabot/npm_and_yarn/brace-expansion-5.0.9
Bump brace-expansion from 5.0.6 to 5.0.9
2026-09-04 13:45:08 -07:00
dependabot[bot] c8d6df912a Bump github/codeql-action from 4.37.1 to 4.37.9
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.37.1 to 4.37.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v4.37.1...v4.37.9)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.37.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 01:43:55 +00:00
dependabot[bot] 0c0e1d27cd Bump eslint-plugin-jest from 28.8.3 to 29.16.6
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 28.8.3 to 29.16.6.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v28.8.3...v29.16.6)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-version: 29.16.6
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 01:43:34 +00:00
dependabot[bot] f28a2efbc7 Bump the minor-updates group with 4 updates
Bumps the minor-updates group with 4 updates: [ts-jest](https://github.com/kulshekhar/ts-jest), [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [@vercel/ncc](https://github.com/vercel/ncc) and [prettier](https://github.com/prettier/prettier).


Updates `ts-jest` from 29.4.11 to 29.4.12
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.4.11...v29.4.12)

Updates `@types/node` from 24.13.2 to 24.13.3
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `@vercel/ncc` from 0.44.0 to 0.45.0
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.44.0...0.45.0)

Updates `prettier` from 3.8.4 to 3.9.6
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.8.4...3.9.6)

---
updated-dependencies:
- dependency-name: ts-jest
  dependency-version: 29.4.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: "@types/node"
  dependency-version: 24.13.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-updates
- dependency-name: "@vercel/ncc"
  dependency-version: 0.45.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
- dependency-name: prettier
  dependency-version: 3.9.6
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-updates
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 01:43:21 +00:00
dependabot[bot] 2a5c32fe65 Bump browserslist from 4.22.1 to 4.28.8
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.22.1 to 4.28.8.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.22.1...4.28.8)

---
updated-dependencies:
- dependency-name: browserslist
  dependency-version: 4.28.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-03 01:43:15 +00:00
dependabot[bot] 9538e6e31c Bump the spdx-licenses group across 1 directory with 2 updates (#1133)
Bumps the spdx-licenses group with 2 updates in the / directory: [spdx-expression-parse](https://github.com/jslicense/spdx-expression-parse.js) and [@types/spdx-expression-parse](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/spdx-expression-parse).


Updates `spdx-expression-parse` from 4.0.0 to 5.0.0
- [Commits](https://github.com/jslicense/spdx-expression-parse.js/compare/v4.0.0...v5.0.0)

Updates `@types/spdx-expression-parse` from 3.0.5 to 4.0.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/spdx-expression-parse)

---
updated-dependencies:
- dependency-name: spdx-expression-parse
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: spdx-licenses
- dependency-name: "@types/spdx-expression-parse"
  dependency-version: 4.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: spdx-licenses
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:16:27 -04:00
dependabot[bot] aae4911372 Bump github/codeql-action from 4 to 4.37.1 (#1134)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4 to 4.37.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v4...v4.37.1)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:15:39 -04:00
dependabot[bot] 57b6663b1e Bump esbuild from 0.25.0 to 0.28.1 (#1116)
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.25.0 to 0.28.1.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2025.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.25.0...v0.28.1)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.28.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:15:13 -04:00
dependabot[bot] ab7c86dd7d Bump actions/setup-node from 6 to 7 (#1129)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:13:36 -04:00
dependabot[bot] a8e96f5b76 Bump actions/stale from 10.2.0 to 11.0.0 (#1138)
Bumps [actions/stale](https://github.com/actions/stale) from 10.2.0 to 11.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v10.2.0...v11.0.0)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: 11.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:13:00 -04:00
dependabot[bot] 2cb914636e Bump js-yaml from 4.1.1 to 4.3.1 (#1141)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.3.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.1/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.1...4.3.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-01 11:12:18 -04:00
dependabot[bot] f9d8e93c20 Bump brace-expansion from 5.0.6 to 5.0.9
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 5.0.6 to 5.0.9.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v5.0.6...v5.0.9)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 5.0.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 04:32:41 +00:00
Sean Murphy c2b21dcd2e Merge pull request #3 from niebloomj/resolve-main-conflicts
Resolve merge conflicts with actions/main
2026-05-11 15:59:19 -04:00
Jacob Niebloom d6742e69a4 Add show_patched_versions to test mock; regenerate dist 2026-05-11 13:38:32 -04:00
Jacob Niebloom 1489879da3 Merge upstream/main to resolve conflicts 2026-05-11 13:22:01 -04:00
Sean Murphy cc905d3f06 Merge branch 'main' into update-pr-comment 2025-08-01 21:24:39 -04:00
Sean Murphy f21eb50a0c Update PR comment behavior for on-failure mode
When comment_summary_in_pr is set to 'on-failure', the action now updates
existing comments when issues are resolved in subsequent runs, providing
clear feedback that dependency issues have been fixed.
2025-06-17 16:08:58 -04:00
16 changed files with 1051 additions and 478 deletions

No files matched your search

+2 -4
View File
@@ -28,7 +28,7 @@
"error",
{"allowExpressions": true}
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
@@ -49,9 +49,7 @@
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"semi": ["error", "never"],
"@typescript-eslint/unbound-method": "error"
},
"env": {
+2 -2
View File
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
@@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
+2 -2
View File
@@ -28,7 +28,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
uses: github/codeql-action/init@v4.37.9
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -43,6 +43,6 @@ jobs:
- dist/sourcemap-register.js
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
uses: github/codeql-action/analyze@v4.37.9
with:
category: "/language:${{matrix.language}}"
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10.2.0
- uses: actions/stale@v11.0.0
name: Clean up stale PRs and Issues
with:
stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity for 180 days. You can: comment on the PR or remove the stale label to hold stalebot off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing, this pull request will be closed eventually by the stalebot. Please see CONTRIBUTING.md for more policy details."
+231
View File
@@ -0,0 +1,231 @@
import {expect, test, beforeEach} from '@jest/globals'
// Mock GitHub Actions modules before importing anything else
jest.mock('@actions/github')
jest.mock('@actions/core')
// Create mocks that will be available throughout the module
const createCommentMock = jest.fn()
const updateCommentMock = jest.fn()
const listCommentsMock = jest.fn()
const paginateIteratorMock = jest.fn()
// Mock the octokit instance creation
jest.mock('@actions/github/lib/utils', () => ({
GitHub: {
plugin: jest.fn(() =>
jest.fn(() => ({
rest: {
issues: {
createComment: createCommentMock,
updateComment: updateCommentMock,
listComments: listCommentsMock
}
},
paginate: {
iterator: paginateIteratorMock
}
}))
)
},
getOctokitOptions: jest.fn(() => ({}))
}))
jest.mock('@octokit/plugin-retry', () => ({
retry: {}
}))
// Now import the modules that use the mocks
import {commentPr} from '../src/comment-pr'
import {ConfigurationOptions} from '../src/schemas'
import * as github from '@actions/github'
import * as core from '@actions/core'
const mockGithub = github as jest.Mocked<typeof github>
const mockCore = core as jest.Mocked<typeof core>
const defaultConfig: ConfigurationOptions = {
comment_summary_in_pr: 'on-failure',
fail_on_severity: 'high',
fail_on_scopes: ['runtime'],
allow_licenses: [],
deny_licenses: [],
allow_dependencies_licenses: [],
allow_ghsas: [],
license_check: true,
vulnerability_check: true,
warn_only: false,
show_openssf_scorecard: false,
warn_on_openssf_scorecard_level: 3,
retry_on_snapshot_warnings: false,
retry_on_snapshot_warnings_timeout: 120,
show_patched_versions: false,
base_ref: '',
head_ref: '',
deny_packages: [],
deny_groups: []
}
beforeEach(() => {
jest.clearAllMocks()
// Setup GitHub context
Object.defineProperty(mockGithub, 'context', {
value: {
repo: {owner: 'test-owner', repo: 'test-repo'},
payload: {pull_request: {number: 123}}
},
writable: true
})
mockCore.getInput.mockReturnValue('mock-token')
// Setup default mock returns
createCommentMock.mockResolvedValue({data: {id: 1}})
updateCommentMock.mockResolvedValue({data: {id: 1}})
listCommentsMock.mockResolvedValue({data: []})
paginateIteratorMock.mockReturnValue([{data: []}])
})
test('commentPr creates comment in always mode regardless of issues', async () => {
const config = {...defaultConfig, comment_summary_in_pr: 'always' as const}
await commentPr('Test content', config, false)
expect(createCommentMock).toHaveBeenCalledWith({
owner: 'test-owner',
repo: 'test-repo',
issue_number: 123,
body: 'Test content\n\n<!-- dependency-review-pr-comment-marker -->'
})
expect(updateCommentMock).not.toHaveBeenCalled()
})
test('commentPr creates comment in on-failure mode when issues found', async () => {
const config = {
...defaultConfig,
comment_summary_in_pr: 'on-failure' as const
}
await commentPr('Issues found', config, true)
expect(createCommentMock).toHaveBeenCalledWith({
owner: 'test-owner',
repo: 'test-repo',
issue_number: 123,
body: 'Issues found\n\n<!-- dependency-review-pr-comment-marker -->'
})
expect(updateCommentMock).not.toHaveBeenCalled()
})
test('commentPr does not comment in never mode', async () => {
const config = {...defaultConfig, comment_summary_in_pr: 'never' as const}
await commentPr('Test content', config, false)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).not.toHaveBeenCalled()
})
test('commentPr does not comment in on-failure mode when no issues and no existing comment', async () => {
const config = {
...defaultConfig,
comment_summary_in_pr: 'on-failure' as const
}
await commentPr('No issues', config, false)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).not.toHaveBeenCalled()
})
test('commentPr updates existing comment in on-failure mode when no issues but comment exists', async () => {
const config = {
...defaultConfig,
comment_summary_in_pr: 'on-failure' as const
}
// Mock existing comment
const existingComment = {
id: 456,
body: 'Previous issues\n\n<!-- dependency-review-pr-comment-marker -->'
}
paginateIteratorMock.mockReturnValue([{data: [existingComment]}])
await commentPr('Issues resolved', config, false)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).toHaveBeenCalledWith({
owner: 'test-owner',
repo: 'test-repo',
comment_id: 456,
body: 'Issues resolved\n\n<!-- dependency-review-pr-comment-marker -->'
})
})
test('commentPr updates existing comment instead of creating new one in always mode', async () => {
const config = {...defaultConfig, comment_summary_in_pr: 'always' as const}
// Mock existing comment
const existingComment = {
id: 789,
body: 'Old content\n\n<!-- dependency-review-pr-comment-marker -->'
}
paginateIteratorMock.mockReturnValue([{data: [existingComment]}])
await commentPr('Updated content', config, false)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).toHaveBeenCalledWith({
owner: 'test-owner',
repo: 'test-repo',
comment_id: 789,
body: 'Updated content\n\n<!-- dependency-review-pr-comment-marker -->'
})
})
test('commentPr finds comment marker among multiple comments', async () => {
const config = {...defaultConfig, comment_summary_in_pr: 'always' as const}
// Mock multiple comments with marker in the middle
const comments = [
{id: 1, body: 'Regular comment'},
{id: 2, body: 'Another comment'},
{
id: 3,
body: 'Target comment\n\n<!-- dependency-review-pr-comment-marker -->'
},
{id: 4, body: 'Last comment'}
]
paginateIteratorMock.mockReturnValue([{data: comments}])
await commentPr('Updated content', config, false)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).toHaveBeenCalledWith({
owner: 'test-owner',
repo: 'test-repo',
comment_id: 3,
body: 'Updated content\n\n<!-- dependency-review-pr-comment-marker -->'
})
})
test('commentPr handles non-PR context gracefully', async () => {
Object.defineProperty(mockGithub, 'context', {
value: {
repo: {owner: 'test-owner', repo: 'test-repo'},
payload: {}
},
writable: true
})
const config = {...defaultConfig, comment_summary_in_pr: 'always' as const}
await commentPr('Test content', config, false)
expect(mockCore.warning).toHaveBeenCalledWith(
'Not in the context of a pull request. Skipping comment creation.'
)
expect(createCommentMock).not.toHaveBeenCalled()
expect(updateCommentMock).not.toHaveBeenCalled()
})
-48
View File
@@ -390,51 +390,3 @@ describe('GH License API fallback', () => {
expect(unlicensed.length).toEqual(1)
})
})
describe('manifest/lock file license deduplication', () => {
const manifestChange: Change = {
change_type: 'added',
manifest: 'pyproject.toml',
ecosystem: 'pip',
name: 'pydantic',
version: '^ 2.11.0',
package_url: 'pkg:pypi/pydantic',
license: null,
source_repository_url: null,
scope: 'runtime',
vulnerabilities: []
}
const lockChange: Change = {
...manifestChange,
manifest: 'poetry.lock',
version: '2.11.0',
package_url: 'pkg:pypi/pydantic@2.11.0',
license: 'MIT'
}
test('does not flag an unlicensed manifest entry when a licensed lock entry exists', async () => {
const {unlicensed} = await getInvalidLicenseChanges(
[manifestChange, lockChange],
{}
)
expect(mockOctokit.rest.licenses.getForRepo).not.toHaveBeenCalled()
expect(unlicensed.length).toEqual(0)
})
test('still flags an unlicensed manifest entry when there is no licensed counterpart', async () => {
const {unlicensed} = await getInvalidLicenseChanges([manifestChange], {})
expect(unlicensed.length).toEqual(1)
})
test('does not deduplicate across differing change_types', async () => {
const {unlicensed} = await getInvalidLicenseChanges(
[manifestChange, {...lockChange, change_type: 'removed'}],
{}
)
expect(unlicensed.length).toEqual(1)
})
})
Generated Vendored
+18 -2
View File
@@ -70,8 +70,15 @@ const octo = new retryingOctokit(githubUtils.getOctokitOptions(core.getInput('re
const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->';
function commentPr(commentContent, config, issueFound) {
return __awaiter(this, void 0, void 0, function* () {
if (!(config.comment_summary_in_pr === 'always' ||
(config.comment_summary_in_pr === 'on-failure' && issueFound))) {
// For 'on-failure' mode, we need to handle both failure and success cases
// - On failure: create/update comment with issues
// - On success: update existing comment to show resolution (if one exists)
const shouldComment = config.comment_summary_in_pr === 'always' ||
(config.comment_summary_in_pr === 'on-failure' && issueFound) ||
(config.comment_summary_in_pr === 'on-failure' &&
!issueFound &&
(yield hasExistingComment()));
if (!shouldComment) {
return;
}
if (!github.context.payload.pull_request) {
@@ -113,6 +120,15 @@ function commentPr(commentContent, config, issueFound) {
}
});
}
function hasExistingComment() {
return __awaiter(this, void 0, void 0, function* () {
if (!github.context.payload.pull_request) {
return false;
}
const existingCommentId = yield findCommentByMarker(COMMENT_MARKER);
return existingCommentId !== undefined;
});
}
function findCommentByMarker(commentBodyIncludes) {
return __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
Generated Vendored
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.js","mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACzIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;AC1EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;AC3NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACALine truncated
{"version":3,"file":"index.js","mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACzJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;AC1EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;AC3NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACALine truncated
+747 -337
View File
File diff suppressed because it is too large. Load diff
+14 -12
View File
@@ -37,33 +37,35 @@
"jest": "^29.7.0",
"octokit": "^3.1.2",
"semver": "^7.8.5",
"spdx-expression-parse": "^4.0.0",
"spdx-expression-parse": "^5.0.0",
"spdx-satisfies": "^6.0.0",
"ts-jest": "^29.4.11",
"ts-jest": "^29.4.12",
"yaml": "^2.9.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^24",
"@types/spdx-expression-parse": "^3.0.4",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vercel/ncc": "^0.44.0",
"@types/semver": "^7.8.0",
"@types/spdx-expression-parse": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^8.68.0",
"@typescript-eslint/parser": "^8.68.0",
"@vercel/ncc": "^0.45.0",
"esbuild-register": "^3.6.0",
"eslint": "^8.57.0",
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest": "29.16.5",
"eslint-plugin-prettier": "^5.5.6",
"js-yaml": "^4.1.1",
"js-yaml": "^5.4.1",
"nodemon": "^3.1.14",
"prettier": "3.8.4",
"prettier": "3.9.6",
"typescript": "^5.9.2"
},
"overrides": {
"cross-spawn": ">=7.0.5",
"cross-spawn": "^7.0.5",
"eslint-plugin-escompat": "3.4.0",
"@octokit/request-error@5.0.1": "5.1.1",
"undici": ">=6.27.0",
"minimatch": ">=9.0.7"
"undici": "^6.27.0",
"minimatch": "^9.0.7"
}
}
+19 -6
View File
@@ -20,12 +20,16 @@ export async function commentPr(
config: ConfigurationOptions,
issueFound: boolean
): Promise<void> {
if (
!(
config.comment_summary_in_pr === 'always' ||
(config.comment_summary_in_pr === 'on-failure' && issueFound)
)
) {
// For 'on-failure' mode, we need to handle both failure and success cases
// - On failure: create/update comment with issues
// - On success: update existing comment to show resolution (if one exists)
const shouldComment =
config.comment_summary_in_pr === 'always' ||
(config.comment_summary_in_pr === 'on-failure' && issueFound) ||
(config.comment_summary_in_pr === 'on-failure' &&
!issueFound &&
(await hasExistingComment()))
if (!shouldComment) {
return
}
@@ -75,6 +79,15 @@ export async function commentPr(
}
}
async function hasExistingComment(): Promise<boolean> {
if (!github.context.payload.pull_request) {
return false
}
const existingCommentId = await findCommentByMarker(COMMENT_MARKER)
return existingCommentId !== undefined
}
async function findCommentByMarker(
commentBodyIncludes: string
): Promise<number | undefined> {
+3 -4
View File
@@ -216,10 +216,9 @@ async function getRemoteConfig(configOpts: {
ref: configOpts.ref
})
// When using mediaType.format = 'raw', the response.data is a string
// but this is not reflected in the return type of getContent, so we're
// casting the return value to a string.
return z.string().parse(data as unknown)
// When using mediaType.format = 'raw', the response data is a string,
// but getContent's return type does not reflect that, so validate it here.
return z.string().parse(data)
} catch (error) {
core.debug(error as string)
throw new Error('Error fetching remote config file')
+4 -51
View File
@@ -17,9 +17,7 @@ import * as spdx from './spdx'
* @returns {Promise<{Object.<string, Array.<Change>>}} A promise to a Record Object. The keys are strings, unlicensed, unresolved and forbidden. The values are a list of changes
*/
export type InvalidLicenseChangeTypes =
| 'unlicensed'
| 'unresolved'
| 'forbidden'
'unlicensed' | 'unresolved' | 'forbidden'
export type InvalidLicenseChanges = Record<InvalidLicenseChangeTypes, Changes>
export async function getInvalidLicenseChanges(
changes: Change[],
@@ -84,7 +82,7 @@ export async function getInvalidLicenseChanges(
invalidLicenseChanges.unresolved.push(change)
}
}
} catch (err) {
} catch {
invalidLicenseChanges.unresolved.push(change)
}
}
@@ -107,7 +105,7 @@ const fetchGHLicense = async (
repo
})
return response.data.license?.spdx_id ?? null
} catch (_) {
} catch {
return null
}
}
@@ -123,7 +121,7 @@ const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
return null
}
return {owner: components[1], repo: components[2]}
} catch (_) {
} catch {
return null
}
}
@@ -154,49 +152,6 @@ const setGHLicenses = async (changes: Change[]): Promise<Change[]> => {
const truncatedDGLicense = (license: string): boolean =>
license.length === 255 && !spdx.isValid(license)
// Builds a key identifying a package across manifest and lock files, so that
// duplicate entries for the same package (differing only by version specifier)
// can be matched. Changes are keyed by their parsed PURL type and full name,
// ignoring the version.
function packageKey(change: Change): string {
const purl = parsePURL(change.package_url)
const type = purl.type.toLowerCase()
const fullName =
purl.namespace && purl.name
? `${purl.namespace}/${purl.name}`
: purl.name ?? purl.namespace
if (type && fullName) {
return `${type}/${fullName.toLowerCase()}`
}
// Fall back to ecosystem + name when the PURL can't be parsed.
return `${change.ecosystem.toLowerCase()}/${change.name.toLowerCase()}`
}
// The dependency graph API can list the same package more than once: e.g. from
// a manifest file (like pyproject.toml) with a version range and a null
// license, and from a lock file (like poetry.lock) with a pinned version and a
// resolved license. This drops the null-license entries for a package when
// another entry of the same change_type resolves a license for it, so the
// package is not incorrectly reported as unlicensed.
function filterLicensedDuplicates(changes: Changes): Changes {
const licensedKeys = new Set<string>()
for (const change of changes) {
if (change.change_type !== 'removed' && change.license !== null) {
licensedKeys.add(`${change.change_type}/${packageKey(change)}`)
}
}
return changes.filter(change => {
if (change.change_type === 'removed' || change.license !== null) {
return true
}
return !licensedKeys.has(`${change.change_type}/${packageKey(change)}`)
})
}
async function groupChanges(
changes: Changes,
licenseExclusions: PackageURL[] | null = null
@@ -234,8 +189,6 @@ async function groupChanges(
})
}
candidateChanges = filterLicensedDuplicates(candidateChanges)
const ghChanges = []
for (const change of candidateChanges) {
+1 -1
View File
@@ -4,7 +4,7 @@ import * as core from '@actions/core'
export async function getScorecardLevels(
changes: Change[]
): Promise<Scorecard> {
const data: Scorecard = {dependencies: []} as Scorecard
const data: Scorecard = {dependencies: []}
for (const change of changes) {
const ecosystem = change.ecosystem
const packageName = change.name
+4 -4
View File
@@ -15,7 +15,7 @@ export function satisfies(candidateExpr: string, allowList: string[]): boolean {
candidateExpr = cleanInvalidSPDX(candidateExpr)
try {
return spdxSatisfies(candidateExpr, allowList)
} catch (_) {
} catch {
return false
}
}
@@ -28,7 +28,7 @@ export function satisfiesAny(
candidateExpr = cleanInvalidSPDX(candidateExpr)
try {
return spdxlib.satisfiesAny(candidateExpr, licenses)
} catch (_) {
} catch {
return false
}
}
@@ -41,7 +41,7 @@ export function satisfiesAll(
candidateExpr = cleanInvalidSPDX(candidateExpr)
try {
return spdxlib.satisfiesAll(candidateExpr, licenses)
} catch (_) {
} catch {
return false
}
}
@@ -52,7 +52,7 @@ export function isValid(spdxExpr: string): boolean {
try {
parse(spdxExpr)
return true
} catch (_) {
} catch {
return false
}
}
+2 -3
View File
@@ -135,7 +135,7 @@ function extractPatchVersionId(patchData: unknown): string | null {
// Handle object format with identifier field (for backward compatibility)
if (patchData && typeof patchData === 'object' && 'identifier' in patchData) {
const id = (patchData as {identifier: unknown}).identifier
const id = patchData.identifier
return typeof id === 'string' ? id : null
}
@@ -422,8 +422,7 @@ export async function addChangeVulnerabilitiesToSummary(
// Find matching entry by ecosystem, package name (case-insensitive), and version range
// Use pre-normalized values from cache to avoid repeated lowercasing and range conversion
let foundEntry:
| {eco: string; pkg: string; range: string; patch: string}
| undefined
{eco: string; pkg: string; range: string; patch: string} | undefined
for (const vulnEntry of advisoryEntries) {
if (vulnEntry.ecoLower !== ecoLowercase) continue
if (vulnEntry.pkgLower !== packageLowercase) continue