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

Feature/boefjes to oci images #2709

Merged
merged 13 commits into from
Mar 29, 2024
Merged

Feature/boefjes to oci images #2709

merged 13 commits into from
Mar 29, 2024

Conversation

Donnype
Copy link
Contributor

@Donnype Donnype commented Mar 22, 2024

Changes

This adds Docker (OCI) image builder setups for both python-native boefjes and boefjes that were using docker containers already. As an example for this first version, only dns-records and dns-sec were changed.

To get it working for the dnssec image, I had to change the boefje_meta argument to be a dict since else we'd be adding pydantic there and a job_models file. This can be a point of discussion.

I also added a step in the make build that we run during installations. We now also do make -C boefjes images that builds the two images. There the target also provides examples of how to manually run the docker build commands with the right arguments and tags.

One issue here is that some alpine images only have python 3.5 available which messes a bit with some of the APIs in the standard lib. Hence the ignoring the dnssec main.py for pre-commit. We'll try to migrate to new python3.11-slim images where possible. In this case, it was possible.

I used boefje.Dockerfile per the Dockerfile naming convention and the fact that potentially normalizer Dockerfiles could perhaps also live in the same directory with the name normalizer.Dockerfile for instance.

Follow up: do we still care about the group and user ids? We do not pass them anyways currently and the main reason for implementing them was specific requirements for the apps themselves, if I recall correctly. No, removed.

Issue link

Closes #2443

Demo & QA notes

This feature should not change the current flow or setup, but please verify that both the dns-records and dns-sec boefje work properly on a clean install (i.e. after make kat or make reset, which should build the images). Perhaps a rough notion of the new performance would also be nice as the risk here is that the new setup will induce significant overhead to smaller boefjes.


Code Checklist

  • All the commits in this PR are properly PGP-signed and verified.
  • This PR only contains functionality relevant to the issue; tickets have been created for newly discovered issues.
  • I have written unit tests for the changes or fixes I made.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have performed a self-review of my code and refactored it to the best of my abilities.

Communication

  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have made corresponding changes to the documentation, if necessary.
  • I have included comments in the code to elaborate on what is not self-evident from the code itself, including references to issues and discussions online, or implicit behavior of an interface.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@Donnype Donnype requested a review from a team as a code owner March 22, 2024 16:56
boefjes/Makefile Show resolved Hide resolved
boefjes/boefjes/docker_boefjes_runner.py Show resolved Hide resolved
boefjes/boefjes/docker_boefjes_runner.py Outdated Show resolved Hide resolved
boefjes/boefjes/plugins/kat_dnssec/boefje.Dockerfile Outdated Show resolved Hide resolved
boefjes/boefjes/plugins/kat_dns/main.py Outdated Show resolved Hide resolved
boefjes/images/base.Dockerfile Show resolved Hide resolved
boefjes/images/boefje_entrypoint.sh Outdated Show resolved Hide resolved
Use the `nonroot` user in the boefje images.
Explanation for setting the DOCKER_DEFAULT_PLATFORM in the boefje Makefile
Donnype added 3 commits March 26, 2024 17:35
Handle the boefje api requests in Python as well, using httpx
Use the docker_adapter as entrypoint, making the entrypoint redundant.
Handle the boefje api requests in Python as well, using httpx
Use the docker_adapter as entrypoint, making the entrypoint redundant
@Donnype Donnype requested a review from dekkers March 26, 2024 17:55
@stephanie0x00
Copy link
Contributor

Checklist for QA:

  • I have checked out this branch, and successfully ran a fresh make reset.
  • I confirmed that there are no unintended functional regressions in this branch:
    • I have managed to pass the onboarding flow
    • Objects and Findings are created properly
    • Tasks are created and completed properly
  • I confirmed that the PR's advertised feature or hotfix works as intended.

What works:

DNSSec boefje works and appear no error messages in the logs. After Review is done it can be moved to Ready to merge.

I followed the following approach while timing: I let the DNSrecords and DNSzone boefjes run and finish, then enable the dnssec boefje and start the stopwatch. Data is against mispo.es with L1 and timed until the KAT-NO-DNSSEC Finding Type is completed under the Normalizer tab:

  • Current main it takes the times below to finish. It takes about ~30s for the first dnssec task to show up.

    • 1st time:- ~40 seconds
    • 2nd time: ~23 seconds
    • 3rd time: ~45 seconds
    • 4th time: ~47 seconds
  • This branch to run. It takes about ~40seconds for the first dnssec related task to show up in the list:

    • 1st time: 1m15seconds
    • 2nd time: ~40 seconds
    • 3rd time: ~55 seconds
    • 4th time: 1m05s.

What doesn't work:

n/a

Bug or feature?:

n/a

domain = input_["name"]

client = docker.from_env()

# check for string pollution in domain. This check will fail if anything other characters than a-zA-Z0-9_.- are
# present in the hostname
if not re.search(r"^[\w.]+[\w\-.]+$", domain.lower()):
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we checked punicode domainname compatibility here?

@underdarknl underdarknl merged commit 33ef390 into main Mar 29, 2024
10 checks passed
@underdarknl underdarknl deleted the feature/boefjes-to-oci-images branch March 29, 2024 10:57
jpbruinsslot added a commit that referenced this pull request Apr 4, 2024
* main: (51 commits)
  Fix static files for container images/Debian packages when DEBUG is on (#2742)
  OOI selection at Aggregate report does not remember changed selection (#2619)
  fix schema errors on empty / missing schemas (#2744)
  Updated `phonenumbers` and `django-phonenumber-field` (#2757)
  Remove octopoes coverage workflow (#2755)
  Bump actions/configure-pages from 4 to 5 (#2745)
  Add xtdb-cli tool to Octopoes (#2733)
  Dont report vulnerabilities without version info of the software for snyk (#2730)
  Feature/boefjes to oci images (#2709)
  Query non-reference fields and subclass-specific fields through path queries (#2662)
  Fix in System Specific (#2732)
  Plugins overview in appendix not showing any plugins (#2694)
  Feat stepper design v2 (#2704)
  Undo project-directory in Rocky (#2734)
  Remove Docker Compose: "version" (#2718)
  Upgrade `pre-commit` hooks (#2729)
  Fix #1739 (#2705)
  Improve generate report (#2633)
  Fix critical vulnerability counter (#2712)
  Fix pdf alignment (#2674)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build CI/CD for building versioned boefje image containers
4 participants