Skip to content

Add non-root container user validation - #699

Merged
stejskalleos merged 2 commits into
theforeman:masterfrom
archanaserver:container-user-validation
Jul 29, 2026
Merged

Add non-root container user validation#699
stejskalleos merged 2 commits into
theforeman:masterfrom
archanaserver:container-user-validation

Conversation

@archanaserver

@archanaserver archanaserver commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Why are you introducing these changes? (Problem description, related links)

The SAT-47250 identified container images configured to run as root, and foremanctl deploys images from multiple repositories, including images whose build pipelines are outside its control. So this adds deployment-level regression coverage to ensure that every running container is explicitly configured to use a non-root user.

What are the changes introduced in this pull request?

  • add a foremanctl test that discovers all running containers using podman ps
  • inspect each container’s image and configured user using podman inspect

How to test this pull request

steps to reproduce:

  • deploy a foremanctl test environment.
  • run the focused test: ./forge test --pytest-args="tests/container_user_test.py -vv"
  • verify that the test:
    • passes when all running containers have a non-root Config.User.
    • fails and reports the container name, image, and configured user when any running container uses root.

Checklist

  • Tests added/updated (if applicable)
  • Documentation updated (if applicable)

Comment thread tests/container_user_test.py Outdated
Comment thread tests/container_user_test.py
@evgeni

evgeni commented Jul 23, 2026

Copy link
Copy Markdown
Member

Tests are failing as expected, as pulp is running as root (well, unset in the definition, resulting in being root).

👍

Add a foremanctl test that discovers all running containers using
podman ps and validates their configured user with podman inspect.

Fail when Config.User is empty, root, or UID 0, and report all
non-compliant containers with their image details.
@archanaserver
archanaserver force-pushed the container-user-validation branch from 77ac553 to 2495547 Compare July 23, 2026 11:03
Comment thread tests/container_user_test.py Outdated
@stejskalleos stejskalleos self-assigned this Jul 27, 2026
@archanaserver
archanaserver force-pushed the container-user-validation branch from f798ee3 to dc61ae9 Compare July 28, 2026 07:04
@stejskalleos
stejskalleos merged commit e7f1574 into theforeman:master Jul 29, 2026
16 checks passed
@ekohl

ekohl commented Jul 31, 2026

Copy link
Copy Markdown
Member

In #716 I took a stab at simplifying the test.

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.

4 participants