Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7be22cbace
|
||
|
|
36a5751a64
|
||
|
|
c72c196d32
|
||
|
|
50cb1867b0
|
||
|
|
380200d383
|
||
|
|
d18d2d8134
|
||
|
|
b7e98a4fa5
|
||
|
|
34fbfaba50
|
||
|
|
f8bde94864
|
||
|
|
858dc40f52 | ||
|
|
3ae01282e2 | ||
|
|
dd2c7de31f | ||
|
|
69366f33c9 | ||
|
|
7b350a127d | ||
|
|
286a088f1c | ||
|
|
b7dc4ebf0c | ||
|
|
6dc762e804 | ||
|
|
fe0359b3e1 | ||
|
|
4da312dd0f | ||
|
|
d6805b6463 | ||
|
|
dd51754d4e | ||
|
|
7cb7a4e8d4 | ||
|
|
13d7e3e1c9 | ||
|
|
9448c34627 | ||
|
|
bb800784d9 |
+2
-5
@@ -6,17 +6,14 @@
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier",
|
||||
"prettier/@typescript-eslint"
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-function-return-type": 0
|
||||
|
||||
@@ -9,10 +9,15 @@ jobs:
|
||||
- name: Create npm configuration
|
||||
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
|
||||
env:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
# octokit types problem ?
|
||||
# - run: npm run lint
|
||||
- run: npm run build
|
||||
- run: npm run test
|
||||
|
||||
@@ -1 +1 @@
|
||||
@actions-rs:registry=https://npm.pkg.github.com
|
||||
@clechasseur:registry=https://npm.pkg.github.com
|
||||
|
||||
@@ -5,6 +5,42 @@ 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/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Update the GitHub Action runtime and local Node tooling target to Node 24.
|
||||
|
||||
## [1.4.1] - 2023-04-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- Corrected reporting on `unsound` and `notice` informationals
|
||||
|
||||
## [1.4.0] - 2023-04-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reflect change to enable warning on `unsound` and `notice` informationals
|
||||
|
||||
## [1.3.2] - 2023-03-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Update various dependencies to fix some known vulnerabilities.
|
||||
|
||||
## [1.3.1] - 2020-05-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- GitHub Actions does not support sequences as input
|
||||
|
||||
## [1.3.0] - 2022-05-09
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for ignores (#1)
|
||||
|
||||
## [1.2.0] - 2020-05-07
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Rust `audit-check` Action
|
||||
|
||||

|
||||
[](https://gitter.im/actions-rs/community)
|
||||
|
||||
> Security vulnerabilities audit
|
||||
|
||||
@@ -27,8 +26,8 @@ jobs:
|
||||
security_audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/audit-check@v1
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rustsec/audit-check@v2.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
@@ -37,13 +36,33 @@ It is recommended to add the `paths:` section into the workflow file,
|
||||
as it would effectively speed up the CI pipeline, since the audit process
|
||||
will not be performed if no dependencies were changed.
|
||||
|
||||
|
||||
In case of any security advisories found, [status check](https://help.github.com/en/articles/about-status-checks)
|
||||
created by this Action will be marked as "failed".\
|
||||
Note that informational advisories are not affecting the check status.
|
||||
|
||||

|
||||
|
||||
#### Granular Permissions
|
||||
|
||||
These are the typically used permissions:
|
||||
|
||||
```yaml
|
||||
name: 'rust-audit-check'
|
||||
github-token:
|
||||
action-input:
|
||||
input: token
|
||||
is-default: false
|
||||
permissions:
|
||||
issues: write
|
||||
issues-reason: to create issues
|
||||
checks: write
|
||||
checks-reason: to create check
|
||||
```
|
||||
|
||||
This action only raises issues when it's triggered from a `cron` scheduled workflow or on manual `workflow_dispatch`
|
||||
|
||||
When running the action as scheduled it will create issues but e.g. in PR / push fails the action.
|
||||
|
||||
#### Limitations
|
||||
|
||||
Due to [token permissions](https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions),
|
||||
@@ -66,8 +85,8 @@ jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/audit-check@v1
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rustsec/audit-check@v2.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
@@ -83,5 +102,28 @@ For each new advisory (including informal) an issue will be created:
|
||||
| Name | Required | Description | Type | Default |
|
||||
| ------------| -------- | ---------------------------------------------------------------------------| ------ | --------|
|
||||
| `token` | ✓ | [GitHub token], usually a `${{ secrets.GITHUB_TOKEN }}` | string | |
|
||||
| `ignore` | | Comma-separated list of advisory ids to ignore | string | |
|
||||
| `working-directory`| | The directory of the Cargo.toml / Cargo.lock files to scan. | string | `.` |
|
||||
| `new-issue-labels` | | Comma-separated list of Labes to be added to new issues | string | `.` |
|
||||
|
||||
[GitHub token]: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||
|
||||
## Contribute
|
||||
|
||||
### Setting up npm login
|
||||
|
||||
This repo uses some npm packages hosted on github.
|
||||
To be able to pull these you need to:
|
||||
|
||||
1. Under <https://github.com/settings/tokens> - create a `personal access token (classic)` with `read:packages` scope
|
||||
|
||||
2. Authenticate to the github npm registry
|
||||
|
||||
```sh
|
||||
npm login --scope=@clechasseur --auth-type=legacy --registry=https://npm.pkg.github.com
|
||||
```
|
||||
|
||||
```txt
|
||||
Username = Github Username
|
||||
Password = Token
|
||||
```
|
||||
|
||||
+8
-1
@@ -8,7 +8,14 @@ inputs:
|
||||
token:
|
||||
description: GitHub Actions token
|
||||
required: true
|
||||
ignore:
|
||||
description: Comma-separated list of advisory ids to ignore
|
||||
required: false
|
||||
working-directory:
|
||||
description: The directory of the Cargo.toml / Cargo.lock files to scan.
|
||||
required: false
|
||||
default: .
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node24'
|
||||
main: 'dist/index.js'
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
+11
-1
File diff suppressed because one or more lines are too long
Generated
+6362
-10054
File diff suppressed because it is too large
Load Diff
+22
-22
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rust-audit-check",
|
||||
"version": "1.2.0",
|
||||
"version": "2.0.0",
|
||||
"private": false,
|
||||
"description": "Security audit for security vulnerabilities",
|
||||
"main": "lib/main.js",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions-rs/audit.git"
|
||||
"url": "github:rustsec/audit-check"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
@@ -31,29 +31,29 @@
|
||||
"author": "actions-rs",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions-rs/audit-check/issues"
|
||||
"url": "https://github.com/rustsec/audit-check/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions-rs/core": "0.0.9",
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/github": "^2.1.1",
|
||||
"npm-check-updates": "^4.1.2",
|
||||
"nunjucks": "^3.2.1"
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@clechasseur/rs-actions-core": "^3.0.5",
|
||||
"gitea-js": "^1.23.0",
|
||||
"nunjucks": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^2.31.0",
|
||||
"ts-node": "^8.10.1",
|
||||
"@typescript-eslint/parser": "^2.31.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^13.13.5",
|
||||
"@zeit/ncc": "^0.22.1",
|
||||
"jest": "^26.0.1",
|
||||
"jest-circus": "^26.0.1",
|
||||
"ts-jest": "^25.5.0",
|
||||
"typescript": "^3.8.3",
|
||||
"prettier": "^2.0.5"
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^24.0.0",
|
||||
"@types/nunjucks": "^3.2.4",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"@vercel/ncc": "0.38.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -2,15 +2,24 @@
|
||||
* Parse action input into a some proper thing.
|
||||
*/
|
||||
|
||||
import { input } from '@actions-rs/core';
|
||||
import { input } from '@clechasseur/rs-actions-core';
|
||||
|
||||
// Parsed action input
|
||||
export interface Input {
|
||||
token: string;
|
||||
ignore: string[];
|
||||
new_issue_labels: string[];
|
||||
workingDirectory: string;
|
||||
}
|
||||
|
||||
export function get(): Input {
|
||||
return {
|
||||
token: input.getInput('token', { required: true }),
|
||||
ignore: input.getInputList('ignore', { required: false }),
|
||||
new_issue_labels: input.getInputList('new-issue-labels', {
|
||||
required: false,
|
||||
}),
|
||||
workingDirectory:
|
||||
input.getInput('working-directory', { required: false }) ?? '.',
|
||||
};
|
||||
}
|
||||
|
||||
+37
-18
@@ -1,29 +1,32 @@
|
||||
import * as process from 'process';
|
||||
import * as os from 'os';
|
||||
import * as process from 'process';
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
|
||||
import { Cargo } from '@actions-rs/core';
|
||||
import { Cargo } from '@clechasseur/rs-actions-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(): Promise<interfaces.Report> {
|
||||
async function getData(
|
||||
ignore: string[] | undefined,
|
||||
workingDirectory: string,
|
||||
): Promise<interfaces.Report> {
|
||||
const cargo = await Cargo.get();
|
||||
await cargo.findOrInstall('cargo-audit');
|
||||
|
||||
await cargo.call(['generate-lockfile']);
|
||||
|
||||
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');
|
||||
commandArray.push('--file', `${workingDirectory}/Cargo.lock`);
|
||||
await cargo.call(commandArray, {
|
||||
ignoreReturnCode: true,
|
||||
listeners: {
|
||||
stdout: (buffer) => {
|
||||
@@ -43,8 +46,18 @@ async function getData(): Promise<interfaces.Report> {
|
||||
return JSON.parse(stdout);
|
||||
}
|
||||
|
||||
function removeTrailingSlash(str) {
|
||||
if (str[str.length - 1] === '/') {
|
||||
return str.substr(0, str.length - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
export async function run(actionInput: input.Input): Promise<void> {
|
||||
const report = await getData();
|
||||
const labels = actionInput.new_issue_labels;
|
||||
const ignore = actionInput.ignore;
|
||||
const workingDirectory = removeTrailingSlash(actionInput.workingDirectory);
|
||||
const report = await getData(ignore, workingDirectory);
|
||||
let shouldReport = false;
|
||||
if (!report.vulnerabilities.found) {
|
||||
core.info('No vulnerabilities were found');
|
||||
@@ -76,20 +89,26 @@ 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') {
|
||||
if (
|
||||
github.context.eventName == 'schedule' ||
|
||||
github.context.eventName == 'workflow_dispatch'
|
||||
) {
|
||||
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,
|
||||
labels,
|
||||
);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +117,7 @@ async function main(): Promise<void> {
|
||||
const actionInput = input.get();
|
||||
await run(actionInput);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
core.setFailed((error as Error).message);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
+79
-31
@@ -4,14 +4,15 @@ import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as nunjucks from 'nunjucks';
|
||||
|
||||
import { checks } from '@actions-rs/core';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as templates from './templates';
|
||||
import { giteaApi } from 'gitea-js';
|
||||
|
||||
interface Stats {
|
||||
critical: number;
|
||||
notices: number;
|
||||
unmaintained: number;
|
||||
unsound: number;
|
||||
other: number;
|
||||
}
|
||||
|
||||
@@ -34,6 +35,20 @@ function makeReport(
|
||||
});
|
||||
break;
|
||||
|
||||
case 'unsound':
|
||||
preparedWarnings.push({
|
||||
advisory: warning.advisory,
|
||||
package: warning.package,
|
||||
});
|
||||
break;
|
||||
|
||||
case 'notice':
|
||||
preparedWarnings.push({
|
||||
advisory: warning.advisory,
|
||||
package: warning.package,
|
||||
});
|
||||
break;
|
||||
|
||||
case 'informational':
|
||||
preparedWarnings.push({
|
||||
advisory: warning.advisory,
|
||||
@@ -72,6 +87,7 @@ function getStats(
|
||||
let critical = 0;
|
||||
let notices = 0;
|
||||
let unmaintained = 0;
|
||||
let unsound = 0;
|
||||
let other = 0;
|
||||
for (const vulnerability of vulnerabilities) {
|
||||
switch (vulnerability.advisory.informational) {
|
||||
@@ -81,6 +97,9 @@ function getStats(
|
||||
case 'unmaintained':
|
||||
unmaintained += 1;
|
||||
break;
|
||||
case 'unsound':
|
||||
unsound += 1;
|
||||
break;
|
||||
case null:
|
||||
critical += 1;
|
||||
break;
|
||||
@@ -96,6 +115,10 @@ function getStats(
|
||||
unmaintained += 1;
|
||||
break;
|
||||
|
||||
case 'unsound':
|
||||
unsound += 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Both yanked and informational types of kind
|
||||
other += 1;
|
||||
@@ -107,6 +130,7 @@ function getStats(
|
||||
critical: critical,
|
||||
notices: notices,
|
||||
unmaintained: unmaintained,
|
||||
unsound: unsound,
|
||||
other: other,
|
||||
};
|
||||
}
|
||||
@@ -115,8 +139,7 @@ function getSummary(stats: Stats): string {
|
||||
const blocks: string[] = [];
|
||||
|
||||
if (stats.critical > 0) {
|
||||
// TODO: Plural
|
||||
blocks.push(`${stats.critical} advisory(ies)`);
|
||||
blocks.push(`${stats.critical} advisories`);
|
||||
}
|
||||
if (stats.notices > 0) {
|
||||
blocks.push(`${stats.notices} notice${plural(stats.notices)}`);
|
||||
@@ -124,6 +147,9 @@ function getSummary(stats: Stats): string {
|
||||
if (stats.unmaintained > 0) {
|
||||
blocks.push(`${stats.unmaintained} unmaintained`);
|
||||
}
|
||||
if (stats.unsound > 0) {
|
||||
blocks.push(`${stats.unsound} unsound`);
|
||||
}
|
||||
if (stats.other > 0) {
|
||||
blocks.push(`${stats.other} other`);
|
||||
}
|
||||
@@ -133,18 +159,26 @@ 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 { owner, repo } = github.context.repo;
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
const stats = getStats(vulnerabilities, warnings);
|
||||
const summary = getSummary(stats);
|
||||
const body = {
|
||||
description: 'Security Audit',
|
||||
context: 'security-audit',
|
||||
};
|
||||
|
||||
core.info(`Found ${summary}`);
|
||||
|
||||
try {
|
||||
await reporter.startCheck('queued');
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state: 'pending',
|
||||
});
|
||||
} catch (error) {
|
||||
// `GITHUB_HEAD_REF` is set only for forked repos,
|
||||
// so we can check if it is a fork and not a base repo.
|
||||
@@ -175,16 +209,22 @@ See https://github.com/actions-rs/clippy-check/issues/2 for details.`);
|
||||
}
|
||||
|
||||
try {
|
||||
const body = makeReport(vulnerabilities, warnings);
|
||||
const output = {
|
||||
title: 'Security advisories found',
|
||||
summary: summary,
|
||||
text: body,
|
||||
};
|
||||
const status = stats.critical > 0 ? 'failure' : 'success';
|
||||
await reporter.finishCheck(status, output);
|
||||
// const body = makeReport(vulnerabilities, warnings);
|
||||
// const output = {
|
||||
// title: 'Security advisories found',
|
||||
// summary: summary,
|
||||
// text: body,
|
||||
// };
|
||||
const state = stats.critical > 0 ? 'failure' : 'success';
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state,
|
||||
});
|
||||
} catch (error) {
|
||||
await reporter.cancelCheck();
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state: 'error',
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -201,16 +241,17 @@ 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({
|
||||
q: `${advisoryId} in:title repo:${owner}/${repo}`,
|
||||
per_page: 1, // eslint-disable-line @typescript-eslint/camelcase
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
const results = await api.repos.issueListIssues(owner, repo, {
|
||||
q: advisoryId,
|
||||
limit: 1,
|
||||
});
|
||||
|
||||
if (results.data.total_count > 0) {
|
||||
if (results.data.length > 0) {
|
||||
core.info(
|
||||
`Seems like ${advisoryId} is mentioned already in the issues/PRs, \
|
||||
will not report an issue against it`,
|
||||
@@ -222,15 +263,18 @@ will not report an issue against it`,
|
||||
}
|
||||
|
||||
export async function reportIssues(
|
||||
client: github.GitHub,
|
||||
token: string,
|
||||
vulnerabilities: Array<interfaces.Vulnerability>,
|
||||
warnings: Array<interfaces.Warning>,
|
||||
labels: string[],
|
||||
): Promise<void> {
|
||||
const { owner, repo } = github.context.repo;
|
||||
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
|
||||
for (const vulnerability of vulnerabilities) {
|
||||
const reported = await alreadyReported(
|
||||
client,
|
||||
token,
|
||||
vulnerability.advisory.id,
|
||||
);
|
||||
if (reported) {
|
||||
@@ -240,12 +284,13 @@ export async function reportIssues(
|
||||
const body = nunjucks.renderString(templates.VULNERABILITY_ISSUE, {
|
||||
vulnerability: vulnerability,
|
||||
});
|
||||
const issue = await client.issues.create({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
const issue = await api.repos.issueCreateIssue(owner, repo, {
|
||||
title: `${vulnerability.advisory.id}: ${vulnerability.advisory.title}`,
|
||||
body: body,
|
||||
body,
|
||||
});
|
||||
for (const label of labels) {
|
||||
core.warning(`Unable to add label ${label}`);
|
||||
}
|
||||
core.info(
|
||||
`Created an issue for ${vulnerability.advisory.id}: ${issue.data.html_url}`,
|
||||
);
|
||||
@@ -254,6 +299,8 @@ export async function reportIssues(
|
||||
for (const warning of warnings) {
|
||||
let advisory: interfaces.Advisory;
|
||||
switch (warning.kind) {
|
||||
case 'unsound':
|
||||
case 'notice':
|
||||
case 'unmaintained':
|
||||
case 'informational':
|
||||
advisory = warning.advisory;
|
||||
@@ -270,7 +317,7 @@ export async function reportIssues(
|
||||
continue;
|
||||
}
|
||||
|
||||
const reported = await alreadyReported(client, advisory.id);
|
||||
const reported = await alreadyReported(token, advisory.id);
|
||||
if (reported) {
|
||||
continue;
|
||||
}
|
||||
@@ -279,12 +326,13 @@ export async function reportIssues(
|
||||
warning: warning,
|
||||
advisory: advisory,
|
||||
});
|
||||
const issue = await client.issues.create({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
const issue = await api.repos.issueCreateIssue(owner, repo, {
|
||||
title: `${advisory.id}: ${advisory.title}`,
|
||||
body: body,
|
||||
body,
|
||||
});
|
||||
for (const label of labels) {
|
||||
core.warning(`Unable to add label ${label}`);
|
||||
}
|
||||
core.info(
|
||||
`Created an issue for ${advisory.id}: ${issue.data.html_url}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user