Skip to content

Add Docker support + Docker secrets with fallback (fixes #92)#98

Merged
RicYaben merged 3 commits intohoneynet:v3.0-devfrom
R1sh0bh-1:feature/docker-secrets-issue92
Mar 2, 2026
Merged

Add Docker support + Docker secrets with fallback (fixes #92)#98
RicYaben merged 3 commits intohoneynet:v3.0-devfrom
R1sh0bh-1:feature/docker-secrets-issue92

Conversation

@R1sh0bh-1
Copy link
Copy Markdown

Hey @RicYaben,

As we discussed in #92, I’ve implemented Docker file-based secrets on the v3.0-dev branch (thank you again for telling me to work on top of it!).

v3.0-dev didn't have any Docker support yet (no Dockerfile, no compose file), so I first created a clean, minimal setup by taking reference from the older branches (mainly v3.0) and adapting everything to the new refactored structure (src/, dicomhawk CLI, etc.).

Then I implemented the Docker secrets feature exactly as per our conversation.

What was done

  • Created Dockerfile and docker-compose.yml so the project can run in containers
  • Implemented file-based Docker secrets
  • Made the secrets path configurable via SECRETS_BASE_PATH env var (defaults to /run/secrets)
  • Added get_secret() + secret_or_env() helpers in src/dicomhawk/config.py
  • Added readSecret() helper in API/threatIntelligence.js
  • Secrets are plain files at project root (git-ignored, no special folder)
  • Full fallback to environment variables when no secret files exist so local dev still works easily
  • Removed plain env vars for these secrets from compose to make it secure
  • Fixed several pre existing bugs that were breaking the branch (NameError in server.py, missing imports, CLI naming conflict, binding issues, etc.) these were needed to actually test and use the secrets feature

Everything has been tested:

  • Secrets mount correctly at /run/secrets/ and are readable inside containers
  • Code reads from secret files first, falls back to environment variables if files are missing
  • No sensitive values leak in docker inspect
  • All containers stay Up, ports are accessible, basic DICOM connection + logs + API work

Please take a look whenever you have time and let me know your thoughts if anything should be changed, scoped differently, or improved, I'm more than happy to work on it.
Thanks again for the direction really appreciate it!

@R1sh0bh-1
Copy link
Copy Markdown
Author

I was also thinking of adding a section to the README.md explaining how to properly set up the secret files. What do you think about that?

@R1sh0bh-1
Copy link
Copy Markdown
Author

@RicYaben I removed the artifacts referencing redis and stuff like that as discussed, please have a look when you get time and let met know if any other changes are required

Copy link
Copy Markdown
Collaborator

@RicYaben RicYaben left a comment

Choose a reason for hiding this comment

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

I cannot merge this PR. As it is right now, it mixes concepts from the previous versions into the new one. The goal was to get rid of unnecessary things, not to add them again. On top of that, this PR touches other files unrelated to attempting to read secrets from a secure location instead of having them just lying around. On that note, it still loads the API secrets into the app at runtime, so there is no much of a difference anyway.

I recommend going back to the drawing board to do just what is needed, no other files touched.

Comment thread src/commands/main.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This file should not be touched by your PR, stick to the docker support

Comment thread src/commands/serve.py Outdated
Comment on lines +38 to +47
block_scanners: Optional[bool] = typer.Option(
None,
"--block-scanners/--no-block-scanners",
help="Block known scanner IPs. Defaults to BLOCK_SCANNERS env var.",
),
integrity_check: Optional[bool] = typer.Option(
None,
"--integrity-check/--no-integrity-check",
help="Enable DICOM file integrity checks. Defaults to INTEGRITY_CHECK env var.",
),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is this? why is this here?

Comment thread src/commands/serve.py Outdated
hp = new_dicomhawk(config)
hp.run() No newline at end of file
hp = new_dicomhawk(logger, [], config)
hp.start() No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why did you change it from run to start?

Comment thread src/dicomhawk/config.py Outdated
EXCEPTIONS_LOG_DIR: str

# TODO: we shouldn't store api keys. This can be loaded from secrets
ABUSE_IP_API_KEY: str
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The TODO refers to not load API credentials in memory. Values can be read when needed (just-in-time)

Comment thread src/dicomhawk/config.py Outdated
try:
with open(f"{base}/{name}") as f:
return f.read().strip()
except (FileNotFoundError, PermissionError):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

silent exception? why is this not handled? if there are no permissions to read, why would we want to continue executing? exit, log the error

Comment thread docker-compose.yml Outdated
Comment on lines +70 to +71
networks:
- main_network
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is there any other network?

Comment thread docker-compose.yml Outdated
Comment on lines +116 to +121
abuse_ip_key:
file: ./abuse_ip_key
ip_quality_score_key:
file: ./ip_quality_score_key
virus_total_key:
file: ./virus_total_key
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove

Comment thread docker-compose.yml Outdated
Comment on lines +125 to +126
tcia_data:
tcia_stagger:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is this?

Comment thread docker-compose.yml Outdated
Comment on lines +129 to +131
networks:
main_network:
driver: bridge No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the default network is already a bridge

Comment thread Dockerfile
@@ -0,0 +1,30 @@
FROM python:3.12-slim

WORKDIR /app
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

?

@R1sh0bh-1
Copy link
Copy Markdown
Author

Hi @RicYaben, apologies for going out of scope earlier. I’ve now kept the changes minimal and focused only on the essentials: this update adds a Dockerfile, a minimal docker-compose configuration with the three secrets (tcia_username, tcia_password, and honey_url) mounted, and two small helper functions in config.py to read from those secret files with an environment variable fallback for local development. No other changes were made. Please let me know if anything needs adjustment.

@R1sh0bh-1 R1sh0bh-1 requested a review from RicYaben March 2, 2026 10:17
@RicYaben RicYaben merged commit 769444d into honeynet:v3.0-dev Mar 2, 2026
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.

2 participants