Skip to content

tracked file movement on git - #21

Merged
lvarin merged 1 commit into
devfrom
helm_modifications_2
Jan 13, 2025
Merged

lvarin merged 1 commit into
devfrom
helm_modifications_2

Conversation

@lvarin

@lvarin lvarin commented Jan 13, 2025 •

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage
  • I have added docstrings following the Python style guidelines of this project to all new modules, classes, methods and functions are documented with docstrings following; I have updated any previously existing docstrings, if applicable
  • I have updated any sections of the app's documentation that are affected by the proposed changes, if applicable

Summary by Sourcery

Update Docker build process to use a non-root user and improve security by storing secrets as environment variables.

Build:

  • Updated the Dockerfile to create a dedicated "pubgrade" user and group with appropriate permissions. Switched to this non-root user for running the application inside the container.
  • Secrets are now loaded from environment variables instead of being hardcoded in the config file.

CI:

  • Updated the CI workflow to use a new image tag and removed the hardcoded secrets from the config file.

Deployment:

  • Updated the Helm chart to version 1 and moved it to a new directory called "helm".

@sourcery-ai

sourcery-ai Bot commented Jan 13, 2025 •

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This pull request implements tracking of file movements in Git and updates the deployment process. It also introduces several security improvements by removing hardcoded secrets and using environment variables instead. Additionally, it updates the Dockerfile to improve security and maintainability, and modifies the configuration files to reflect these changes.

Sequence diagram for the updated image signing process

sequenceDiagram
    participant A as API
    participant GH as GitHub Actions
    participant R as Registry
    participant S as Signer

    A->>A: Load environment variables
    A->>GH: Trigger signing workflow
    Note over A,GH: Uses GH_ACCESS_TOKEN from env
    GH->>R: Pull image
    Note over GH,R: Uses INTERMEDIATE_REGISTRY_TOKEN
    GH->>S: Sign image
    Note over GH,S: Uses COSIGN_PRIVATE_KEY and COSIGN_PASSWORD
    S->>R: Push signed image
Loading

Class diagram showing configuration structure changes

classDiagram
    class Config {
        +db: Object
        +api: Object
        +endpoints: Object
    }

    class Endpoints {
        +admin_users: Array
        +builds: Object
    }

    class Builds {
        +gh_action_path: String
        +intermediate_registery_format: String
        -intermediate_registry_token: String
    }

    Config --> Endpoints
    Endpoints --> Builds

    note for Builds "Removed hardcoded token,
now using env variable"
Loading

File-Level Changes

Change Details Files
Tracked file movement on Git.
  • Added a group and user 'pubgrade' with UID and GID 1000.
  • Set the working directory to /app.
  • Copied source code to /app and changed ownership to pubgrade user.
  • Installed dependencies using pip.
  • Switched to non-root user 'pubgrade' for improved security.
  • Updated the entrypoint for the Docker image.
build-complete-updater/Dockerfile
Updated configuration files.
  • Updated user access tokens for Akash and Alvaro.
  • Changed the intermediate registry format.
  • Removed the intermediate registry token.
pubgrade/config.yaml
Improved security by removing hardcoded secrets.
  • Removed hardcoded secrets like gh_access_token, cosign_password, and cosign_private_key.
  • Used environment variables for sensitive information like INTERMEDIATE_REGISTRY_TOKEN, COSIGN_PRIVATE_KEY, COSIGN_PASSWORD, and GH_ACCESS_TOKEN.
pubgrade/modules/endpoints/builds.py
pubgrade/secrets.py
Updated Makefile and Helm chart.
  • Updated the image name for Pubgrade in the Makefile.
  • Commented out the namespace creation and image update commands in the Makefile.
  • Updated the Helm chart API version from v2 to v1.
Makefile
deployment/Chart.yaml
helm/Chart.yaml
Added encryption rules for secrets.
  • Added a sops configuration file to encrypt secrets in the helm chart.
helm/templates/pubgrade-webserver/.sops.yaml
Added .helmignore file.
  • Created a .helmignore file to exclude unnecessary files from the Helm chart.
helm/.helmignore
Updated requirements.
  • Updated the Kubernetes library version.
build-complete-updater/requirements.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @lvarin - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Remove access tokens from version control (link)

Overall Comments:

  • The removal of requests from requirements.txt may cause issues as it appears to be a needed dependency. Please verify if this removal was intentional.
  • Please complete the PR description template by selecting the type of change and filling out the checklist. This helps with tracking and reviewing the changes.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


COPY --chown=1000:1000 ./ /app
##### WORKING DIRECTORY #####
WORKDIR /app

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (performance): Consider restructuring Dockerfile to optimize layer caching

Move the COPY command after installing dependencies to better utilize Docker layer caching. Copy only requirements.txt first, install dependencies, then copy the rest of the code.

Comment thread pubgrade/config.yaml
- name: 'Akash'
uid: 'akash.saini'
user_access_token: 'XXXXXXXXXXXXXXXXXXXX'
user_access_token: 'c42a6d44e3d0'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 issue (security): Remove access tokens from version control

Access tokens should not be committed to version control, even if truncated. Use environment variables or a secrets management system instead.

}"""
) % (intermediate_registry_format.split("/", 1)[0], intermediate_registry_token )
) % (intermediate_registry_format.split("/", 1)[0],
os.getenv("INTERMEDIATE_REGISTRY_TOKEN") )

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Add fallback handling for environment variables

Consider using os.getenv() with a default value or add explicit error handling for missing environment variables to prevent runtime errors.

Suggested change
os.getenv("INTERMEDIATE_REGISTRY_TOKEN") )
os.getenv("INTERMEDIATE_REGISTRY_TOKEN", None))
if template_config_file.find("None") != -1:
raise EnvironmentError("INTERMEDIATE_REGISTRY_TOKEN environment variable is not set")

def trigger_signing_image(dockerhub_token: str,
image_path: str, pull_tag: str, push_tag: str):
username, password = base64.b64decode(dockerhub_token).decode('utf-8').split(":")
url = "https://api.github.com/repos/{}/dispatches".format(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (code-quality): Replace call to format with f-string [×2] (use-fstring-for-formatting)

@lvarin lvarin left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LGTM

@DeRuina DeRuina left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@lvarin
lvarin merged commit ca9884f into dev Jan 13, 2025
@lvarin
lvarin deleted the helm_modifications_2 branch January 13, 2025 11:51
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