Updates to v1.3.2 with node16

This commit is contained in:
pinkforest(she/her)
2023-03-28 11:24:53 +11:00
committed by pinkforest
parent 9448c34627
commit 13d7e3e1c9
10 changed files with 8238 additions and 8602 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
* Parse action input into a some proper thing.
*/
import { input } from '@actions-rs/core';
import { getInputList } from '@actions-rs/core/dist/input';
import { input } from '@rinse-repeat/actions-rs-core';
import { getInputList } from '@rinse-repeat/actions-rs-core/dist/input';
// Parsed action input
export interface Input {
+4 -10
View File
@@ -4,16 +4,12 @@ import * as os from 'os';
import * as core from '@actions/core';
import * as github from '@actions/github';
import { Cargo } from '@actions-rs/core';
import { Cargo } from '@rinse-repeat/actions-rs-core';
import * as input from './input';
import * as interfaces from './interfaces';
import * as reporter from './reporter';
const pkg = require('../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
const USER_AGENT = `${pkg.name}/${pkg.version} (${pkg.bugs.url})`;
async function getData(
ignore: string[] | undefined,
): Promise<interfaces.Report> {
@@ -84,20 +80,18 @@ export async function run(actionInput: input.Input): Promise<void> {
return;
}
const client = new github.GitHub(actionInput.token, {
userAgent: USER_AGENT,
});
// const octokit = github.getOctokit(actionInput.token, {userAgent: USER_AGENT});
const advisories = report.vulnerabilities.list;
if (github.context.eventName == 'schedule') {
core.debug(
'Action was triggered on a schedule event, creating an Issues report',
);
await reporter.reportIssues(client, advisories, warnings);
await reporter.reportIssues(actionInput.token, advisories, warnings);
} else {
core.debug(
`Action was triggered on a ${github.context.eventName} event, creating a Check report`,
);
await reporter.reportCheck(client, advisories, warnings);
await reporter.reportCheck(actionInput.token, advisories, warnings);
}
}
+17 -10
View File
@@ -4,10 +4,13 @@ import * as core from '@actions/core';
import * as github from '@actions/github';
import * as nunjucks from 'nunjucks';
import { checks } from '@actions-rs/core';
import { checks } from '@rinse-repeat/actions-rs-core';
import * as interfaces from './interfaces';
import * as templates from './templates';
const pkg = require('../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
const USER_AGENT = `${pkg.name}/${pkg.version} (${pkg.bugs.url})`;
interface Stats {
critical: number;
notices: number;
@@ -133,11 +136,12 @@ function getSummary(stats: Stats): string {
/// Create and publish audit results into the Commit Check.
export async function reportCheck(
client: github.GitHub,
token: string,
vulnerabilities: Array<interfaces.Vulnerability>,
warnings: Array<interfaces.Warning>,
): Promise<void> {
const reporter = new checks.CheckReporter(client, 'Security audit');
const client = github.getOctokit(token, {userAgent: USER_AGENT});
const reporter = new checks.CheckReporter(client.rest, 'Security audit');
const stats = getStats(vulnerabilities, warnings);
const summary = getSummary(stats);
@@ -201,11 +205,12 @@ See https://github.com/actions-rs/clippy-check/issues/2 for details.`);
}
async function alreadyReported(
client: github.GitHub,
token: string,
advisoryId: string,
): Promise<boolean> {
const { owner, repo } = github.context.repo;
const results = await client.search.issuesAndPullRequests({
const client = github.getOctokit(token, {userAgent: USER_AGENT});
const results = await client.rest.search.issuesAndPullRequests({
q: `${advisoryId} in:title repo:${owner}/${repo}`,
per_page: 1, // eslint-disable-line @typescript-eslint/camelcase
});
@@ -222,15 +227,17 @@ will not report an issue against it`,
}
export async function reportIssues(
client: github.GitHub,
token: string,
vulnerabilities: Array<interfaces.Vulnerability>,
warnings: Array<interfaces.Warning>,
): Promise<void> {
const { owner, repo } = github.context.repo;
const client = github.getOctokit(token, {userAgent: USER_AGENT});
for (const vulnerability of vulnerabilities) {
const reported = await alreadyReported(
client,
token,
vulnerability.advisory.id,
);
if (reported) {
@@ -240,7 +247,7 @@ export async function reportIssues(
const body = nunjucks.renderString(templates.VULNERABILITY_ISSUE, {
vulnerability: vulnerability,
});
const issue = await client.issues.create({
const issue = await client.rest.issues.create({
owner: owner,
repo: repo,
title: `${vulnerability.advisory.id}: ${vulnerability.advisory.title}`,
@@ -270,7 +277,7 @@ export async function reportIssues(
continue;
}
const reported = await alreadyReported(client, advisory.id);
const reported = await alreadyReported(token, advisory.id);
if (reported) {
continue;
}
@@ -279,7 +286,7 @@ export async function reportIssues(
warning: warning,
advisory: advisory,
});
const issue = await client.issues.create({
const issue = await client.rest.issues.create({
owner: owner,
repo: repo,
title: `${advisory.id}: ${advisory.title}`,