Skip to content

Commit aaa586a

Browse files
author
Mickaël Villers
authored
Merge branch 'master' into feat/allow-disable-annotation
2 parents 1df7382 + 9206a21 commit aaa586a

File tree

7 files changed

+73
-22
lines changed

7 files changed

+73
-22
lines changed

.github/workflows/test_action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
output_formats: sarif
2121
ignore_on_exit: results
2222
enable_comments: true
23+
enable_jobs_summary: true
2324
comments_with_queries: true
2425
excluded_column_for_comments_with_queries: "description_id,similarity_id,search_line,search_value,cis_description_id,cis_description_title,cis_description_text,cloud_provider"
2526
- run: ls -la && ls -la myoutput

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- [KICS Github Action](#kics-github-action)
88
- [Integrate KICS into your GitHub workflows](#integrate-kics-into-your-github-workflows)
9-
- [Supported Platforms](#supported-platforms)
9+
- [Supported Platforms](#supported-platforms)
1010
- [Please find more info in the official website: <a href="https://kics.io">kics.io</a>](#please-find-more-info-in-the-official-website-kicsio)
1111
- [Inputs](#inputs)
1212
- [Simple usage example](#simple-usage-example)
@@ -76,6 +76,7 @@ And ensure that you're using the <a href="https://github.com/Checkmarx/kics-gith
7676
| enable_comment | true | Enable pull request report comments | Boolean | No | false |
7777
| disable_annotations | true | Disable annotations report | Boolean | No | false |
7878
| comments_with_queries | true | Add queries in th pull request report comments (available when enable_comments = true) | Boolean | No | false |
79+
| enable_jobs_summary | true | Enable report as jobs summary | Boolean | No | false |
7980
| excluded_column_for_comments_with_queries | description_id,similarity_id,search_line,search_value | Excluded columns for the comment with queries, accepts a comma separated list | String | No | description_id,similarity_id,search_line,search_value |
8081
| path | terraform/main.tf,Dockerfile | paths to a file or directories to scan, comma separated list | String | Yes | N/A |
8182
| ignore_on_exit | results | defines which non-zero exit codes should be ignored (all, results, errors, none) | String | No | none |
@@ -238,16 +239,16 @@ You can only enable one profiler at a time, CPU or MEM.
238239

239240
```yaml
240241
steps:
241-
- uses: actions/checkout@v3
242-
- name: run kics Scan
243-
uses: checkmarx/[email protected]
244-
with:
245-
path: 'terraform'
246-
profiling: MEM
247-
output_path: myResults/
248-
- name: display kics results
249-
run: |
250-
cat myResults/results.json
242+
- uses: actions/checkout@v3
243+
- name: run kics Scan
244+
uses: checkmarx/[email protected]
245+
with:
246+
path: 'terraform'
247+
profiling: MEM
248+
output_path: myResults/
249+
- name: display kics results
250+
run: |
251+
cat myResults/results.json
251252
```
252253

253254
## Uploading SARIF report

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
required: false
1515
default: "false"
1616
description: "Enable pull request report comments"
17+
enable_jobs_summary:
18+
required: false
19+
default: "false"
20+
description: "Enable report as jobs summary"
1721
comments_with_queries:
1822
required: false
1923
default: "false"
@@ -111,6 +115,7 @@ runs:
111115
INPUT_OUTPUT_PATH: ${{ inputs.output_path }}
112116
INPUT_DISABLE_ANNOTATIONS: ${{ inputs.disable_annotations }}
113117
INPUT_ENABLE_COMMENTS: ${{ inputs.enable_comments }}
118+
INPUT_ENABLE_JOBS_SUMMARY: ${{ inputs.enable_jobs_summary }}
114119
INPUT_COMMENTS_WITH_QUERIES: ${{ inputs.comments_with_queries }}
115120
INPUT_EXCLUDED_COLUMNS_FOR_COMMENTS_WITH_QUERIES: ${{ inputs.excluded_column_for_comments_with_queries }}
116121
INPUT_OUTPUT_FORMATS: ${{ inputs.output_formats }}

package-lock.json

Lines changed: 42 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/Checkmarx/kics-github-action#readme",
2121
"dependencies": {
22-
"@actions/core": "^1.6.0",
22+
"@actions/core": "^1.10.0",
2323
"@actions/exec": "^1.1.0",
2424
"@actions/github": "^5.0.0",
2525
"@actions/io": "^1.1.1",

src/commenter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const moment = require('moment')
2+
const { summary } = require('@actions/core/lib/summary');
23

34
const kicsLogo = "https://user-images.githubusercontent.com/74597872/143567454-f65ad285-00d8-4875-845d-568d2e67d868.png"
45
const severityOrder = ["HIGH", "MEDIUM", "LOW", "INFO", "TRACE"];
@@ -158,6 +159,12 @@ async function postPRComment(results, repo, prNumber, octokit, commentWithQuerie
158159
}
159160
}
160161

162+
async function postJobSummary(results, commentWithQueries = false, excludedColumnsForCommentsWithQueries) {
163+
const message = createComment(results, commentWithQueries, excludedColumnsForCommentsWithQueries);
164+
await summary.addRaw(message).write()
165+
}
166+
161167
module.exports = {
162-
postPRComment
168+
postPRComment,
169+
postJobSummary
163170
};

src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ async function main() {
4949
const githubToken = process.env.INPUT_TOKEN;
5050
const disableAnnotations = process.env.INPUT_DISABLE_ANNOTATIONS;
5151
const enableComments = process.env.INPUT_ENABLE_COMMENTS;
52+
const enableJobsSummary = process.env.INPUT_ENABLE_JOBS_SUMMARY;
5253
const commentsWithQueries = process.env.INPUT_COMMENTS_WITH_QUERIES;
5354
const excludedColumnsForCommentsWithQueries = process.env.INPUT_EXCLUDED_COLUMNS_FOR_COMMENTS_WITH_QUERIES.split(',');
5455
const outputPath = processOutputPath(process.env.INPUT_OUTPUT_PATH);
@@ -78,6 +79,9 @@ async function main() {
7879
if (enableComments.toLocaleLowerCase() === "true") {
7980
await commenter.postPRComment(parsedResults, repo, prNumber, octokit, commentsWithQueries.toLocaleLowerCase() === "true", excludedColumnsForCommentsWithQueries);
8081
}
82+
if (enableJobsSummary.toLocaleLowerCase() === "true") {
83+
await commenter.postJobSummary(parsedResults, commentsWithQueries.toLocaleLowerCase() === "true", excludedColumnsForCommentsWithQueries);
84+
}
8185

8286
setWorkflowStatus(exitCode);
8387
cleanupOutput(outputPath.resultsJSONFile, outputFormats);

0 commit comments

Comments
 (0)