Skip to content

Commit 7e2907d

Browse files
committed
[prettier] Modify trailling comma to es5
1 parent c71a52d commit 7e2907d

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

.prettierrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
semi: true
22
singleQuote: true
3-
trailingComma: all
3+
trailingComma: es5
44
parser": typescript
55
bracketSpacing: true

dist/index.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13307,26 +13307,30 @@ Downloader.trivyRepository = {
1330713307
repo: 'trivy',
1330813308
};
1330913309
class Trivy {
13310-
static scan(trivyPath, image, options) {
13310+
static scan(trivyPath, image, option) {
13311+
Trivy.validateOption(option);
1331113312
const args = [
1331213313
'--severity',
13313-
options.severity,
13314+
option.severity,
1331413315
'--vuln-type',
13315-
options.vulnType,
13316+
option.vulnType,
1331613317
'--format',
1331713318
'json',
1331813319
'--quiet',
1331913320
'--no-progress',
1332013321
];
13321-
if (options.ignoreUnfixed) {
13322+
if (option.ignoreUnfixed) {
1332213323
args.push('--ignore-unfixed');
1332313324
}
1332413325
args.push(image);
1332513326
const result = child_process_1.spawnSync(trivyPath, args, {
1332613327
encoding: 'utf-8',
1332713328
});
1332813329
if (result.stdout && result.stdout.length > 0) {
13329-
return JSON.parse(result.stdout);
13330+
const vulnerabilities = JSON.parse(result.stdout);
13331+
if (vulnerabilities.length > 0) {
13332+
return vulnerabilities;
13333+
}
1333013334
}
1333113335
throw new Error(`Failed vulnerability scan using Trivy.
1333213336
stdout: ${result.stdout}
@@ -13358,6 +13362,21 @@ class Trivy {
1335813362
console.debug(issueContent);
1335913363
return issueContent;
1336013364
}
13365+
static validateOption(option) {
13366+
const allowedSeverities = /UNKNOWN|LOW|MEDIUM|HIGH|CRITICAL/;
13367+
const allowedVulnTypes = /os|library/;
13368+
for (const severity of option.severity.split(',')) {
13369+
if (!allowedSeverities.test(severity)) {
13370+
throw new Error(`severity option error: ${severity} is unknown severity`);
13371+
}
13372+
}
13373+
for (const vulnType of option.vulnType.split(',')) {
13374+
if (!allowedVulnTypes.test(vulnType)) {
13375+
throw new Error(`vuln-type option error: ${vulnType} is unknown vuln-type`);
13376+
}
13377+
}
13378+
return true;
13379+
}
1336113380
}
1336213381
exports.Trivy = Trivy;
1336313382

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ async function run() {
3232
const result: Vulnerability[] = Trivy.scan(
3333
trivyCmdPath,
3434
image,
35-
trivyOptions,
35+
trivyOptions
3636
);
3737
const issueContent: string = Trivy.parse(result);
3838

3939
if (issueContent === '') {
4040
core.info(
41-
'Vulnerabilities were not found.\nYour maintenance looks good 👍',
41+
'Vulnerabilities were not found.\nYour maintenance looks good 👍'
4242
);
4343
return;
4444
}

src/issue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IssueOption, IssueResponse } from './interface';
44

55
export async function createIssue(
66
token: string,
7-
options: IssueOption,
7+
options: IssueOption
88
): Promise<IssueResponse> {
99
const client: Octokit = new github.GitHub(token);
1010
const {

0 commit comments

Comments
 (0)