Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf consumer #52

Merged
merged 38 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
af7ff59
add the ability to enrich sbom document with security scorecard score
northdpole Oct 15, 2023
627d767
lint:
northdpole Oct 15, 2023
0554b5e
fix logging
northdpole Oct 16, 2023
22355d2
fix depsdev + tests
northdpole Oct 18, 2023
4bd109f
dependency track owner tagging
northdpole Oct 18, 2023
4e8a96d
Update components/consumers/dependency-track/main.go
northdpole Oct 18, 2023
c6ed2a1
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
da7c902
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
a71558b
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
0cb0d14
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
8872537
Update components/consumers/dependency-track/main.go
northdpole Oct 18, 2023
08ea1a3
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
73deb59
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
341ba68
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
1e54471
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
38115f8
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
e23bf7b
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
bcff58b
Update components/enrichers/depsdev/main_test.go
northdpole Oct 18, 2023
ac3a3be
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
2eca5da
Update components/consumers/dependency-track/main.go
northdpole Oct 18, 2023
ad8403a
Merge branch 'main' into dependency-track-improvements
northdpole Oct 18, 2023
ad3de34
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
f68e8fa
Update components/consumers/dependency-track/main.go
northdpole Oct 18, 2023
a2ce9ab
Update components/consumers/dependency-track/main.go
northdpole Oct 18, 2023
2d5cbdc
Update components/consumers/dependency-track/main_test.go
northdpole Oct 18, 2023
7c3e656
add ability to run zap without automation framework
northdpole Nov 4, 2023
2bb7508
wip pdf consumer
northdpole Nov 12, 2023
842a6cb
Merge branch 'main' into pdf-consumer
northdpole Nov 12, 2023
85616d8
nit
northdpole Nov 12, 2023
74f9a53
pdf-consumer
northdpole Nov 16, 2023
e71722e
make default template legible
northdpole Nov 16, 2023
9a803e5
lint
northdpole Nov 19, 2023
bbd8b3f
lint
northdpole Nov 19, 2023
32b78f7
cleanup
northdpole Nov 19, 2023
8e9cdb8
Update components/consumers/pdf/main.go
northdpole Nov 19, 2023
81f756f
cleanup
northdpole Nov 19, 2023
66155ac
nosec
northdpole Nov 19, 2023
0135d0b
lint
northdpole Nov 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/consumers/dependency-track/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func addOwnersTags(owners []string) error {
_, err = client.Project.Update(context.Background(), project)
return err
}

func uploadBOM(bom string, projectVersion string) (string, error) {
if projectVersion == "" {
projectVersion = "Unknown"
Expand Down
55 changes: 55 additions & 0 deletions components/consumers/pdf/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
subinclude(
"//build/defs:buildkit",
"///k8s//build/defs:k8s",
"//build/defs:dracon",
)

go_binary(
name = "pdf",
srcs = [
"main.go",
],
static = True,
deps = [
"//api/proto/v1",
"//components/consumers",
"//pkg/enumtransformers",
"//pkg/templating",
"//third_party/go/github.com/aws/aws-sdk-go",
"//third_party/go/github.com/playwright-community/playwright-go",
"//third_party/go/google.golang.org/protobuf",
],
)

filegroup(
name = "template",
srcs = ["default.html"],
)
# buildkit_distroless_image(
# name = "image",
# srcs = [":pdf"],
# visibility = [
# "//examples/...",
# ],
# )

buildkit_image(
name = "image",
srcs = [
":pdf",
":template",
],
dockerfile = "Dockerfile",
visibility = [
"//examples/...",
],
)

dracon_component(
name = "pdf",
images = [
":image",
],
task = "task.yaml",
visibility = ["//examples/pipelines/..."],
)
11 changes: 11 additions & 0 deletions components/consumers/pdf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:latest

WORKDIR /playwright
RUN go mod init github.com/ocurity/pdf-consumer &&\
go get -u github.com/playwright-community/playwright-go &&\
go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps

ENV PATH="${PATH}:/go/pkg/mod/github.com/playwright-community"
COPY components/consumers/pdf/pdf /playwright/pdf
COPY components/consumers/pdf/default.html /playwright/default.html
ENTRYPOINT ["/playwright/pdf"]
183 changes: 183 additions & 0 deletions components/consumers/pdf/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vulnerability Scan Results</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
color: #333;
margin: 20px;
}

header {
text-align: center;
margin-bottom: 20px;
}

header img {
max-width: 100px;
height: auto;
}

.report {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.report-title {
font-size: 24px;
font-weight: bold;
color: #333;
text-align: center;
margin-bottom: 20px;
}

.scan {
margin-bottom: 20px;
}

.scan-title {
font-size: 20px;
font-weight: bold;
color: #007bff;
margin-bottom: 10px;
}

.scan-details {
margin-top: 10px;
color: #555;
}

.finding {
border: 1px solid #eee;
border-radius: 5px;
margin: 15px 0;
padding: 15px;
background-color: #f9f9f9;
/* Alternating background color */
}

.finding:nth-child(even) {
background-color: #f5f5f5;
/* Alternating background color for even elements */
}

.finding-title {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}

.finding-details {
color: #777;
}

.introduction {
margin-bottom: 20px;
}

.summary {
margin-top: 20px;
border-top: 1px solid #ddd;
padding-top: 20px;
color: #555;
}

.placeholder-metrics {
display: flex;
justify-content: space-around;
margin-bottom: 20px;
}

.placeholder-graph {
height: 200px;
background-color: #eaeaea;
border-radius: 5px;
}
</style>
</head>

<body>

<header>
<img src="https://github.com/ocurity/dracon/raw/main/assets/dracon-logo-light.svg#gh-dark-mode-only" alt="Logo">
<h1>Dracon Report</h1>
</header>

<div class="report">
<div class="report-title">Scan Results</div>

<!-- Introduction -->
<div class="introduction">
<p>This report summarizes the results of running Dracon.</p>
</div>
<!-- Summary -->
<div class="summary">
<h2>Summary</h2>

<!-- Placeholder Metrics -->
<div class="placeholder-metrics">
<div>
<h3>Total Number of Findings</h3>
<p>10</p>
</div>
<div>
<h3>Total High Severity Findings</h3>
<p>10</p>
</div>
</div>

<!-- Placeholder Graph -->
<div class="placeholder-graph"></div>

<p>The vulnerability scans have identified potential issues that need attention. It is recommended to review
and address the findings promptly to enhance the security of our systems.</p>
</div>

<!-- Scan -->
{{range .}}
<div class="scan">
<div class="scan-title">{{.OriginalResults.ScanInfo.ScanUuid}} - {{.OriginalResults.ToolName}}</div>
<div class="scan-details">
<div><strong>Start Time:</strong> {{.OriginalResults.ScanInfo.ScanStartTime}}</div>
</div>
{{range .Issues}}
<div class="finding">
<div class="finding-title">{{.RawIssue.Title}}</div>
<div class="finding-details">
<div>Target: {{.RawIssue.Target}} </div>
<div>Type: {{.RawIssue.Type}} </div>
<div>CVSS: {{.RawIssue.Cvss}} </div>
<div>CVE: {{.RawIssue.Cve}} </div>
<div>Confidence: {{.RawIssue.Confidence}} </div>
<div>Severity: {{.RawIssue.Severity}} </div>
<div>Description: {{.RawIssue.Description}} </div>
<div>First Seen: {{.FirstSeen}} </div>
<div>Seen Before Times: {{.Count}} </div>
<div>False Positive?:{{.FalsePositive}} </div>
<div>Last Updated: {{.UpdatedAt}} </div>
{{ range $key,$element := .Annotations }}
<p><b>{{$key}}</b>:{{$element}}</p>
{{end}}
<div>SBOM<pre>{{.RawIssue.CycloneDXSBOM}}</pre></div>
</div>
</div>
{{end}}

<!-- Add more scans as needed -->

</div>
{{end}}
</body>

</html>
91 changes: 91 additions & 0 deletions components/consumers/pdf/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# DO NOT EDIT. Code generated by:
# github.com/ocurity/dracon//build/tools/kustomize-component-generator.

apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- task.yaml
patches:
# Add the Task to the Tekton Pipeline.
- patch: |
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: unused
spec:
workspaces:
- name: source-code-ws
tasks:
- name: consumer-pdf
taskRef:
name: consumer-pdf
workspaces:
- name: source-code-ws
workspace: source-code-ws
params:
- name: consumer-pdf-s3-access-key-id
value: $(params.consumer-pdf-s3-access-key-id)
- name: consumer-pdf-s3-secret-access-key
value: $(params.consumer-pdf-s3-secret-access-key)
- name: consumer-pdf-s3-bucket-name
value: $(params.consumer-pdf-s3-bucket-name)
- name: consumer-pdf-s3-bucket-region
value: $(params.consumer-pdf-s3-bucket-region)
- name: consumer-pdf-template-location
value: $(params.consumer-pdf-template-location)
params:
- name: consumer-pdf-s3-access-key-id
type: string
- name: consumer-pdf-s3-secret-access-key
type: string
- name: consumer-pdf-s3-bucket-name
type: string
- name: consumer-pdf-s3-bucket-region
type: string
- name: consumer-pdf-template-location
type: string
default: /playwright/default.html
target:
kind: Pipeline
# Add anchors to Task.
- patch: |
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: consumer-pdf
labels:
v1.dracon.ocurity.com/component: consumer
spec:
params:
- name: anchors
type: array
description: A list of tasks that this task depends on using their anchors.
default: []
results:
- name: anchor
description: An anchor to allow other tasks to depend on this task.
steps:
- name: anchor
image: docker.io/busybox:1.35.0
script: echo "$(context.task.name)" > "$(results.anchor.path)"
target:
kind: Task
name: consumer-pdf
# If we have an enricher-aggregator task in the pipeline (added by the
# enricher-aggregator component), make the consumer depend on the completion of
# it.
- patch: |
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: unused
spec:
tasks:
- name: consumer-pdf
params:
- name: anchors
value:
- $(tasks.enricher-aggregator.results.anchor)
target:
kind: Pipeline
annotationSelector: v1.dracon.ocurity.com/has-enricher-aggregator=true
Loading
Loading