Skip to content

Commit 9206a21

Browse files
authored
Merge pull request #72 from villers/feat/report-as-job-summary
feat: allow to active report as job summary
2 parents 40fa83a + c38d533 commit 9206a21

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)
@@ -74,6 +74,7 @@ And ensure that you're using the <a href="https://github.com/Checkmarx/kics-gith
7474
| Variable | Example Value &nbsp; | Description &nbsp; | Type | Required | Default |
7575
|-------------------------------------------|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| -------- |--------------------------------------------------------|
7676
| enable_comment | true | Enable pull request report comments | Boolean | No | false |
77+
| enable_jobs_summary | true | Enable report as jobs summary | Boolean | No | false |
7778
| comments_with_queries | true | Add queries in th pull request report comments (available when enable_comments = true) | Boolean | No | false |
7879
| 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 |
7980
| path | terraform/main.tf,Dockerfile | paths to a file or directories to scan, comma separated list | String | Yes | N/A |
@@ -237,16 +238,16 @@ You can only enable one profiler at a time, CPU or MEM.
237238

238239
```yaml
239240
steps:
240-
- uses: actions/checkout@v3
241-
- name: run kics Scan
242-
uses: checkmarx/[email protected]
243-
with:
244-
path: 'terraform'
245-
profiling: MEM
246-
output_path: myResults/
247-
- name: display kics results
248-
run: |
249-
cat myResults/results.json
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
250251
```
251252

252253
## Uploading SARIF report

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
required: false
1111
default: "false"
1212
description: "Enable pull request report comments"
13+
enable_jobs_summary:
14+
required: false
15+
default: "false"
16+
description: "Enable report as jobs summary"
1317
comments_with_queries:
1418
required: false
1519
default: "false"
@@ -106,6 +110,7 @@ runs:
106110
INPUT_TOKEN: ${{ inputs.token }}
107111
INPUT_OUTPUT_PATH: ${{ inputs.output_path }}
108112
INPUT_ENABLE_COMMENTS: ${{ inputs.enable_comments }}
113+
INPUT_ENABLE_JOBS_SUMMARY: ${{ inputs.enable_jobs_summary }}
109114
INPUT_COMMENTS_WITH_QUERIES: ${{ inputs.comments_with_queries }}
110115
INPUT_EXCLUDED_COLUMNS_FOR_COMMENTS_WITH_QUERIES: ${{ inputs.excluded_column_for_comments_with_queries }}
111116
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
@@ -48,6 +48,7 @@ async function main() {
4848
// Get ENV variables
4949
const githubToken = process.env.INPUT_TOKEN;
5050
const enableComments = process.env.INPUT_ENABLE_COMMENTS;
51+
const enableJobsSummary = process.env.INPUT_ENABLE_JOBS_SUMMARY;
5152
const commentsWithQueries = process.env.INPUT_COMMENTS_WITH_QUERIES;
5253
const excludedColumnsForCommentsWithQueries = process.env.INPUT_EXCLUDED_COLUMNS_FOR_COMMENTS_WITH_QUERIES.split(',');
5354
const outputPath = processOutputPath(process.env.INPUT_OUTPUT_PATH);
@@ -74,6 +75,9 @@ async function main() {
7475
if (enableComments.toLocaleLowerCase() === "true") {
7576
await commenter.postPRComment(parsedResults, repo, prNumber, octokit, commentsWithQueries.toLocaleLowerCase() === "true", excludedColumnsForCommentsWithQueries);
7677
}
78+
if (enableJobsSummary.toLocaleLowerCase() === "true") {
79+
await commenter.postJobSummary(parsedResults, commentsWithQueries.toLocaleLowerCase() === "true", excludedColumnsForCommentsWithQueries);
80+
}
7781

7882
annotator.annotateChangesWithResults(parsedResults);
7983

0 commit comments

Comments
 (0)