Skip to content

Commit e987fdd

Browse files
authoredDec 23, 2020
Fix more than 50 annotations (#7)
* Fix check run creation when there are more than 50 annotations * Update Scan workflow
1 parent 7a34679 commit e987fdd

File tree

8 files changed

+2032
-1387
lines changed

8 files changed

+2032
-1387
lines changed
 

‎.github/workflows/scan.yaml

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
name: Scan
1+
name: Scan Image
22

33
on:
44
push:
55
workflow_dispatch:
6-
inputs:
7-
image:
8-
description: Image to scan
9-
required: true
10-
default: alpine:3.7
116

127
jobs:
138
build:
149
runs-on: ubuntu-latest
1510

1611
steps:
17-
- name: Scan image
12+
- name: Scan dummy-vuln-app
1813
id: scan
19-
uses: sysdiglabs/scan-action@use-inline-scan-v2
14+
uses: sysdiglabs/scan-action@master
2015
with:
21-
image-tag: "alpine:3.7"
22-
sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
23-
pull-from-registry: true
16+
# Tag of the image to analyse
17+
image-tag: sysdiglabs/dummy-vuln-app:latest
18+
# API token for Sysdig Scanning auth
19+
sysdig-secure-token: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
20+
input-type: pull
21+
ignore-failed-scan: true

‎README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
# Sysdig Secure Inline Scan Action
23

3-
This action performs analysis on locally built container image and posts the result to Sysdig Secure. For more information about Secure Inline Scan, see https://github.com/sysdiglabs/secure-inline-scan and read [Sysdig Secure documentation](https://docs.sysdig.com/en/image-scanning.html).
4+
This action performs analysis on locally built container image and posts the result to Sysdig Secure. For more information about Secure Inline Scan, see [Sysdig Secure documentation](https://docs.sysdig.com/en/image-scanning.html).
45

56
## Inputs
67

@@ -138,4 +139,4 @@ and then add another step for uploading the SARIF report, providing the path in
138139
sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
139140
input-type: docker-archive
140141
input-path: artifacts/my-image.tar
141-
```
142+
```

‎dist/index.js

+292-310
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.js

+30-4
Original file line numberDiff line numberDiff line change
@@ -384,24 +384,50 @@ async function generateChecks(scanResult, evaluationResults, vulnerabilities) {
384384
core.warning("No github-token provided. Skipping creation of check run");
385385
}
386386

387-
try {
387+
let octokit;
388+
let annotations;
389+
let check_run;
388390

389-
const octokit = github.getOctokit(githubToken);
391+
try {
392+
octokit = github.getOctokit(githubToken);
393+
annotations = getReportAnnotations(evaluationResults, vulnerabilities)
394+
} catch (error) {
395+
core.warning("Error creating octokit: " + error);
396+
return;
397+
}
390398

391-
await octokit.checks.create({
399+
try {
400+
check_run = await octokit.checks.create({
392401
owner: github.context.repo.owner,
393402
repo: github.context.repo.repo,
394403
name: "Scan results",
395404
head_sha: github.context.sha,
396405
output: {
397406
title: "Inline scan results",
398407
summary: "Scan result is " + scanResult,
399-
annotations: getReportAnnotations(evaluationResults, vulnerabilities)
408+
annotations: annotations.slice(0,50)
400409
}
401410
});
402411
} catch (error) {
403412
core.warning("Error creating check run: " + error);
404413
}
414+
415+
try {
416+
for (let i = 50; i < annotations.length; i+=50) {
417+
await octokit.checks.update({
418+
owner: github.context.repo.owner,
419+
repo: github.context.repo.repo,
420+
check_run_id: check_run.data.id,
421+
output: {
422+
title: "Inline scan results",
423+
summary: "Scan result is " + scanResult,
424+
annotations: annotations.slice(i, i+50)
425+
}
426+
});
427+
}
428+
} catch (error) {
429+
core.warning("Error updating check run: " + error);
430+
}
405431
}
406432

407433
function getReportAnnotations(evaluationResults, vulnerabilities) {

0 commit comments

Comments
 (0)