Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26f9009348 | ||
|
|
d8774e016c | ||
|
|
d1a8548176 | ||
|
|
4869f6bfcf | ||
|
|
b0356b9add | ||
|
|
34d5211002 | ||
|
|
c5a5443df7 |
+5
-2
@@ -6,14 +6,17 @@
|
||||
"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",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-function-return-type": 0
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
- name: Create npm configuration
|
||||
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
|
||||
env:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
@@ -5,12 +5,6 @@ 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
|
||||
|
||||
@@ -61,7 +61,7 @@ github-token:
|
||||
|
||||
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.
|
||||
When running the action as scheduled it will crate issues but e.g. in PR / push fails the action.
|
||||
|
||||
#### Limitations
|
||||
|
||||
|
||||
+1
-1
@@ -17,5 +17,5 @@ inputs:
|
||||
default: .
|
||||
|
||||
runs:
|
||||
using: 'node24'
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
|
||||
Vendored
+3
-11
File diff suppressed because one or more lines are too long
Generated
+8
-23
@@ -12,13 +12,11 @@
|
||||
"@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": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^24.0.0",
|
||||
"@types/nunjucks": "^3.2.4",
|
||||
"@types/node": "^20.11.17",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"@vercel/ncc": "0.38.1",
|
||||
@@ -2041,22 +2039,15 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.0.tgz",
|
||||
"integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==",
|
||||
"version": "20.14.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz",
|
||||
"integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.16.0"
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/nunjucks": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/nunjucks/-/nunjucks-3.2.6.tgz",
|
||||
"integrity": "sha512-pHiGtf83na1nCzliuAdq8GowYiXvH5l931xZ0YEHaLMNFgynpEqx+IPStlu7UaDkehfvl01e4x/9Tpwhy7Ue3w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
"version": "7.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz",
|
||||
@@ -3725,12 +3716,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/gitea-js": {
|
||||
"version": "1.23.0",
|
||||
"resolved": "https://registry.npmjs.org/gitea-js/-/gitea-js-1.23.0.tgz",
|
||||
"integrity": "sha512-f4+UPoWgDetZeZ+Awo5iI1nVdO5bjxA8+2QCeLo3oYWUYxKyzLfXgbW1EPD635wb8hLgS0DRBu5XhtiuYKEeUA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
@@ -6108,9 +6093,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
|
||||
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
||||
+1
-3
@@ -37,13 +37,11 @@
|
||||
"@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": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^24.0.0",
|
||||
"@types/nunjucks": "^3.2.4",
|
||||
"@types/node": "^20.11.17",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"@vercel/ncc": "0.38.1",
|
||||
|
||||
+31
-42
@@ -4,9 +4,12 @@ import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import * as nunjucks from 'nunjucks';
|
||||
|
||||
import { checks } from '@clechasseur/rs-actions-core';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as templates from './templates';
|
||||
import { giteaApi } from 'gitea-js';
|
||||
|
||||
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;
|
||||
@@ -163,22 +166,15 @@ export async function reportCheck(
|
||||
vulnerabilities: Array<interfaces.Vulnerability>,
|
||||
warnings: Array<interfaces.Warning>,
|
||||
): Promise<void> {
|
||||
const { owner, repo } = github.context.repo;
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
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);
|
||||
const body = {
|
||||
description: 'Security Audit',
|
||||
context: 'security-audit',
|
||||
};
|
||||
|
||||
core.info(`Found ${summary}`);
|
||||
|
||||
try {
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state: 'pending',
|
||||
});
|
||||
await reporter.startCheck('queued');
|
||||
} 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.
|
||||
@@ -209,22 +205,16 @@ 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 state = stats.critical > 0 ? 'failure' : 'success';
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state,
|
||||
});
|
||||
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);
|
||||
} catch (error) {
|
||||
await api.repos.repoCreateStatus(owner, repo, github.context.sha, {
|
||||
...body,
|
||||
state: 'error',
|
||||
});
|
||||
await reporter.cancelCheck();
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -245,13 +235,13 @@ async function alreadyReported(
|
||||
advisoryId: string,
|
||||
): Promise<boolean> {
|
||||
const { owner, repo } = github.context.repo;
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
const results = await api.repos.issueListIssues(owner, repo, {
|
||||
q: advisoryId,
|
||||
limit: 1,
|
||||
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
|
||||
});
|
||||
|
||||
if (results.data.length > 0) {
|
||||
if (results.data.total_count > 0) {
|
||||
core.info(
|
||||
`Seems like ${advisoryId} is mentioned already in the issues/PRs, \
|
||||
will not report an issue against it`,
|
||||
@@ -270,7 +260,7 @@ export async function reportIssues(
|
||||
): Promise<void> {
|
||||
const { owner, repo } = github.context.repo;
|
||||
|
||||
const api = giteaApi(process.env.GITHUB_SERVER_URL!, { token });
|
||||
const client = github.getOctokit(token, { userAgent: USER_AGENT });
|
||||
|
||||
for (const vulnerability of vulnerabilities) {
|
||||
const reported = await alreadyReported(
|
||||
@@ -284,13 +274,13 @@ export async function reportIssues(
|
||||
const body = nunjucks.renderString(templates.VULNERABILITY_ISSUE, {
|
||||
vulnerability: vulnerability,
|
||||
});
|
||||
const issue = await api.repos.issueCreateIssue(owner, repo, {
|
||||
const issue = await client.rest.issues.create({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
title: `${vulnerability.advisory.id}: ${vulnerability.advisory.title}`,
|
||||
body,
|
||||
body: body,
|
||||
labels,
|
||||
});
|
||||
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}`,
|
||||
);
|
||||
@@ -326,13 +316,12 @@ export async function reportIssues(
|
||||
warning: warning,
|
||||
advisory: advisory,
|
||||
});
|
||||
const issue = await api.repos.issueCreateIssue(owner, repo, {
|
||||
const issue = await client.rest.issues.create({
|
||||
owner: owner,
|
||||
repo: 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