Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .templates/new-scanner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

*.tar
31 changes: 31 additions & 0 deletions .templates/new-scanner/.helm-docs.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- /*
SPDX-FileCopyrightText: 2021 iteratec GmbH

SPDX-License-Identifier: Apache-2.0
*/ -}}

{{- define "extra.docsSection" -}}
---
title: "new-scanner"
category: "scanner"
type: "Network"
state: "released"
appVersion: "{{ template "chart.appVersion" . }}"
usecase: "NEW SCANNER USECASE"
---

ADD A [LOGO]() HERE!

{{- end }}

{{- define "extra.dockerDeploymentSection" -}}
## Supported Tags
- `latest` (represents the latest stable release build)
- tagged releases, e.g. `{{ template "chart.appVersion" . }}`
{{- end }}

{{- define "extra.chartAboutSection" -}}
## What is new-scanner?

Please write some information about the new scanner.
{{- end }}
40 changes: 40 additions & 0 deletions .templates/new-scanner/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# Node.js files
node_modules/*
package.json
package-lock.json
src/*
config/*
Dockerfile
.dockerignore
*.tar
parser/*
scanner/*
integration-tests/*
examples/*
docs/*
Makefile
26 changes: 26 additions & 0 deletions .templates/new-scanner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: new-scanner
description: A Helm chart for the new-scanner security Scanner that integrates with the secureCodeBox.

type: application
# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
version: v3.1.0-alpha1
appVersion: "" # Set appVersion
kubeVersion: ">=v1.11.0-0"

keywords:
- security
- new-scanner
- scanner
- secureCodeBox
home: https://docs.securecodebox.io/docs/scanners/new-scanner
icon: https://docs.securecodebox.io/img/integrationIcons/new-scanner.svg # Upload new icon
sources:
- https://github.com/secureCodeBox/secureCodeBox
maintainers:
- name: iteratec GmbH
email: [email protected]
12 changes: 12 additions & 0 deletions .templates/new-scanner/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/make -f
#
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0
#

include_guard = set
scanner = new-scanner
custom_scanner = set

include ../../scanners.mk
49 changes: 49 additions & 0 deletions .templates/new-scanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "new-scanner"
category: "scanner"
type: "Network"
state: "released"
appVersion: ""
usecase: "NEW SCANNER USECASE"
---

ADD A [LOGO]() HERE!

<!--
SPDX-FileCopyrightText: 2021 iteratec GmbH

SPDX-License-Identifier: Apache-2.0
-->
<!--
.: IMPORTANT! :.
--------------------------
This file is generated automatically with `helm-docs` based on the following template files:
- ./.helm-docs/templates.gotmpl (general template data for all charts)
- ./chart-folder/.helm-docs.gotmpl (chart specific template data)

Please be aware of that and apply your changes only within those template files instead of this file.
Otherwise your changes will be reverted/overwritten automatically due to the build process `./.github/workflows/helm-docs.yaml`
--------------------------
-->

<p align="center">
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="License Apache-2.0" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/></a>
<a href="https://github.com/secureCodeBox/secureCodeBox/releases/latest"><img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/secureCodeBox/secureCodeBox?sort=semver"/></a>
<a href="https://owasp.org/www-project-securecodebox/"><img alt="OWASP Incubator Project" src="https://img.shields.io/badge/OWASP-Incubator%20Project-365EAA"/></a>
<a href="https://artifacthub.io/packages/search?repo=securecodebox"><img alt="Artifact HUB" src="https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/securecodebox"/></a>
<a href="https://github.com/secureCodeBox/secureCodeBox/"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/secureCodeBox/secureCodeBox?logo=GitHub"/></a>
<a href="https://twitter.com/securecodebox"><img alt="Twitter Follower" src="https://img.shields.io/twitter/follow/securecodebox?style=flat&color=blue&logo=twitter"/></a>
</p>

## What is new-scanner?

Please write some information about the new scanner.

## Deployment
The new-scanner chart can be deployed via helm:

```bash
# Install HelmChart (use -n to configure another namespace)
helm upgrade --install new-scanner secureCodeBox/new-scanner
```

Empty file.
Empty file.
14 changes: 14 additions & 0 deletions .templates/new-scanner/examples/localhost/scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: "execution.securecodebox.io/v1"
kind: Scan
metadata:
name: "new-scanner-localhost"
spec:
scanType: "new-scanner"
parameters:
# Note: Localhost here isn't "your" localhost, but the scanner container.
# This container doesn't have any ports open...
- localhost
5 changes: 5 additions & 0 deletions .templates/new-scanner/parser/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

node_modules/
24 changes: 24 additions & 0 deletions .templates/new-scanner/parser/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

# No additional dependencies
ARG namespace
ARG baseImageTag
FROM ${namespace:-securecodebox}/parser-sdk-nodejs:${baseImageTag:-latest}
WORKDIR /home/app/parser-wrapper/parser/
COPY --chown=app:app ./parser.js ./parser.js

# Additional packages
# ARG namespace
# ARG baseImageTag
# FROM node:14-alpine as build
# RUN mkdir -p /home/app
# WORKDIR /home/app
# COPY package.json package-lock.json ./
# RUN npm ci --production
#
# FROM ${namespace:-securecodebox}/parser-sdk-nodejs:${baseImageTag:-latest}
# WORKDIR /home/app/parser-wrapper/parser/
# COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
# COPY --chown=app:app ./parser.js ./parser.js
2 changes: 2 additions & 0 deletions .templates/new-scanner/parser/__testFiles__/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
3 changes: 3 additions & 0 deletions .templates/new-scanner/parser/__testFiles__/example.com.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"target":"http://example.com"}
]
33 changes: 33 additions & 0 deletions .templates/new-scanner/parser/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-FileCopyrightText: 2021 iteratec GmbH
//
// SPDX-License-Identifier: Apache-2.0

async function parse(fileContent) {
const targets = parseResultFile(fileContent);
return transformToFindings(targets);
}

function transformToFindings(targets) {

const targetFindings = [];

// Code to transform the scanner results to scb findings

return [...targetFindings];
}

/**
* Parses a given new-scanner result file and extracts all targets
* @param {*} fileContent
*/
function parseResultFile(fileContent) {
let targetList = [];

for(const rawTarget of fileContent) {
// Code to transform raw target findings to usable js format
// If scanner is only able to output xml files, you have to transform them first (look at nmap parser for example)
}
return targetList;
}

module.exports.parse = parse;
39 changes: 39 additions & 0 deletions .templates/new-scanner/parser/parser.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2021 iteratec GmbH
//
// SPDX-License-Identifier: Apache-2.0

const fs = require("fs");
const util = require("util");

const {
validateParser,
} = require("@securecodebox/parser-sdk-nodejs/parser-utils");

// eslint-disable-next-line security/detect-non-literal-fs-filename
const readFile = util.promisify(fs.readFile);

const { parse } = require("./parser");

test("should properly parse new-scanner json file", async () => {
const fileContent = JSON.parse(
await readFile(__dirname + "/__testFiles__/example.com.json", {
encoding: "utf8",
})
);
const findings = await parse(fileContent);
// validate findings
await expect(validateParser(findings)).resolves.toBeUndefined();
expect(findings).toMatchInlineSnapshot();
});

test("should properly parse empty json file", async () => {
const fileContent = JSON.parse(
await readFile(__dirname + "/__testFiles__/empty.json", {
encoding: "utf8",
})
);
const findings = await parse(fileContent);
// validate findings
await expect(validateParser(findings)).resolves.toBeUndefined();
expect(findings).toMatchInlineSnapshot();
});
6 changes: 6 additions & 0 deletions .templates/new-scanner/scanner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

# Write your dockerfile for the scanner new-scanner here
# Alternatively, you can use an existing image from docker-hub
15 changes: 15 additions & 0 deletions .templates/new-scanner/templates/cascading-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

# We only want to import the default cascading rules if they are enabled
{{ if .Values.cascadingRules.enabled }}
# The CascadingRules are not directly in the /templates directory as their curly bracket syntax clashes with helms templates ... :(
# We import them as raw files to avoid these clashes as escaping them is even more messy
{{ range $path, $_ := .Files.Glob "cascading-rules/*" }}
# Include File
{{ $.Files.Get $path }}
# Separate multiple files
---
{{ end }}
{{ end }}
14 changes: 14 additions & 0 deletions .templates/new-scanner/templates/new-scanner-parse-definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: "execution.securecodebox.io/v1"
kind: ParseDefinition
metadata:
name: "new-scanner-json"
spec:
image: "{{ .Values.parser.image.repository }}:{{ .Values.parser.image.tag | default .Chart.Version }}"
imagePullPolicy: {{ .Values.parser.image.pullPolicy }}
ttlSecondsAfterFinished: {{ .Values.parser.ttlSecondsAfterFinished }}
env:
{{- toYaml .Values.parser.env | nindent 4 }}
44 changes: 44 additions & 0 deletions .templates/new-scanner/templates/new-scanner-scan-type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: "execution.securecodebox.io/v1"
kind: ScanType
metadata:
name: "new-scanner{{ .Values.scanner.nameAppend | default ""}}"
spec:
extractResults:
type: new-scanner-json
location: "/home/securecodebox/new-scanner-results.json"
jobTemplate:
spec:
{{- if .Values.scanner.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ .Values.scanner.ttlSecondsAfterFinished }}
{{- end }}
backoffLimit: {{ .Values.scanner.backoffLimit }}
{{- if .Values.scanner.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ .Values.scanner.activeDeadlineSeconds }}
{{- end }}
template:
spec:
restartPolicy: OnFailure
containers:
- name: new-scanner
image: "{{ .Values.scanner.image.repository }}:{{ .Values.scanner.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.scanner.image.pullPolicy }}
command:
- "new-scanner"
- "/home/securecodebox/new-scanner-results.json" # Replace output command
resources:
{{- toYaml .Values.scanner.resources | nindent 16 }}
securityContext:
{{- toYaml .Values.scanner.securityContext | nindent 16 }}
env:
{{- toYaml .Values.scanner.env | nindent 16 }}
volumeMounts:
{{- toYaml .Values.scanner.extraVolumeMounts | nindent 16 }}
{{- if .Values.scanner.extraContainers }}
{{- toYaml .Values.scanner.extraContainers | nindent 12 }}
{{- end }}
volumes:
{{- toYaml .Values.scanner.extraVolumes | nindent 12 }}
Loading