Skip to content

Commit

Permalink
feat(twistlock): add compliance issues to reports
Browse files Browse the repository at this point in the history
  • Loading branch information
error418 committed Jul 5, 2019
1 parent 9923610 commit f4ef9ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/twistlock/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export namespace TwistlockModel {
interface Result {
id: string;
distro: string;
compliances?: Compliance[];
complianceDistribution: SeverityCount;
vulnerabilities?: Vulnerability[];
vulnerabilityDistribution: SeverityCount;
Expand All @@ -20,6 +21,11 @@ export namespace TwistlockModel {
total: number;
}

interface Compliance {
title: string;
severity: string;
}

interface Vulnerability {
id: string;
status: string;
Expand Down
14 changes: 11 additions & 3 deletions templates/twistlock/scan.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
| Compliance | {{ result.complianceDistribution.critical }} | {{ result.complianceDistribution.high }} | {{ result.complianceDistribution.medium }} | {{ result.complianceDistribution.low }} | {{ result.complianceDistribution.total }} |
| Vulnerabilities | {{ result.vulnerabilityDistribution.critical }} | {{ result.vulnerabilityDistribution.high }} | {{ result.vulnerabilityDistribution.medium }} | {{ result.vulnerabilityDistribution.low }} | {{ result.vulnerabilityDistribution.total }} |


{% if result.compliances -%}
## Compliance Issues
{% for compliance in result.compliances -%}
* **{{ compliance.severity }}:** {{ compliance.title }}
{% endfor %}
{% endif %}

{% if result.vulnerabilities -%}
## Vulnerabilities
{% for vul in result.vulnerabilities | sort(true, false, "cvss") -%}
{% for vul in result.vulnerabilities | sort(true, false, "cvss") -%}
### {{ vul.id }}

| CVSS | Severity | Package | Version | |
Expand All @@ -38,6 +45,7 @@
{%- endif %}

---
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
10 changes: 8 additions & 2 deletions test/mock/twistlock-report-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
{
"id": "sha256:268bc513b12e6bf7bfb41a7f0b18d69ce69ad952b5ee7489318fbb7b870f4a33",
"distro": "CentOS Linux 7 (Core)",
"compliances": [
{
"title": "(CIS_Docker_CE_v1.1.0 - 4.1) Image should be created with a non-root user",
"severity": "high"
}
],
"complianceDistribution": {
"critical": 0,
"high": 0,
"high": 1,
"medium": 0,
"low": 0,
"total": 0
"total": 1
},
"vulnerabilities": [
{
Expand Down

0 comments on commit f4ef9ec

Please sign in to comment.