feat: adds support for ignores (#1)

* feat: adding optional ignore list

* chore: updating lock file

* format: prettier tak

* chore: new build

* chore: adding nvm rc to avoid error with vercel and node v17

* chore: bumping version to 1.3.0

* fix: gh actions does not support sequences as input

* chore: refresh build

* refactor: use getInputList from actos-rs/core

* add ignore to action.yml

Co-authored-by: moliva <oliva.miguelh@gmail.com>
This commit is contained in:
Dustin J. Mitchell
2022-08-12 19:47:29 +10:00
committed by GitHub
co-authored by moliva
parent 35b7b53b1e
commit bb800784d9
7 changed files with 22893 additions and 9998 deletions
+3
View File
@@ -3,14 +3,17 @@
*/
import { input } from '@actions-rs/core';
import { getInputList } from '@actions-rs/core/dist/input';
// Parsed action input
export interface Input {
token: string;
ignore: string[];
}
export function get(): Input {
return {
token: input.getInput('token', { required: true }),
ignore: getInputList('ignore', { required: false }),
};
}
+11 -3
View File
@@ -14,7 +14,9 @@ const pkg = require('../package.json'); // eslint-disable-line @typescript-eslin
const USER_AGENT = `${pkg.name}/${pkg.version} (${pkg.bugs.url})`;
async function getData(): Promise<interfaces.Report> {
async function getData(
ignore: string[] | undefined,
): Promise<interfaces.Report> {
const cargo = await Cargo.get();
await cargo.findOrInstall('cargo-audit');
@@ -23,7 +25,12 @@ async function getData(): Promise<interfaces.Report> {
let stdout = '';
try {
core.startGroup('Calling cargo-audit (JSON output)');
await cargo.call(['audit', '--json'], {
const commandArray = ['audit'];
for (const item of ignore ?? []) {
commandArray.push('--ignore', item);
}
commandArray.push('--json');
await cargo.call(commandArray, {
ignoreReturnCode: true,
listeners: {
stdout: (buffer) => {
@@ -44,7 +51,8 @@ async function getData(): Promise<interfaces.Report> {
}
export async function run(actionInput: input.Input): Promise<void> {
const report = await getData();
const ignore = actionInput.ignore;
const report = await getData(ignore);
let shouldReport = false;
if (!report.vulnerabilities.found) {
core.info('No vulnerabilities were found');