Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan committed Jan 24, 2022
1 parent 301d97c commit bd9429b
Show file tree
Hide file tree
Showing 6 changed files with 731 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.9.5

ENV REPORT_FILE="/github/workspace/report.json"
ENV MARKDOWN_FILE="/github/workspace/report.md"
ENV MUSTACHE_TEMPLATE="./report.md.mustache"

WORKDIR /usr/src/app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD ["/usr/src/app/clair-to-markdown.py"]

ENTRYPOINT ["python3"]
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Clair to markdown'
description: 'Translate clair-json-reports to markdown.'
author: [email protected]
branding:
icon: 'tag'
color: 'green'
inputs:
reportFile:
description: Path to the clair-json-report inside the contaienr.
required: false
default: "/github/workspace/report.json"
markdownFile:
description: Path to the generated markdown inside the contaienr.
required: false
default: "/github/workspace/report.md"
mustacheTemplate:
description: Path to an alternative mustache template for generating reports
required: false
default: "./report.md.mustache"
runs:
using: 'docker'
image: 'Dockerfile'
env:
REPORT_FILE: ${{ inputs.reportFile }}
MARKDOWN_FILE: ${{ inputs.markdownFile }}
MUSTACHE_TEMPLATE: ${{ inputs.mustacheTemplate }}
19 changes: 19 additions & 0 deletions clair-to-markdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import os
import json
import pystache

report_file = os.getenv("REPORT_FILE")
markdown_file = os.getenv("MARKDOWN_FILE")
mustache_file = os.getenv("MUSTACHE_TEMPLATE")

json_file=open(report_file)
json_report = json.load(json_file)

mustache_template=open(mustache_file)
template_string= mustache_template.read()


rendered_report=pystache.render(template_string, json_report)
with open(markdown_file, "w") as markdown_report:
markdown_report.write(rendered_report)
9 changes: 9 additions & 0 deletions report.md.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# {{image}}

## Vulnerabilities

| Severity | Featurename | Version | CVE | Namespace | Description | Link | Fixed by |
|----------|-------------|---------|-----|-----------|-------------|------|----------|
{{#vulnerabilities}}
|{{severity}}|{{featurename}}|{{featureversion}}|{{vulnerability}}|{{namespace}}|{{description}}|{{link}}|{{fixedby}}|
{{/vulnerabilities}}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pystache

0 comments on commit bd9429b

Please sign in to comment.