Release v1.2.0
Continuous integration / main (push) Failing after 18s

This commit is contained in:
svartalf
2020-05-07 11:00:43 +03:00
parent d6b76c84eb
commit 35b7b53b1e
7 changed files with 75 additions and 67 deletions
+2 -1
View File
@@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.0] ## [1.2.0] - 2020-05-07
### Fixed ### Fixed
- Compatibility with latest `cargo-audit == 0.12` JSON output (#115)
- Do not fail check if no critical vulnerabilities were found when executed for a fork repository (closes #104) - Do not fail check if no critical vulnerabilities were found when executed for a fork repository (closes #104)
## [1.1.0] ## [1.1.0]
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rust-audit-check", "name": "rust-audit-check",
"version": "1.1.0", "version": "1.2.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rust-audit-check", "name": "rust-audit-check",
"version": "1.1.0", "version": "1.2.0",
"private": false, "private": false,
"description": "Security audit for security vulnerabilities", "description": "Security audit for security vulnerabilities",
"main": "lib/main.js", "main": "lib/main.js",
+3 -19
View File
@@ -8,7 +8,7 @@ export interface Report {
database: DatabaseInfo; database: DatabaseInfo;
lockfile: LockfileInfo; lockfile: LockfileInfo;
vulnerabilities: VulnerabilitiesInfo; vulnerabilities: VulnerabilitiesInfo;
warnings: Warning[]; warnings: Warning[] | { [key: string]: Warning[] };
} }
export interface DatabaseInfo { export interface DatabaseInfo {
@@ -47,23 +47,7 @@ export interface Package {
} }
export interface Warning { export interface Warning {
kind: Kind; kind: 'unmaintained' | 'informational' | 'yanked' | string;
advisory: Advisory;
package: Package; package: Package;
} }
// TypeScript types system is weird :(
export interface Kind {
unmaintained?: KindUnmaintained;
informational?: KindInformational;
yanked?: KindYanked;
}
export interface KindUnmaintained {
advisory: Advisory;
}
export interface KindInformational {
advisory: Advisory;
}
export interface KindYanked {} // eslint-disable-line @typescript-eslint/no-empty-interface
+16 -4
View File
@@ -53,10 +53,22 @@ export async function run(actionInput: input.Input): Promise<void> {
shouldReport = true; shouldReport = true;
} }
if (report.warnings.length === 0) { // In `cargo-audit < 0.12` report contained an array of `Warning`.
// In `cargo-audit >= 0.12` it is a JSON object,
// where key is a warning type, and value is an array of `Warning` of that type.
let warnings: Array<interfaces.Warning> = [];
if (Array.isArray(report.warnings)) {
warnings = report.warnings;
} else {
for (const items of Object.values(report.warnings)) {
warnings = warnings.concat(items);
}
}
if (warnings.length === 0) {
core.info('No warnings were found'); core.info('No warnings were found');
} else { } else {
core.warning(`${report.warnings.length} warnings found!`); core.warning(`${warnings.length} warnings found!`);
shouldReport = true; shouldReport = true;
} }
@@ -72,12 +84,12 @@ export async function run(actionInput: input.Input): Promise<void> {
core.debug( core.debug(
'Action was triggered on a schedule event, creating an Issues report', 'Action was triggered on a schedule event, creating an Issues report',
); );
await reporter.reportIssues(client, advisories, report.warnings); await reporter.reportIssues(client, advisories, warnings);
} else { } else {
core.debug( core.debug(
`Action was triggered on a ${github.context.eventName} event, creating a Check report`, `Action was triggered on a ${github.context.eventName} event, creating a Check report`,
); );
await reporter.reportCheck(client, advisories, report.warnings); await reporter.reportCheck(client, advisories, warnings);
} }
} }
+27 -16
View File
@@ -26,26 +26,32 @@ function makeReport(
): string { ): string {
const preparedWarnings: Array<templates.ReportWarning> = []; const preparedWarnings: Array<templates.ReportWarning> = [];
for (const warning of warnings) { for (const warning of warnings) {
// TODO: Is there any better way? switch (warning.kind) {
if ('unmaintained' in warning.kind) { case 'unmaintained':
preparedWarnings.push({ preparedWarnings.push({
advisory: warning.kind.unmaintained!.advisory, // eslint-disable-line @typescript-eslint/no-non-null-assertion advisory: warning.advisory,
package: warning.package, package: warning.package,
}); });
} else if ('informational' in warning.kind) { break;
case 'informational':
preparedWarnings.push({ preparedWarnings.push({
advisory: warning.kind.informational!.advisory, // eslint-disable-line @typescript-eslint/no-non-null-assertion advisory: warning.advisory,
package: warning.package, package: warning.package,
}); });
} else if ('yanked' in warning.kind) { break;
case 'yanked':
preparedWarnings.push({ preparedWarnings.push({
package: warning.package, package: warning.package,
}); });
} else { break;
default:
core.warning( core.warning(
`Unknown warning kind ${warning.kind} found, please, file a bug`, `Unknown warning kind ${warning.kind} found, please, file a bug`,
); );
continue; break;
} }
} }
@@ -85,11 +91,15 @@ function getStats(
} }
for (const warning of warnings) { for (const warning of warnings) {
if (warning.kind.unmaintained) { switch (warning.kind) {
case 'unmaintained':
unmaintained += 1; unmaintained += 1;
} else { break;
default:
// Both yanked and informational types of kind // Both yanked and informational types of kind
other += 1; other += 1;
break;
} }
} }
@@ -243,16 +253,17 @@ export async function reportIssues(
for (const warning of warnings) { for (const warning of warnings) {
let advisory: interfaces.Advisory; let advisory: interfaces.Advisory;
if ('unmaintained' in warning.kind) { switch (warning.kind) {
advisory = warning.kind.unmaintained!.advisory; // eslint-disable-line @typescript-eslint/no-non-null-assertion case 'unmaintained':
} else if ('informational' in warning.kind) { case 'informational':
advisory = warning.kind.informational!.advisory; // eslint-disable-line @typescript-eslint/no-non-null-assertion advisory = warning.advisory;
} else if ('yanked' in warning.kind) { break;
case 'yanked':
core.warning( core.warning(
`Crate ${warning.package.name} was yanked, but no issue will be reported about it`, `Crate ${warning.package.name} was yanked, but no issue will be reported about it`,
); );
continue; continue;
} else { default:
core.warning( core.warning(
`Unknown warning kind ${warning.kind} found, please, file a bug`, `Unknown warning kind ${warning.kind} found, please, file a bug`,
); );