Merge pull request #827 from ebickle/fix/comment-warn-only
fix: add summary comment on failure when warn-only: true
This commit is contained in:
+2313
-1590
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+20
-1
@@ -1460,7 +1460,7 @@ lru-cache
|
|||||||
ISC
|
ISC
|
||||||
The ISC License
|
The ISC License
|
||||||
|
|
||||||
Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -1764,6 +1764,25 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
yallist
|
||||||
|
ISC
|
||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
yaml
|
yaml
|
||||||
ISC
|
ISC
|
||||||
Copyright Eemeli Aro <[email protected]>
|
Copyright Eemeli Aro <[email protected]>
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+3
-3
@@ -17,13 +17,13 @@ const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->'
|
|||||||
|
|
||||||
export async function commentPr(
|
export async function commentPr(
|
||||||
commentContent: string,
|
commentContent: string,
|
||||||
config: ConfigurationOptions
|
config: ConfigurationOptions,
|
||||||
|
issueFound: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
config.comment_summary_in_pr === 'always' ||
|
config.comment_summary_in_pr === 'always' ||
|
||||||
(config.comment_summary_in_pr === 'on-failure' &&
|
(config.comment_summary_in_pr === 'on-failure' && issueFound)
|
||||||
process.exitCode === core.ExitCode.Failure)
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -35,12 +35,6 @@ export async function getDeniedChanges(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDeniedPackage) {
|
|
||||||
core.setFailed('Dependency review detected denied packages.')
|
|
||||||
} else {
|
|
||||||
core.info('Dependency review did not detect any denied packages')
|
|
||||||
}
|
|
||||||
|
|
||||||
return changesDenied
|
return changesDenied
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-15
@@ -141,10 +141,16 @@ async function run(): Promise<void> {
|
|||||||
summary.addSnapshotWarnings(config, snapshot_warnings)
|
summary.addSnapshotWarnings(config, snapshot_warnings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let issueFound = false
|
||||||
|
|
||||||
if (config.vulnerability_check) {
|
if (config.vulnerability_check) {
|
||||||
core.setOutput('vulnerable-changes', JSON.stringify(vulnerableChanges))
|
core.setOutput('vulnerable-changes', JSON.stringify(vulnerableChanges))
|
||||||
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity)
|
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity)
|
||||||
printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly)
|
issueFound ||= await printVulnerabilitiesBlock(
|
||||||
|
vulnerableChanges,
|
||||||
|
minSeverity,
|
||||||
|
warnOnly
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (config.license_check) {
|
if (config.license_check) {
|
||||||
core.setOutput(
|
core.setOutput(
|
||||||
@@ -152,12 +158,12 @@ async function run(): Promise<void> {
|
|||||||
JSON.stringify(invalidLicenseChanges)
|
JSON.stringify(invalidLicenseChanges)
|
||||||
)
|
)
|
||||||
summary.addLicensesToSummary(invalidLicenseChanges, config)
|
summary.addLicensesToSummary(invalidLicenseChanges, config)
|
||||||
printLicensesBlock(invalidLicenseChanges, warnOnly)
|
issueFound ||= await printLicensesBlock(invalidLicenseChanges, warnOnly)
|
||||||
}
|
}
|
||||||
if (config.deny_packages || config.deny_groups) {
|
if (config.deny_packages || config.deny_groups) {
|
||||||
core.setOutput('denied-changes', JSON.stringify(deniedChanges))
|
core.setOutput('denied-changes', JSON.stringify(deniedChanges))
|
||||||
summary.addDeniedToSummary(deniedChanges)
|
summary.addDeniedToSummary(deniedChanges)
|
||||||
printDeniedDependencies(deniedChanges, config)
|
issueFound ||= await printDeniedDependencies(deniedChanges, config)
|
||||||
}
|
}
|
||||||
if (config.show_openssf_scorecard) {
|
if (config.show_openssf_scorecard) {
|
||||||
summary.addScorecardToSummary(scorecard, config)
|
summary.addScorecardToSummary(scorecard, config)
|
||||||
@@ -182,7 +188,7 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the PR comment if needed with the right-sized summary
|
// update the PR comment if needed with the right-sized summary
|
||||||
await commentPr(rendered, config)
|
await commentPr(rendered, config, issueFound)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof RequestError && error.status === 404) {
|
if (error instanceof RequestError && error.status === 404) {
|
||||||
core.setFailed(
|
core.setFailed(
|
||||||
@@ -208,14 +214,12 @@ function printVulnerabilitiesBlock(
|
|||||||
addedChanges: Changes,
|
addedChanges: Changes,
|
||||||
minSeverity: Severity,
|
minSeverity: Severity,
|
||||||
warnOnly: boolean
|
warnOnly: boolean
|
||||||
): void {
|
): Promise<boolean> {
|
||||||
|
return core.group('Vulnerabilities', async () => {
|
||||||
let vulFound = false
|
let vulFound = false
|
||||||
core.group('Vulnerabilities', async () => {
|
|
||||||
if (addedChanges.length > 0) {
|
|
||||||
for (const change of addedChanges) {
|
for (const change of addedChanges) {
|
||||||
printChangeVulnerabilities(change)
|
vulFound ||= printChangeVulnerabilities(change)
|
||||||
}
|
|
||||||
vulFound = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vulFound) {
|
if (vulFound) {
|
||||||
@@ -230,10 +234,12 @@ function printVulnerabilitiesBlock(
|
|||||||
`Dependency review did not detect any vulnerable packages with severity level "${minSeverity}" or higher.`
|
`Dependency review did not detect any vulnerable packages with severity level "${minSeverity}" or higher.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return vulFound
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function printChangeVulnerabilities(change: Change): void {
|
function printChangeVulnerabilities(change: Change): boolean {
|
||||||
for (const vuln of change.vulnerabilities) {
|
for (const vuln of change.vulnerabilities) {
|
||||||
core.info(
|
core.info(
|
||||||
`${styles.bold.open}${change.manifest} » ${change.name}@${
|
`${styles.bold.open}${change.manifest} » ${change.name}@${
|
||||||
@@ -244,14 +250,18 @@ function printChangeVulnerabilities(change: Change): void {
|
|||||||
)
|
)
|
||||||
core.info(` ↪ ${vuln.advisory_url}`)
|
core.info(` ↪ ${vuln.advisory_url}`)
|
||||||
}
|
}
|
||||||
|
return change.vulnerabilities.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function printLicensesBlock(
|
function printLicensesBlock(
|
||||||
invalidLicenseChanges: Record<string, Changes>,
|
invalidLicenseChanges: Record<string, Changes>,
|
||||||
warnOnly: boolean
|
warnOnly: boolean
|
||||||
): void {
|
): Promise<boolean> {
|
||||||
core.group('Licenses', async () => {
|
return core.group('Licenses', async () => {
|
||||||
|
let issueFound = false
|
||||||
|
|
||||||
if (invalidLicenseChanges.forbidden.length > 0) {
|
if (invalidLicenseChanges.forbidden.length > 0) {
|
||||||
|
issueFound = true
|
||||||
core.info('\nThe following dependencies have incompatible licenses:')
|
core.info('\nThe following dependencies have incompatible licenses:')
|
||||||
printLicensesError(invalidLicenseChanges.forbidden)
|
printLicensesError(invalidLicenseChanges.forbidden)
|
||||||
const msg = 'Dependency review detected incompatible licenses.'
|
const msg = 'Dependency review detected incompatible licenses.'
|
||||||
@@ -262,6 +272,7 @@ function printLicensesBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (invalidLicenseChanges.unresolved.length > 0) {
|
if (invalidLicenseChanges.unresolved.length > 0) {
|
||||||
|
issueFound = true
|
||||||
core.warning(
|
core.warning(
|
||||||
'\nThe validity of the licenses of the dependencies below could not be determined. Ensure that they are valid SPDX licenses:'
|
'\nThe validity of the licenses of the dependencies below could not be determined. Ensure that they are valid SPDX licenses:'
|
||||||
)
|
)
|
||||||
@@ -271,6 +282,8 @@ function printLicensesBlock(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
printNullLicenses(invalidLicenseChanges.unlicensed)
|
printNullLicenses(invalidLicenseChanges.unlicensed)
|
||||||
|
|
||||||
|
return issueFound
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +386,10 @@ function printScannedDependencies(changes: Changes): void {
|
|||||||
function printDeniedDependencies(
|
function printDeniedDependencies(
|
||||||
changes: Changes,
|
changes: Changes,
|
||||||
config: ConfigurationOptions
|
config: ConfigurationOptions
|
||||||
): void {
|
): Promise<boolean> {
|
||||||
core.group('Denied', async () => {
|
return core.group('Denied', async () => {
|
||||||
|
let issueFound = false
|
||||||
|
|
||||||
for (const denied of config.deny_packages) {
|
for (const denied of config.deny_packages) {
|
||||||
core.info(`Config: ${denied}`)
|
core.info(`Config: ${denied}`)
|
||||||
}
|
}
|
||||||
@@ -383,6 +398,15 @@ function printDeniedDependencies(
|
|||||||
core.info(`Change: ${change.name}@${change.version} is denied`)
|
core.info(`Change: ${change.name}@${change.version} is denied`)
|
||||||
core.info(`Change: ${change.package_url} is denied`)
|
core.info(`Change: ${change.package_url} is denied`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changes.length > 0) {
|
||||||
|
issueFound = true
|
||||||
|
core.setFailed('Dependency review detected denied packages.')
|
||||||
|
} else {
|
||||||
|
core.info('Dependency review did not detect any denied packages')
|
||||||
|
}
|
||||||
|
|
||||||
|
return issueFound
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user