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

feat: Various codejail improvements for devstack usage #92

Merged
merged 3 commits into from
Jan 31, 2025

Conversation

timmc-edx
Copy link
Member

@timmc-edx timmc-edx commented Jan 30, 2025

A collection of improvements to enable the usual live-reloading workflow. Running as app meant we couldn't recompile files, modify the container environment, etc.

  • Run as root in dev target, for convenience and matching other images
  • Use gunicorn for both targets, since in devstack we can specify the CMD in the docker-compose file anyhow.
  • Install make, less, and some editors in the dev target
  • Set up virtualenv for dev environment

A collection of improvements to enable the usual live-reloading workflow.
Running as app meant we couldn't recompile files, modify the container
environment, etc.

- Run as root in dev target, for convenience and matching other images
- Fail RUN commands if there's an error
- Use gunicorn for both targets, since in devstack we can specify the CMD
  in the docker-compose file anyhow.
- Install make, less, and some editors in the dev target
- Set up virtualenv for dev environment
timmc-edx added a commit to edx/devstack that referenced this pull request Jan 30, 2025
This goes with edx/public-dockerfiles#92 which
switches the default CMD from runserver to gunicorn; we want to keep
runserver.
timmc-edx added a commit to edx/devstack that referenced this pull request Jan 30, 2025
This goes with edx/public-dockerfiles#92 which
switches the default CMD from runserver to gunicorn; we want to keep
runserver.
Copy link

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Food for thought, but no blockers (I think).

Comment on lines +102 to 103
# Drop to unprivileged user for running service
USER app
Copy link

Choose a reason for hiding this comment

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

I don't know enough about Docker. This will apply to the Docker's container's process, even though the command was moved from the end of the file? Just double-checking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, as far as I can tell from experimentation and the Dockerfile reference. I believe it even persists across layers (although that's not relevant here).



FROM app AS dev

# Developers will want some additional packages for interactive debugging.
Copy link

Choose a reason for hiding this comment

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

Since you are the security person, I imagine you have determined this is the right balance between security and usability? Just double-checking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding these packages shouldn't be a concern, as they're fairly standard and will only be applied to the dev target anyhow. In the prod target you generally want to limit the number of system packages because they can allow an attacker who has gained a foothold to solidify their persistence on the host and pivot to other hosts, but on dev, well... the developer already has full control.

The possibly more concerning thing is that the dev will be running as root (since I've removed USER app from the end of this target). The way people use Docker by default is already very dodgy, since it allows a trivial privilege escalation. More a problem on Linux than Mac. But we do this for all of our Dockerfiles, for a variety of reasons (volume mounting and user table mismatch, service restarts, package installation, etc.)

timmc-edx added a commit to edx/devstack that referenced this pull request Jan 31, 2025
This goes with edx/public-dockerfiles#92 which
switches the default CMD from runserver to gunicorn; we want to keep
runserver.
Apparently GoCD has an older or different version of `docker build` that
doesn't understand RUN heredoc.
@timmc-edx timmc-edx merged commit ab6202c into main Jan 31, 2025
@timmc-edx timmc-edx deleted the timmc/cj-root branch January 31, 2025 17:09
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