Skip to content

dev: hot reloading improvements celery/html/tpl#12714

Merged
Maffooch merged 3 commits into
DefectDojo:bugfixfrom
valentijnscholten:hot-reload-improvements
Jun 30, 2025
Merged

dev: hot reloading improvements celery/html/tpl#12714
Maffooch merged 3 commits into
DefectDojo:bugfixfrom
valentijnscholten:hot-reload-improvements

Conversation

@valentijnscholten

Copy link
Copy Markdown
Member

Improvements to hot-reloading/autoreload:

  • fix path to /app/dojo/settings/settings.py
  • also reload on .html and .tpl changes
  • enable autoreload on the celeryworker

For celery it could be done without watchmedo, but that would require installting pypi package celery[dev] which would end up also in production. I'm not sure of the impact of that, so I avoided it.

@dryrunsecurity

dryrunsecurity Bot commented Jun 28, 2025

Copy link
Copy Markdown

DryRun Security

This pull request contains minor security observations related to development dependencies, file permissions, and a development script in the production image, all of which are currently marked as non-blocking and pose minimal risk to the application's overall security posture.

Unnecessary Development Dependency in requirements.txt
Vulnerability Unnecessary Development Dependency
Description The watchdog package is added to requirements without clear separation between development and production dependencies. This could unnecessarily increase the application's dependency attack surface if deployed to production without careful filtering.

PyYAML==6.0.2
pyopenssl==25.1.0
parameterized==0.9.0
watchdog==6.0.0 # only needed for development, but would require some docker refactoring if we want to exclude it for production images

Overly Permissive File Permissions in docker/entrypoint-celery-worker-dev.sh
Vulnerability Overly Permissive File Permissions
Description The umask 0002 setting grants group write permissions to newly created files, which is less restrictive than typical production security practices. In a shared environment, this could allow unintended file modifications by group members.

#!/bin/bash
umask 0002
id
set -e # needed to handle "exit" correctly
. /secret-file-loader.sh
. /reach_database.sh
wait_for_database_to_be_reachable
echo
if [ "${DD_CELERY_WORKER_POOL_TYPE}" = "prefork" ]; then
EXTRA_PARAMS=("--autoscale=${DD_CELERY_WORKER_AUTOSCALE_MAX},${DD_CELERY_WORKER_AUTOSCALE_MIN}"
"--prefetch-multiplier=${DD_CELERY_WORKER_PREFETCH_MULTIPLIER}")
else
EXTRA_PARAMS=()
fi
# do the check with Django stack
python3 manage.py check
# hot reload using watmedo as we don't want to install celery[dev] and have that end up in our production images
watchmedo auto-restart --directory=./ --pattern="*.py;*.tpl" --recursive -- \
celery --app=dojo worker --loglevel="${DD_CELERY_LOG_LEVEL}" --pool="${DD_CELERY_WORKER_POOL_TYPE}" --concurrency="${DD_CELERY_WORKER_CONCURRENCY:-1}" "${EXTRA_PARAMS[@]}"

Development Script in Production Image in Dockerfile.django-alpine
Vulnerability Development Script in Production Image
Description The Dockerfile includes a development-specific entrypoint script that could expose unnecessary configuration details or debug features if used in a production environment. This increases the potential attack surface by including non-essential scripts with potentially less secure configurations.

COPY \
docker/entrypoint-celery-beat.sh \
docker/entrypoint-celery-worker.sh \
docker/entrypoint-celery-worker-dev.sh \
docker/entrypoint-initializer.sh \
docker/entrypoint-first-boot.sh \
docker/entrypoint-uwsgi.sh \


All finding details can be found in the DryRun Security Dashboard.

@mtesauro

Copy link
Copy Markdown
Contributor

For celery it could be done without watchmedo, but that would require installting pypi package celery[dev] which would end up also in production. I'm not sure of the impact of that, so I avoided it.

I agree with this ☝️ thinking

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved

@valentijnscholten valentijnscholten changed the title hot reloading improvements celery/html/tpl dev: hot reloading improvements celery/html/tpl Jun 30, 2025

@Maffooch Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is legit life changing

@Maffooch Maffooch merged commit 5c62799 into DefectDojo:bugfix Jun 30, 2025
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants