Skip to content

Commit

Permalink
Fix more than 50 annotations (#7)
Browse files Browse the repository at this point in the history
* Fix check run creation when there are more than 50 annotations

* Update Scan workflow
  • Loading branch information
airadier authored Dec 23, 2020
1 parent 7a34679 commit e987fdd
Show file tree
Hide file tree
Showing 8 changed files with 2,032 additions and 1,387 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: Scan
name: Scan Image

on:
push:
workflow_dispatch:
inputs:
image:
description: Image to scan
required: true
default: alpine:3.7

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Scan image
- name: Scan dummy-vuln-app
id: scan
uses: sysdiglabs/scan-action@use-inline-scan-v2
uses: sysdiglabs/scan-action@master
with:
image-tag: "alpine:3.7"
sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
pull-from-registry: true
# Tag of the image to analyse
image-tag: sysdiglabs/dummy-vuln-app:latest
# API token for Sysdig Scanning auth
sysdig-secure-token: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
input-type: pull
ignore-failed-scan: true
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Sysdig Secure Inline Scan Action

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).
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).

## Inputs

Expand Down Expand Up @@ -138,4 +139,4 @@ and then add another step for uploading the SARIF report, providing the path in
sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
input-type: docker-archive
input-path: artifacts/my-image.tar
```
```
602 changes: 292 additions & 310 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

34 changes: 30 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,24 +384,50 @@ async function generateChecks(scanResult, evaluationResults, vulnerabilities) {
core.warning("No github-token provided. Skipping creation of check run");
}

try {
let octokit;
let annotations;
let check_run;

const octokit = github.getOctokit(githubToken);
try {
octokit = github.getOctokit(githubToken);
annotations = getReportAnnotations(evaluationResults, vulnerabilities)
} catch (error) {
core.warning("Error creating octokit: " + error);
return;
}

await octokit.checks.create({
try {
check_run = await octokit.checks.create({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
name: "Scan results",
head_sha: github.context.sha,
output: {
title: "Inline scan results",
summary: "Scan result is " + scanResult,
annotations: getReportAnnotations(evaluationResults, vulnerabilities)
annotations: annotations.slice(0,50)
}
});
} catch (error) {
core.warning("Error creating check run: " + error);
}

try {
for (let i = 50; i < annotations.length; i+=50) {
await octokit.checks.update({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
check_run_id: check_run.data.id,
output: {
title: "Inline scan results",
summary: "Scan result is " + scanResult,
annotations: annotations.slice(i, i+50)
}
});
}
} catch (error) {
core.warning("Error updating check run: " + error);
}
}

function getReportAnnotations(evaluationResults, vulnerabilities) {
Expand Down
Loading

0 comments on commit e987fdd

Please sign in to comment.