Public Access
Updates to v1.3.2 with node16
This commit is contained in:
+17
-10
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user