Skip to content

feat: add a check to detect Dockerfile insecure patterns #1116

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

achrafmag
Copy link
Contributor

Summary

Added a checker for insecure Dockerfile patterns.

Description of changes

Created security analyzer for Dockerfile following current available literature emphasizing:

  • Use of outdated or insecure base images (FROM)
  • Running containers as root (USER)
  • Copying sensitive files into the image (COPY, ADD)
  • Exposing insecure ports (EXPOSE)
  • Environment variable leaks (ENV)
  • Mounting unsafe host directories (VOLUME)
  • Use of potentially dangerous shell commands (RUN)

Related issues

Checklist

  • I have reviewed the contribution guide.
  • My PR title and commits follow the Conventional Commits convention.
  • My commits include the "Signed-off-by" line.
  • I have signed my commits following the instructions provided by GitHub. Note that we run GitHub's commit verification tool to check the commit signatures. A green verified label should appear next to all of your commits on GitHub.
  • [] I have updated the relevant documentation, if applicable.
  • I have tested my changes and verified they work as expected.

Changes:

-Function find_dockerfile_from_job: handles finding Dockerfile inside workflow in 2 cases of workflow jobs: -run and -uses.

-Simple DockerNode class, so far it stores mainly the dockerfile path retrieved from workflow

-Parsing Dockerfile using dockerfile-parse and RUN instruction commands using bashparser.py

-Parsing and storing build commands found in Dockerfiles

Signed-off-by: Achraf Maghous <[email protected]>
Changes:

-Created security analyzer for Dockerfile following current available literature emphasizing:

Use of outdated or insecure base images (FROM)

Running containers as root (USER)

Copying sensitive files into the image (COPY, ADD)

Exposing insecure ports (EXPOSE)

Environment variable leaks (ENV)

Mounting unsafe host directories (VOLUME)

Use of potentially dangerous shell commands (RUN)

Signed-off-by: Achraf Maghous <[email protected]>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 2, 2025
@tromai tromai changed the title Created a check for known Dockerfile insecure patterns feat: add a check to detect Dockerfile insecure patterns Jul 3, 2025
Changes: -Added unit tests handling different Docker
files

Signed-off-by: Achraf Maghous <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant