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

Sonarcloud ghauri #5

Merged
merged 5 commits into from
Dec 8, 2024
Merged

Sonarcloud ghauri #5

merged 5 commits into from
Dec 8, 2024

Conversation

matusso
Copy link
Owner

@matusso matusso commented Dec 8, 2024

PR Type

enhancement, configuration changes


Description

  • Enhanced the Ghauri GitHub Actions workflow by adding a new job for SonarCloud scanning, which includes setting up Python and installing necessary dependencies.
  • Updated the Docker build process in the Ghauri workflow to use build context and dynamic release versioning.
  • Modified the Dockerfile for Ghauri to use a generic Python image and handle release versions dynamically.
  • Improved the kiterunner workflow by quoting build arguments in the Docker build command to ensure proper handling.
  • Cleaned up formatting in the metasploit-framework workflow by removing an unnecessary newline.

Changes walkthrough 📝

Relevant files
Enhancement
ghauri.yml
Enhance Ghauri workflow with SonarCloud integration and Docker build
updates

.github/workflows/ghauri.yml

  • Added new branch sonarcloud-ghauri for triggering workflows.
  • Introduced environment variables for Python and release versions.
  • Updated Docker build context and arguments.
  • Added a new job for SonarCloud scanning.
  • +63/-9   
    Dockerfile
    Update Ghauri Dockerfile for dynamic release version handling

    files/ghauri/Dockerfile

  • Changed base image to a generic Python image.
  • Added ARG and ENV for release version.
  • Updated git clone command to use dynamic release version.
  • +5/-3     
    Configuration changes
    kiterunner.yml
    Update Docker build command with quoted arguments               

    .github/workflows/kiterunner.yml

    • Added quotes around build arguments in Docker build command.
    +1/-1     
    Formatting
    metasploit-framework.yml
    Clean up environment variable section formatting                 

    .github/workflows/metasploit-framework.yml

    • Removed unnecessary newline in environment variable section.
    +0/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    Base Image Security Risk:
    Using a generic 'python' base image without version pinning in the Ghauri Dockerfile could potentially introduce security vulnerabilities. An attacker could exploit known vulnerabilities in older Python versions if the latest image happens to use an outdated version. Always specify exact version like 'python:3.13-alpine' for better security control.

    ⚡ Recommended focus areas for review

    Base Image Security
    Using generic 'python' base image instead of specific version. This could lead to unexpected behavior and security vulnerabilities. Should specify exact Python version.

    Missing Clean Up
    No cleanup of package manager cache after installation. Should add cleanup to reduce image size.

    Error Handling
    SonarCloud scan is set to continue-on-error which could hide critical issues. Consider failing the workflow on critical findings.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Use correct package manager commands matching the base image's Linux distribution

    The apk package installation is placed after the FROM statement but before the
    ARG/ENV declarations, which will fail since Alpine Linux commands are used with a
    non-Alpine base image.

    files/ghauri/Dockerfile [1-7]

     FROM python
     
     ARG RELEASE_VERSION="${RELEASE_VERSION}"
     
     ENV RELEASE_VERSION=${RELEASE_VERSION}
     # Install git
    -RUN apk update && apk add --no-cache git
    +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Critical fix for package installation - using Alpine's 'apk' commands with a Debian-based Python image would cause build failure. The suggestion correctly proposes using 'apt-get' instead.

    9
    Security
    Ensure security scans can fail the pipeline to maintain security standards

    The SonarCloud scan is configured to continue on error, which could allow security
    issues to go unnoticed. Remove 'continue-on-error: true' to ensure pipeline fails on
    security findings.

    .github/workflows/ghauri.yml [119-123]

     - name: SonarCloud Scan
       uses: sonarsource/sonarqube-scan-action@v4
    -  continue-on-error: true
       env:
         SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Important security improvement that ensures the pipeline fails when security issues are found, rather than silently continuing with potential vulnerabilities.

    8

    💡 Need additional feedback ? start a PR chat

    Copy link

    sonarqubecloud bot commented Dec 8, 2024

    Copy link

    sonarqubecloud bot commented Dec 8, 2024

    @matusso matusso merged commit 55954c1 into main Dec 8, 2024
    19 of 20 checks passed
    @matusso matusso deleted the sonarcloud-ghauri branch December 8, 2024 19:11
    Copy link

    sonarqubecloud bot commented Dec 8, 2024

    Quality Gate Failed Quality Gate failed for 'ghauri'

    Failed conditions
    19 Security Hotspots
    0.0% Coverage on New Code (required ≥ 80%)
    19.1% Duplication on New Code (required ≤ 3%)
    C Reliability Rating on New Code (required ≥ A)

    See analysis details on SonarQube Cloud

    Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

    Copy link

    sonarqubecloud bot commented Dec 8, 2024

    Copy link

    sonarqubecloud bot commented Dec 8, 2024

    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.

    1 participant