Skip to content

container scans#51

Open
Ngwerume wants to merge 3 commits into
mainfrom
container-scan
Open

container scans#51
Ngwerume wants to merge 3 commits into
mainfrom
container-scan

Conversation

@Ngwerume
Copy link
Copy Markdown
Contributor

No description provided.

@codacy-staging
Copy link
Copy Markdown

codacy-staging Bot commented Apr 22, 2026

Up to standards ✅

🟢 Issues 1 high

Results:
1 new issue

Category Results
Security 1 high

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements container security scanning but contains multiple high-severity issues that prevent a successful and secure deployment. The implementation is currently broken due to a variable interpolation bug in the shell script and a dependency conflict in the Dockerfile (Numpy 1.26.4 requires Python 3.9+).

Furthermore, the Docker image is insecure by default, running as root and failing to update a vulnerable lxml dependency. There is also a configuration mismatch between the provided documentation and the GitHub Actions workflow concerning the expected secret names, which will likely cause setup failures for users.

About this PR

  • Inconsistent secret naming: The implementation (workflow/scripts) uses 'CODACY_API_TOKEN', while the documentation refers to 'CODACY_CLI_TOKEN'. This should be standardized to 'CODACY_API_TOKEN' across all files.
  • The PR description is empty and no Jira ticket is linked. Providing context is essential for verifying requirements and ensuring the scanning setup aligns with project goals.

Test suggestions

  • Docker image builds successfully using the provided Dockerfile
  • .codacy-cli.sh correctly downloads and executes the Codacy CLI binary
  • test-container-scan-local.sh successfully triggers a local scan with and without an API token
  • GitHub Action workflow correctly initializes the CLI and uploads the SBOM
  • Verify Docker container runs as a non-root user
  • Verify that all dependencies in requirements.txt are installed during the build
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Docker image builds successfully using the provided Dockerfile
2. .codacy-cli.sh correctly downloads and executes the Codacy CLI binary
3. test-container-scan-local.sh successfully triggers a local scan with and without an API token
4. GitHub Action workflow correctly initializes the CLI and uploads the SBOM
5. Verify Docker container runs as a non-root user
6. Verify that all dependencies in requirements.txt are installed during the build

🗒️ Improve review quality by adding custom instructions

Comment thread requirements.txt
@@ -13,7 +13,7 @@ idna==3.2
kiwisolver==1.3.2
lxml==4.7.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Update lxml to version 6.1.0 to address CVE-2026-41066.

This might be a simple fix:

Suggested change
lxml==4.7.1
lxml==6.1.0

Comment thread Dockerfile

COPY main.py .

CMD ["python", "main.py"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Running as 'root' is a security hazard. Specify a non-root USER in the Dockerfile to limit privileges.

This might be a simple fix:

Suggested change
CMD ["python", "main.py"]
RUN useradd --create-home appuser
USER appuser
CMD ["python", "main.py"]

Comment thread Dockerfile

WORKDIR /app

COPY main.py .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Dependencies from requirements.txt are not being installed. Add the necessary COPY and RUN pip install commands to build a functional image.

Suggested change
COPY main.py .
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY main.py .

Comment thread Dockerfile
@@ -0,0 +1,7 @@
FROM python:3.8
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Numpy 1.26.4 requires Python 3.9 or higher. Update the base image to python:3.9 to ensure compatibility with the specified dependencies.

Suggested change
FROM python:3.8
FROM python:3.9

Comment thread .codacy-cli.sh
remote_file="codacy-cli-v2_${version}_${suffix}_${arch}.tar.gz"
url="https://github.com/codacy/codacy-cli-v2/releases/download/${version}/${remote_file}"

download "$url" "$bin_folder"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

The variable version is missing the $ prefix for interpolation, which will cause the download to fail.

Suggested change
download "$url" "$bin_folder"
url="https:[REDACTED:HIGH_ENTROPY]${version}/${remote_file}"

Comment thread .codacy-cli.sh
if [ "$#" -eq 1 ] && [ "$1" = "download" ]; then
echo "Codacy cli v2 download succeeded"
else
eval "$run_command $*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Avoid using eval for command execution to prevent shell injection vulnerabilities. Execute the binary directly while passing all arguments safely using "$@".

Suggested change
eval "$run_command $*"
"$run_command" "$@"

Comment on lines +40 to +41
-o codacy-acme \
-r engine-helper
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ LOW RISK

Suggestion: Hardcoded organization ('codacy-acme') and repository ('engine-helper'). Consider using GitHub Actions context variables like '${{ github.repository_owner }}' and '${{ github.event.repository.name }}' for better portability.

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.

1 participant