8000 fix(security): remove SSL bypass, log silent errors, add checksum validation by laurigates · Pull Request #1682 · hacksider/Deep-Live-Cam · GitHub
[go: up one dir, main page]

Skip to content

fix(security): remove SSL bypass, log silent errors, add checksum validation#1682

Open
laurigates wants to merge 2 commits intohacksider:mainfrom
laurigates:pr/fix-ssl-bypass-v2
Open

fix(security): remove SSL bypass, log silent errors, add checksum validation#1682
laurigates wants to merge 2 commits intohacksider:mainfrom
laurigates:pr/fix-ssl-bypass-v2

Conversation

@laurigates
Copy link
Contributor
@laurigates laurigates commented Feb 23, 2026

Summary

  • Remove macOS ssl._create_unverified_context monkey-patch — SSL certificate verification is now enabled on all platforms
  • run_ffmpeg() and detect_fps() now print errors instead of silently swallowing them
  • face_masking.apply_mask_area() logs blending failures before returning the unmodified frame
  • Add _compute_sha256() helper and expected_checksums parameter to conditional_download() — mismatched files are deleted and ValueError raised

Replaces #1658 (closed — wrong branch content).

Test plan

  • Verify model downloads succeed with SSL verification enabled
  • Confirm checksum validation catches corrupted downloads
  • Test face masking error path returns unmodified frame
  • Run ffmpeg operations and verify errors are logged

🤖 Generated with Claude Code

Summary by Sourcery

Tighten download and processing security by enabling SSL verification, adding checksum validation for downloaded files, and surfacing previously silent processing errors.

New Features:

  • Add SHA-256 checksum computation helper and optional expected_checksums support to conditional_download() to validate downloaded files.

Bug Fixes:

  • Remove macOS-specific SSL context monkey-patch so HTTPS certificate verification is enforced consistently.
  • Ensure run_ffmpeg() reports command failures instead of failing silently.
  • Ensure detect_fps() logs parsing errors before falling back to a default frame rate.
  • Ensure face_masking.apply_mask_area() logs blending failures before returning the original frame.

…idation

- Remove macOS ssl._create_unverified_context monkey-patch; SSL
  certificate verification is now enabled on all platforms
- run_ffmpeg and detect_fps now print the error instead of swallowing it
- face_masking blending failure is logged before returning the unmodified frame
- Add _compute_sha256 helper and expected_checksums parameter to
  conditional_download; mismatched files are deleted and ValueError raised

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sourcery-ai
Copy link
Contributor
sourcery-ai bot commented Feb 23, 2026

Reviewer's Guide

Enables SSL certificate verification again, improves error visibility in ffmpeg and face masking utilities, and adds optional SHA-256 checksum verification to model downloads to detect and delete corrupted files.

Class diagram for utilities and face_masking changes

classDiagram
    class Utilities {
        <<module>>
        +str TEMP_FILE
        +str TEMP_DIRECTORY
        +str _compute_sha256(file_path)
        +bool run_ffmpeg(args)
        +float detect_fps(target_path)
        +void conditional_download(download_directory_path, urls, expected_checksums)
    }

    class FaceMasking {
        <<module>>
        +apply_mask_area(frame, mask, min_x, min_y, max_x, max_y, erosion, blur_amount, feather_amount, sigma)
    }
Loading

Flow diagram for conditional_download with checksum validation

flowchart TD
    A[Start conditional_download] --> B{download_directory_path exists?}
    B -- Yes --> C[Iterate over urls]
    B -- No --> B1[Create download_directory_path] --> C

    C --> D[Take next url]
    D --> E{url is a Google Drive link?}
    E -- Yes --> F[Handle Google Drive download]
    E -- No --> G[Handle standard download]

    F --> H[Set download_file_path]
    G --> H

    H --> I{download_file_path exists?}
    I -- Yes --> C
    I -- No --> J[Download file with urlretrieve and progress]

    J --> K{expected_checksums provided and filename in expected_checksums?}
    K -- No --> C
    K -- Yes --> L["_compute_sha256(download_file_path)"]

    L --> M{actual checksum == expected checksum?}
    M -- Yes --> N[Log checksum verified] --> C
    M -- No --> O[Delete download_file_path]
    O --> P[Raise ValueError for checksum mismatch]

    C --> Q[All urls processed]
    Q --> R[End conditional_download]
Loading

File-Level Changes

Change Details Files
Improve robustness and observability of ffmpeg utilities and face masking by logging errors instead of silently swallowing exceptions.
  • Update run_ffmpeg to print a descriptive message when the subprocess call fails and return False
  • Update detect_fps to log parsing errors with the target path and exception details before falling back to 30 FPS
  • Update face_masking.apply_mask_area to log blending failures while preserving the behavior of returning the original frame
modules/utilities.py
modules/processors/frame/face_masking.py
Tighten download and integrity behavior by removing SSL bypass and adding optional SHA-256 checksum validation for downloaded files.
  • Remove macOS-only ssl._create_unverified_context monkey patch so SSL certificate verification remains enabled
  • Introduce a _compute_sha256 helper that streams files in 1 MiB chunks to compute SHA-256 hashes
  • Extend conditional_download with an expected_checksums parameter keyed by filename, computing and comparing hashes after download
  • On checksum mismatch, delete the downloaded file and raise a ValueError; on success, log a checksum verification message
modules/utilities.py

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The new error reporting in run_ffmpeg, detect_fps, and apply_mask_area uses bare print calls, which may be noisy or hard to route in non-CLI environments; consider routing these through the existing logging mechanism or stderr so callers can better control verbosity.
  • The expected_checksums mapping in conditional_download is keyed by os.path.basename(url), which can be ambiguous if different URLs share the same filename; consider keying by full URL or allowing callers to specify an explicit filename key to avoid silent collisions.
  • Changing the conditional_download signature to add expected_checksums may break existing callers; if this is a public helper, consider using a keyword-only argument, defaulting via **kwargs, or adding a wrapper to maintain backward compatibility.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new error reporting in `run_ffmpeg`, `detect_fps`, and `apply_mask_area` uses bare `print` calls, which may be noisy or hard to route in non-CLI environments; consider routing these through the existing logging mechanism or `stderr` so callers can better control verbosity.
- The `expected_checksums` mapping in `conditional_download` is keyed by `os.path.basename(url)`, which can be ambiguous if different URLs share the same filename; consider keying by full URL or allowing callers to specify an explicit filename key to avoid silent collisions.
- Changing the `conditional_download` signature to add `expected_checksums` may break existing callers; if this is a public helper, consider using a keyword-only argument, defaulting via `**kwargs`, or adding a wrapper to maintain backward compatibility.

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.

laurigates added a commit to laurigates/Deep-Live-Cam that referenced this pull request Feb 24, 2026
- Replace bare print() calls with logger.error/warning/info in
  utilities.py and face_masking.py; routes output through the standard
  logging framework so callers can control verbosity
- Key expected_checksums by full URL instead of os.path.basename(url)
  to prevent silent collisions when different URLs share the same filename
- Make expected_checksums keyword-only (add * sentinel) to prevent
  accidental positional passing and clarify the API boundary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace bare print() calls with logger.error/warning/info in
  utilities.py and face_masking.py; routes output through the standard
  logging framework so callers can control verbosity
- Key expected_checksums by full URL instead of os.path.basename(url)
  to prevent silent collisions when different URLs share the same filename
- Make expected_checksums keyword-only (add * sentinel) to prevent
  accidental positional passing and clarify the API boundary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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

0