-
Notifications
You must be signed in to change notification settings - Fork 179
Add Makefile For Finding Post Processing Hook #558
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9367283
Add Makefile For Findings Post Processing
nigthknight dde1bad
Move Integration Tests
nigthknight c7f610b
Remove hook dir and .tar files from helm context
nigthknight e6c01d9
Add Finding Post Processing To CI
nigthknight f501fbe
Remove Finding Post Processing From Old Matrix
nigthknight 6bedc73
Add Correct Prefix For Hook Images
nigthknight 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
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 |
|---|---|---|
|
|
@@ -33,4 +33,5 @@ config/* | |
| Dockerfile | ||
| .dockerignore | ||
| docs/ | ||
|
|
||
| *.tar | ||
| hook/* | ||
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,112 @@ | ||
| #!/usr/bin/make -f | ||
| # | ||
| # SPDX-FileCopyrightText: 2021 iteratec GmbH | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # | ||
| # This Makefile is intended to be used for developement and testing only. | ||
| # For using this hook/hook in production please use the helm chart. | ||
| # See: <https://docs.securecodebox.io/docs/getting-started/installation> | ||
| # | ||
| # This Makefile expects some additional software to be installed: | ||
| # - git | ||
| # - node + npm | ||
| # - docker | ||
| # - kind | ||
| # - kubectl | ||
| # - helm | ||
|
|
||
| # Thx to https://stackoverflow.com/questions/5618615/check-if-a-program-exists-from-a-makefile | ||
| EXECUTABLES = make docker kind git node npm npx kubectl helm | ||
| K := $(foreach exec,$(EXECUTABLES),\ | ||
| $(if $(shell which $(exec)),some string,$(error "ERROR: The prerequisites are not met to execute this makefile! No '$(exec)' found in your PATH"))) | ||
|
|
||
|
|
||
| # Variables you might want to override: | ||
| # | ||
| # IMG_NS: Defines the namespace under which the images are build. | ||
| # For `securecodebox/hook-nmap` `securecodebox` is the namespace | ||
| # Defaults to `securecodebox` | ||
| # | ||
| # BASE_IMG_TAG: Defines the tag of the base image used to build this hook/hook | ||
| # | ||
| # IMG_TAG: Tag used to tag the newly created image. Defaults to the shortend commit hash | ||
| # prefixed with `sha-` e.g. `sha-ef8de4b7` | ||
| # | ||
| # JEST_VERSION Defines the jest version used for executing the tests. Defaults to latest | ||
| # | ||
| # Examples: | ||
| # make all IMG_TAG=main | ||
| # make deploy IMG_TAG=$(git rev-parse --short HEAD) | ||
| # make integration-tests | ||
| # | ||
|
|
||
| SHELL = /bin/sh | ||
|
|
||
| IMG_NS ?= securecodebox | ||
| GIT_TAG ?= $$(git rev-parse --short HEAD) | ||
| BASE_IMG_TAG ?= latest | ||
| IMG_TAG ?= "sha-$(GIT_TAG)" | ||
| JEST_VERSION ?= latest | ||
|
|
||
| hook = finding-post-processing | ||
| hook-prefix = hook- | ||
|
|
||
|
|
||
| build: | install-deps docker-build | ||
|
|
||
| test: | unit-tests docker-export kind-import deploy-prerequisites deploy deploy-test-deps integration-tests | ||
|
|
||
| all: | clean install-deps unit-tests docker-build docker-export kind-import deploy-prerequisites deploy deploy-test-deps integration-tests | ||
|
|
||
| .PHONY: unit-tests install-deps docker-build docker-export kind-import deploy-prerequisites deploy deploy-test-deps integration-tests all build test | ||
|
|
||
| unit-tests: | ||
| @echo ".: 🧪 Starting unit-tests for hook '$(hook)' with 'jest@$(JEST_VERSION)'." | ||
| cd hook && npx --yes --package jest@$(JEST_VERSION) jest --ci --colors --coverage . | ||
|
|
||
| install-deps: | ||
| @echo ".: ⚙️ Installing all hook specific dependencies." | ||
| cd hook && npm ci | ||
|
|
||
| docker-build: | ||
| @echo ".: ⚙️ Build With BASE_IMG_TAG: '$(BASE_IMG_TAG)'." | ||
| docker build --build-arg=baseImageTag=$(BASE_IMG_TAG) --build-arg=namespace=$(IMG_NS) -t $(IMG_NS)/$(hook-prefix)$(hook):$(IMG_TAG) -f ./hook/Dockerfile ./hook | ||
|
|
||
| docker-export: | ||
| @echo ".: ⚙️ Saving new docker image archive to '$(hook-prefix)$(hook).tar'." | ||
| docker save $(IMG_NS)/$(hook-prefix)$(hook):$(IMG_TAG) -o $(hook-prefix)$(hook).tar | ||
|
|
||
| kind-import: | ||
| @echo ".: 💾 Importing the image archive '$(hook-prefix)$(hook).tar' to local kind cluster." | ||
| kind load image-archive ./$(hook-prefix)$(hook).tar | ||
|
|
||
| deploy: | ||
| @echo ".: 💾 Deploying '$(hook)' hook HelmChart with the docker tag '$(IMG_TAG)' into kind namespace 'integration-tests'." | ||
| helm -n integration-tests upgrade --install $(hook) ./ --wait \ | ||
| --values ./integration-tests/__testFiles__/values.yaml \ | ||
| --set="hook.image.repository=docker.io/$(IMG_NS)/$(hook-prefix)$(hook)" \ | ||
| --set="hook.image.tag=$(IMG_TAG)" | ||
|
|
||
| deploy-test-deps: | ||
| @echo ".: 💾 Deploying test dependency HelmChart with the docker tag '$(BASE_IMG_TAG)' into kind namespace 'integration-tests'." | ||
| helm -n integration-tests upgrade --install test-scan ../../scanners/test-scan/ --wait \ | ||
| --set="scanner.image.tag=$(BASE_IMG_TAG)" \ | ||
| --set="parser.image.tag=$(BASE_IMG_TAG)" | ||
|
|
||
| install-integration-test-deps: | ||
|
|
||
| integration-tests: | ||
| @echo ".: 🩺 Starting integration test in kind namespace 'integration-tests'." | ||
| kubectl -n integration-tests delete scans --all | ||
| cd ../../tests/integration && npm ci | ||
| npx jest --ci --config=./integration-tests/jest.config.json --colors --coverage ./integration-tests | ||
|
|
||
| clean: | ||
| @echo ".: 🧹 Cleaning up all generated files." | ||
| rm -f ./$(hook-prefix)$(hook).tar | ||
| rm -rf ./hook/node_modules | ||
| rm -rf ./hook/coverage | ||
| rm -rf ./integration-tests/node_modules | ||
| rm -rf ./integration-tests/coverage |
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 @@ | ||
| {} |
23 changes: 23 additions & 0 deletions
23
hooks/finding-post-processing/integration-tests/__testFiles__/values.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,23 @@ | ||
| # SPDX-FileCopyrightText: 2020 iteratec GmbH | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Default values for dispatcher. | ||
| # This is a YAML-formatted file. | ||
| # Declare variables to be passed into your templates. | ||
|
|
||
| image: | ||
| # image.tag - defaults to the charts version | ||
| # image.repository -- Hook image repository | ||
| repository: docker.io/securecodebox/finding-post-processing | ||
| # parserImage.tag -- Parser image tag | ||
| # @default -- defaults to the charts version | ||
| tag: null | ||
|
|
||
| rules: | ||
| - matches: | ||
| anyOf: | ||
| - category: "Open Port" | ||
| override: | ||
| severity: "high" | ||
| category: "SomeNewCategory" | ||
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
1 change: 1 addition & 0 deletions
1
hooks/finding-post-processing/integration-tests/jest.config.json
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 @@ | ||
| {} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.