Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
907a6e9569 | ||
|
|
f4fc8069af | ||
|
|
c15ec0f451 | ||
|
|
72aaca2ab0 | ||
|
|
2f920dad77 | ||
|
|
46b39ef136 | ||
|
|
41184d6995 | ||
|
|
108c8ecde0 | ||
|
|
5dd1a81845 | ||
|
|
a1f042c02b | ||
|
|
284c089a1c | ||
|
|
ba5451defb | ||
|
|
ecb589c3c7 | ||
|
|
cc619a78a7 | ||
|
|
0cf05d1048 | ||
|
|
478e8f1efb | ||
|
|
799981d143 | ||
|
|
8725015b0b | ||
|
|
24f1d4c629 | ||
|
|
2bb8ee2515 | ||
|
|
c8d6df912a | ||
|
|
0c0e1d27cd | ||
|
|
f28a2efbc7 | ||
|
|
2a5c32fe65 | ||
|
|
9538e6e31c | ||
|
|
aae4911372 | ||
|
|
57b6663b1e | ||
|
|
ab7c86dd7d | ||
|
|
a8e96f5b76 | ||
|
|
2cb914636e | ||
|
|
f9d8e93c20 | ||
|
|
c2b21dcd2e | ||
|
|
d6742e69a4 | ||
|
|
1489879da3 | ||
|
|
cc905d3f06 | ||
|
|
f21eb50a0c |
No files matched your search
+2
-4
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}}"
|
||||
@@ -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."
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
+18
-2
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
Generated
+747
-337
File diff suppressed because it is too large.
Load diff
+14
-12
@@ -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
@@ -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
@@ -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
-6
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
@@ -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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user