Create viewer for SBOM and VEX data.
[oam.git] / code / container-analysis / viewer / views / index.pug
1 //-
2 //- Copyright 2023 highstreet technologies and others
3 //-
4 //- Licensed under the Apache License, Version 2.0 (the "License");
5 //- you may not use this file except in compliance with the License.
6 //- You may obtain a copy of the License at
7 //-
8 //-     http://www.apache.org/licenses/LICENSE-2.0
9 //-
10 //- Unless required by applicable law or agreed to in writing, software
11 //- distributed under the License is distributed on an "AS IS" BASIS,
12 //- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 //- See the License for the specific language governing permissions and
14 //- limitations under the License.
15 //-
16  
17 extends layout
18
19 block content
20   h1= title
21   p Date: #{date}
22
23   h2 Images
24   table(class='table  table-striped table-hover') 
25     thead(class='thead-dark')
26       tr 
27         th(scope=col, class='text-left') Name
28         th(scope=col, class='text-right') Version
29         th(scope=col, class='text-center') SBOM
30         th(scope=col, class='text-right') # Files
31         th(scope=col, class='text-right') # Packages
32         th(scope=col, class='text-right') Created
33         th(scope=col, class='text-center') VEX
34         th(scope=col, class='text-right') # Components
35         th(scope=col, class='text-right') # Vulnerabilities
36         th(scope=col, class='text-right') # Critical
37         th(scope=col, class='text-right') # High
38         th(scope=col, class='text-right') # Medium
39         th(scope=col, class='text-right') # Low
40         th(scope=col, class='text-right') # Unknown
41         th(scope=col, class='text-right') # None
42         th(scope=col, class='text-center') Chart
43         th(scope=col, class='text-right') Created
44         
45     tbody 
46       each image in images
47         tr
48           td(scope=col, class='text-left')= image.name
49           td(scope=col, class='text-right')= image.version
50           td(scope=col, class='text-center')
51             a(href=image.sbom.url, title=image.sbom.url) link
52           td(scope=col, class='text-right')= image.sbom.files
53           td(scope=col, class='text-right')= image.sbom.packages
54           td(scope=col, class='text-right')= image.sbom.created
55           td(scope=col, class='text-center')
56             a(href=image.vex.url,title=image.vex.url) link
57           td(scope=col, class='text-right')= image.vex.components
58           td(scope=col, class='text-right')= image.vex.vulnerabilities.count
59           td(scope=col, class='text-right')= image.vex.vulnerabilities.critical
60           td(scope=col, class='text-right')= image.vex.vulnerabilities.high
61           td(scope=col, class='text-right')= image.vex.vulnerabilities.medium
62           td(scope=col, class='text-right')= image.vex.vulnerabilities.low
63           td(scope=col, class='text-right')= image.vex.vulnerabilities.unknown
64           td(scope=col, class='text-right')= image.vex.vulnerabilities.none
65           td(scope=col, class='text-center')
66             svg( width=`${10 * image.vex.vulnerabilities.scale}`, height=`${10 * image.vex.vulnerabilities.scale}`, viewbox=`${-5 * image.vex.vulnerabilities.scale} ${-5 * image.vex.vulnerabilities.scale} ${10 * image.vex.vulnerabilities.scale} ${10 * image.vex.vulnerabilities.scale}`, transform=`scale( ${image.vex.vulnerabilities.scale} ) rotate(180 0 0)`)
67               circle(cx='0', cy='0', r='5', fill='white', stroke='black', stroke-width='0')
68               each slice, i in image.vex.vulnerabilities.slices
69                 path(d=`M0,0 L${0 + 5 * Math.cos(slice.startAngle)},${0 + 5 * Math.sin(slice.startAngle)} A5,5 0 ${slice.arc}, 1${0 + 5 * Math.cos(slice.endAngle)},${0 + 5 * Math.sin(slice.endAngle)} Z`, fill=slice.color)
70                   title= slice.name + ': ' + slice.count
71               circle(cx='0', cy='0', r='2', fill='white', stroke='black', stroke-width='0')
72           td(scope=col, class='text-right')= image.vex.created