-
Notifications
You must be signed in to change notification settings - Fork 179
🚧 [Consistency] Create New Scanner makefile command #706
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
08f4781
Adding template folder for new scanner files
SebieF 856d56f
Adding create-new-scanner command to Makefile
SebieF c60ce4f
Updating Helm Docs
SebieF 6f874f0
Adding quotes to Chart.yaml template
SebieF b6c290b
Merge remote-tracking branch 'origin/consistency/new-scanner-makefile…
SebieF 2e4a5e9
Making new-scanner-scan-type.yaml consistent with existing scan type …
SebieF 9fba067
Merge branch 'main' into consistency/new-scanner-makefile
SebieF 0768283
Make template files consistent with current used files
SebieF a1a39e6
Replacing old name nmap with generic name
SebieF e1a1968
Removing autogenerated files
SebieF 1fd5877
Removing optional file that is not always used
SebieF 8819b39
Fixing typo
SebieF adba333
Updating Helm Docs
SebieF 0738cfa
Merge branch 'main' into consistency/new-scanner-makefile
SebieF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [ | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [ | ||
| {"target":"http://example.com"} | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
14
.templates/new-scanner/templates/new-scanner-parse-definition.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
44
.templates/new-scanner/templates/new-scanner-scan-type.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.