@@ -6572,28 +6572,35 @@ const issue_1 = __webpack_require__(163);
65726572function run() {
65736573 return __awaiter(this, void 0, void 0, function* () {
65746574 try {
6575- const token = core.getInput('token', { required: true });
65766575 const trivyVersion = core
65776576 .getInput('trivy_version')
65786577 .replace(/^v/, '');
65796578 const image = core.getInput('image') || process.env.IMAGE_NAME;
6579+ const issueFlag = core.getInput('issue').toLowerCase() == 'true';
65806580 if (image === undefined || image === '') {
65816581 throw new Error('Please specify scan target image name');
65826582 }
6583- const trivyOptions = {
6583+ const trivyOption = {
65846584 severity: core.getInput('severity').replace(/\s+/g, ''),
65856585 vulnType: core.getInput('vuln_type').replace(/\s+/g, ''),
65866586 ignoreUnfixed: core.getInput('ignore_unfixed').toLowerCase() === 'true',
6587+ format: issueFlag ? 'json' : 'table',
65876588 };
65886589 const downloader = new trivy_1.Downloader();
65896590 const trivyCmdPath = yield downloader.download(trivyVersion);
6590- const result = trivy_1.Trivy.scan(trivyCmdPath, image, trivyOptions);
6591+ const result = trivy_1.Trivy.scan(trivyCmdPath, image, trivyOption);
6592+ if (!issueFlag) {
6593+ core.info(`Not create a issue because issue parameter is false.
6594+ Vulnerabilities:
6595+ ${result}`);
6596+ return;
6597+ }
65916598 const issueContent = trivy_1.Trivy.parse(result);
65926599 if (issueContent === '') {
65936600 core.info('Vulnerabilities were not found.\nYour maintenance looks good 👍');
65946601 return;
65956602 }
6596- const issueOptions = {
6603+ const issueOption = {
65976604 title: core.getInput('issue_title'),
65986605 body: issueContent,
65996606 labels: core
@@ -6605,7 +6612,8 @@ function run() {
66056612 .replace(/\s+/g, '')
66066613 .split(','),
66076614 };
6608- const output = yield issue_1.createIssue(token, issueOptions);
6615+ const token = core.getInput('token', { required: true });
6616+ const output = yield issue_1.createIssue(token, issueOption);
66096617 core.setOutput('html_url', output.htmlUrl);
66106618 core.setOutput('issue_number', output.issueNumber.toString());
66116619 }
@@ -13315,19 +13323,18 @@ class Trivy {
1331513323 '--vuln-type',
1331613324 option.vulnType,
1331713325 '--format',
13318- 'json' ,
13326+ option.format ,
1331913327 '--quiet',
1332013328 '--no-progress',
1332113329 ];
13322- if (option.ignoreUnfixed) {
13330+ if (option.ignoreUnfixed)
1332313331 args.push('--ignore-unfixed');
13324- }
1332513332 args.push(image);
1332613333 const result = child_process_1.spawnSync(trivyPath, args, {
1332713334 encoding: 'utf-8',
1332813335 });
1332913336 if (result.stdout && result.stdout.length > 0) {
13330- const vulnerabilities = JSON.parse(result.stdout);
13337+ const vulnerabilities = option.format === 'json' ? JSON.parse(result.stdout) : result.stdout ;
1333113338 if (vulnerabilities.length > 0) {
1333213339 return vulnerabilities;
1333313340 }
@@ -13359,7 +13366,6 @@ class Trivy {
1335913366 }
1336013367 issueContent += `${vulnTable}\n\n`;
1336113368 }
13362- console.debug(issueContent);
1336313369 return issueContent;
1336413370 }
1336513371 static validateOption(option) {
0 commit comments