Skip to content

Add a new AutoDiscovery Operator for automated Scans in Kubernetes Clusters#461

Merged
J12934 merged 48 commits intomainfrom
auto-discovery
Jul 12, 2021
Merged

Add a new AutoDiscovery Operator for automated Scans in Kubernetes Clusters#461
J12934 merged 48 commits intomainfrom
auto-discovery

Conversation

@J12934
Copy link
Member

@J12934 J12934 commented May 31, 2021

Description

This PR adds a "AutoDiscovery" feature for workloads running inside kubernetes.
Currently only supports http / https types of workloads by "auto-discovering" kubernetes services and starting scans against them.

For more info check out the readme of the AutoDiscovery subfolder: https://github.com/secureCodeBox/secureCodeBox/tree/auto-discovery/auto-discovery/kubernetes

Todos

  • License headers
  • Resources limits configuration via helm chart

@J12934 J12934 added enhancement New feature or request auto-discovery labels May 31, 2021
@J12934 J12934 self-assigned this May 31, 2021
Copy link
Member

@nigthknight nigthknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Work!
I just have some questions and minor issues.

  1. Why do we need a kubernetes directory?
  2. I think it would be best to include the short SPDX Header instead of the Apache Header
  3. Trying to run the tests locally with make test fails with
•STEP: tearing down the test environment

------------------------------
Failure [20.014 seconds]
[AfterSuite] AfterSuite
/home/yfuhrmeister/Projects/scb/secureCodeBox/auto-discovery/kubernetes/controllers/suite_test.go:119

  Unexpected error:
      <errors.aggregate | len:1, cap:1>: [
          {
              s: "timeout waiting for process kube-apiserver to stop",
          },
      ]
      timeout waiting for process kube-apiserver to stop
  occurred

  /home/yfuhrmeister/Projects/scb/secureCodeBox/auto-discovery/kubernetes/controllers/suite_test.go:122

COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to use the Makefile at this point as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is directly taken from the defaukt kubebuilder starting point, so not sure what the exact reasoning here is to doing it like this, I'd guess that this gives them more controll over the flags used for the go build but I'm not sure.

Co-authored-by: Yannik Fuhrmeister <12710254+fuhrmeistery@users.noreply.github.com>
@J12934
Copy link
Member Author

J12934 commented Jun 1, 2021

Great Work!
I just have some questions and minor issues.

1. Why do we need a `kubernetes` directory?

2. I think it would be best to include the short SPDX Header instead of the Apache Header

3. Trying to run the tests locally with `make test` fails with
•STEP: tearing down the test environment

------------------------------
Failure [20.014 seconds]
[AfterSuite] AfterSuite
/home/yfuhrmeister/Projects/scb/secureCodeBox/auto-discovery/kubernetes/controllers/suite_test.go:119

  Unexpected error:
      <errors.aggregate | len:1, cap:1>: [
          {
              s: "timeout waiting for process kube-apiserver to stop",
          },
      ]
      timeout waiting for process kube-apiserver to stop
  occurred

  /home/yfuhrmeister/Projects/scb/secureCodeBox/auto-discovery/kubernetes/controllers/suite_test.go:122

@fuhrmeistery

  1. The kubernetes directory is so that we can add additional "auto-discoveries" for different cloud / runtime environments in the future, not just kubernetes. This is mentioned in the readme in the auto-discovery dir.
  2. Yup, good point the existing headers are automatically setup by kubebuilder didn't setup the spdx header up yet...
  3. Not sure whats going on there, seems to work okay for my machine and the CI, looks like this is only failing to tear down the api server, is your linux distro configured in a unusual way which might interfer with that?

@nigthknight
Copy link
Member

@fuhrmeistery

1. The kubernetes directory is so that we can add additional "auto-discoveries" for different cloud / runtime environments in the future, not just kubernetes. This is mentioned in the readme in the `auto-discovery` dir.

2. Yup, good point the existing headers are automatically setup by kubebuilder didn't setup the spdx header up yet...

3. Not sure whats going on there, seems to work okay for my machine and the CI, looks like this is only failing to tear down the api server, is your linux distro configured in a unusual way which might interfer with that?
  1. Yes, I think you are right. Tested on another machine and everything was fine o.O

@J12934
Copy link
Member Author

J12934 commented Jun 1, 2021

Mh interesting, hopefully that's actually related to your system and not that the test suite is flaky 😅

@rfelber rfelber added this to the v2.8.0 milestone Jun 3, 2021
@rfelber rfelber linked an issue Jun 3, 2021 that may be closed by this pull request
@rfelber rfelber removed this from the v2.8.0 milestone Jun 4, 2021
@J12934 J12934 marked this pull request as ready for review July 9, 2021 12:58
@J12934 J12934 requested a review from nigthknight July 9, 2021 12:58
@J12934
Copy link
Member Author

J12934 commented Jul 9, 2021

  • I fixed some typos in the helm-docs templates this has exploded as this has changed the doc files in every component. PR should still be reviewable by just checking the changes auto-discovery/ and .helm-docs/ folder.
  • I changed the helm-docs action to check the checksum of the downloaded binary and mv'ed it to the /usr/local/bin so that we don't have to juggle with the correct relative path every time

This should make the PR look a bit more green :)

Signed-off-by: Jannik Hollenbach <jannik.hollenbach@iteratec.com>
Copy link
Member

@nigthknight nigthknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me 👍

@J12934 J12934 merged commit 92bae12 into main Jul 12, 2021
@J12934 J12934 deleted the auto-discovery branch July 12, 2021 08:59
@rfelber rfelber changed the title Add AutoDiscovery for Kubernetes Add a new AutoDiscovery Operator for automated Scans in Kubernetes Clusters Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-discovery enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a Scan Autodiscovery for K8S Services

3 participants