nikhilbadyal / docker-py-revanced

One Click Python util to build all Revanced apps.
https://nikhilbadyal.github.io/docker-py-revanced/
GNU General Public License v3.0
556 stars 430 forks source link

Changelogs #540

Closed SipeP closed 2 months ago

SipeP commented 2 months ago

PR Type

enhancement, tests, documentation


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
check_patches.py
Add script to fetch latest GitHub release tag                       

scripts/check_patches.py
  • Added a script to fetch the latest release tag from a GitHub
    repository.
  • Utilizes the GitHub API to get release information.
  • Includes error handling for API response.
  • +14/-0   
    download-previous-artifact
    Add script to download previous GitHub Actions artifact   

    scripts/download-previous-artifact
  • Added a script to download the previous artifact from a GitHub Actions
    workflow.
  • Includes error handling for missing workflows or artifacts.
  • +55/-0   
    Tests
    check_newest_revanced_patch.yml
    Add workflow to check for new Revanced Patches releases   

    .github/workflows/check_newest_revanced_patch.yml
  • Created a GitHub Actions workflow to check for new Revanced Patches
    releases.
  • Includes steps for setting up Python, installing dependencies, and
    running the new script.
  • Compares the latest release with the previous one and triggers another
    workflow if changes are detected.
  • +61/-0   
    Configuration changes
    newapp-check.yml
    Update repository reference in workflow condition               

    .github/workflows/newapp-check.yml - Updated repository reference in the workflow condition.
    +1/-1     
    Documentation
    changelog.json
    Update changelog with latest release information                 

    changelog.json
  • Added changelog entries for multiple repositories.
  • Includes version, changelog details, and publication date.
  • +44/-1   
    changelog.md
    Add markdown changelog entries for multiple repositories 

    changelog.md
  • Added markdown formatted changelog entries for multiple repositories.
  • +9/-0     
    updates.json
    Add update information for multiple applications                 

    updates.json
  • Added update information for multiple applications.
  • Includes app version, integration version, patches version, and other
    metadata.
  • +245/-1 

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Summary by Sourcery

    This pull request updates the version details and metadata for several apps in updates.json, adds the latest release information to changelog.json and changelog.md, and introduces a new GitHub Actions workflow to check for new ReVanced Patches releases.

    sourcery-ai[bot] commented 2 months ago

    Reviewer's Guide by Sourcery

    This pull request adds detailed patch information for various apps, updates changelog entries for multiple repositories, and introduces a new GitHub Actions workflow to automate checking for new ReVanced Patches releases.

    File-Level Changes

    Files Changes
    updates.json
    changelog.json
    changelog.md
    Added detailed patch and changelog information for multiple apps and repositories, and created a new markdown file for changelog entries.
    .github/workflows/newapp-check.yml
    .github/workflows/check_newest_revanced_patch.yml
    scripts/check_patches.py
    Updated existing GitHub Actions workflow and added a new workflow along with a Python script to automate checking for new ReVanced Patches releases.

    Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
    gitguardian[bot] commented 2 months ago

    โš ๏ธ GitGuardian has uncovered 1 secret following the scan of your pull request.

    Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

    Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard. Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

    ๐Ÿ”Ž Detected hardcoded secret in your pull request
    | GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [8555267](https://dashboard.gitguardian.com/workspace/199222/incidents/8555267) | Triggered | Base64 Basic Authentication | 40c47bdebcf7c9878210e061ccf904180cfd1832 | src/utils.py | [View secret](https://github.com/nikhilbadyal/docker-py-revanced/commit/40c47bdebcf7c9878210e061ccf904180cfd1832#diff-51246e53255db77c9edad496f074aa1bdbf8dbdc11f89a02040115c9ab4fa7f0R26) |
    ๐Ÿ›  Guidelines to remediate hardcoded secrets
    1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secret safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate this secret](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/base64_basic_auth#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

    ๐Ÿฆ‰ GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 4 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Key issues to review

    Error Handling
    The function `get_latest_release` uses a basic error handling that only checks for HTTP status code 200. It should handle other potential HTTP errors and exceptions from the `requests` library more robustly. Hardcoded Values
    The workflow contains hardcoded values for Python version and other settings which might need to be updated or parameterized for better flexibility and maintainability. Error Handling
    The script lacks comprehensive error handling for network requests and file operations which could lead to unhandled exceptions.
    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Improve error handling by wrapping the HTTP request in a try-except block ___ **To handle potential exceptions that may occur during the HTTP request, such as a
    connection error, it's advisable to wrap the request in a try-except block. This
    will improve the robustness of the function by handling these exceptions gracefully.** [scripts/check_patches.py [5-6]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-ce4c07edf5d90daba3fdbf0f909ab39f1fae22d1184fb827089c80f231ba5748R5-R6) ```diff -response = requests.get(url) -data = response.json() +try: + response = requests.get(url) + data = response.json() +except requests.exceptions.RequestException as e: + return str(e) ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: This suggestion significantly improves the robustness of the function by handling potential exceptions that may occur during the HTTP request, which is crucial for reliable operation.
    9
    Best practice
    Update the GitHub Actions checkout step to use a stable version ___ **Replace the deprecated actions/checkout@main with actions/checkout@v3 to ensure
    stability and access to the latest features and fixes.** [.github/workflows/check_newest_revanced_patch.yml [12]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-7392f67c6995d2c663f4eca550d7ea0d1f0de7f93255f5792d60990c443735deR12-R12) ```diff -uses: actions/checkout@main +uses: actions/checkout@v3 ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Updating to a stable version ensures better compatibility and access to the latest features and fixes, which is a best practice for maintaining CI/CD pipelines.
    9
    Update the Python setup action to a stable version ___ **Replace the deprecated actions/setup-python@main with actions/setup-python@v4 to
    ensure compatibility and stability.** [.github/workflows/check_newest_revanced_patch.yml [15]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-7392f67c6995d2c663f4eca550d7ea0d1f0de7f93255f5792d60990c443735deR15-R15) ```diff -uses: actions/setup-python@main +uses: actions/setup-python@v4 ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Using a stable version of the setup-python action ensures compatibility and stability, which is crucial for the reliability of the workflow.
    9
    Update the GitHub script action to a stable version ___ **Replace the deprecated actions/github-script@main with actions/github-script@v6 to
    ensure the use of supported features and improved security.** [.github/workflows/check_newest_revanced_patch.yml [25]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-7392f67c6995d2c663f4eca550d7ea0d1f0de7f93255f5792d60990c443735deR25-R25) ```diff -uses: actions/github-script@main +uses: actions/github-script@v6 ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Updating to a stable version of the GitHub script action ensures the use of supported features and improved security, which is important for maintaining the integrity of the workflow.
    9
    Update the artifact upload action to a stable version ___ **Replace the deprecated actions/upload-artifact@main with actions/upload-artifact@v3
    to ensure the use of supported features and improved security.** [.github/workflows/check_newest_revanced_patch.yml [51]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-7392f67c6995d2c663f4eca550d7ea0d1f0de7f93255f5792d60990c443735deR51-R51) ```diff -uses: actions/upload-artifact@main +uses: actions/upload-artifact@v3 ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Using a stable version of the upload-artifact action ensures the use of supported features and improved security, which is essential for the reliability and security of the workflow.
    9
    Ensure the HTTP response is successful before parsing it as JSON ___ **It's a good practice to check the HTTP response's status code before attempting to
    parse it as JSON. This prevents attempting to decode a JSON response when the HTTP
    request might have failed or returned an error status code.** [scripts/check_patches.py [6-7]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-ce4c07edf5d90daba3fdbf0f909ab39f1fae22d1184fb827089c80f231ba5748R6-R7) ```diff -data = response.json() if response.status_code == 200: + data = response.json() +else: + return "Failed to fetch data" ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Checking the HTTP response's status code before parsing it as JSON is a best practice that prevents errors when the request fails, enhancing the function's reliability.
    8
    Enhancement
    Return a structured error object for better error handling ___ **To make the function get_latest_release more robust, consider returning a more
    structured error message or object when the request fails, instead of just the error
    message string. This can help in debugging and logging.** [scripts/check_patches.py [9-10]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-ce4c07edf5d90daba3fdbf0f909ab39f1fae22d1184fb827089c80f231ba5748R9-R10) ```diff else: - return data['message'] + return {"error": True, "status_code": response.status_code, "message": data.get('message', 'Unknown error')} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Returning a structured error object provides more detailed information for debugging and logging, which enhances the function's robustness and maintainability.
    8
    Use a function or configuration to set the repository name dynamically ___ **Instead of hardcoding the repository name in the script, consider using a function
    parameter or a configuration file to make the script more flexible and reusable for
    different repositories.** [scripts/check_patches.py [13]](https://github.com/nikhilbadyal/docker-py-revanced/pull/540/files#diff-ce4c07edf5d90daba3fdbf0f909ab39f1fae22d1184fb827089c80f231ba5748R13-R13) ```diff -repo = "ReVanced/revanced-patches" # replace with your repository +# This can be set elsewhere in your application or passed as a parameter +repo = get_repo_name() ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: This enhancement makes the script more flexible and reusable for different repositories, improving maintainability and adaptability.
    7
    SipeP commented 2 months ago

    Sorry, still learning git, got confused and created this pull req on this repo instead of working on my fork.