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
+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}`,