Skip to content

feat(plugins): secure yt-dlp and centralize plugin CI - #168

Merged
mpiton merged 16 commits into
mainfrom
feat/lot-1
Jul 16, 2026
Merged

feat(plugins): secure yt-dlp and centralize plugin CI#168
mpiton merged 16 commits into
mainfrom
feat/lot-1

Conversation

@mpiton

@mpiton mpiton commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace generic plugin subprocess execution with a typed, provider-scoped yt-dlp broker
  • add the reusable CI and immutable release workflow for official plugins
  • move from the Extism fork to upstream Extism 1.30.0 and remove the obsolete source allowlist
  • normalize media variant handling and isolate yt-dlp output per job

Validation

  • Rust fmt, Clippy and 1,509 tests pass
  • frontend lint, typecheck and 702 tests pass
  • actionlint validates the reusable workflow
  • targeted broker verification covers argument injection, binary replacement, output limits and process-group timeout

Linear: MAT-129, MAT-131


Summary by cubic

Secures the yt-dlp integration and centralizes plugin CI. Also closes broker validation races and atomically reserves adaptive download outputs to prevent overwrites.

  • New Features

    • Typed yt-dlp broker (MAT-131): approved plugins only; host discovers yt-dlp safely, builds args, clears env, disables external config/plugins/remote components, caps output, enforces process‑group timeouts, and uses private per‑job output dirs; strict run_subprocess shim and run_ytdlp; persists, revalidates, reconciles, and completes Store provenance outside user‑writable paths; grants only to Store‑installed official plugins matching freshly fetched registry SHA256s; app uses the broker for generic metadata and managed fallback downloads.
    • Reusable Plugin CI (MAT-129): split into read‑only verification and tag‑only release; release is owner‑only, publishes immutable assets, whitelists verified artifacts, checks central registry consistency, canonicalizes names, handles collisions, and rejects ambiguous registry releases.
  • Bug Fixes

    • Closed broker validation races around binary discovery and output‑dir checks.
    • Added atomic path reservation for adaptive outputs to avoid TOCTOU overwrites (reserve_unique_destination).
    • Upgraded to extism 1.30.0 and added command-group 5.0.1 for safe process‑group management.

Written for commit c2d55fb. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Security
    • Hardened media-plugin execution by removing the generic subprocess contract in favor of an approved yt-dlp broker flow with strict validation, timeouts, cleared environments, and capped output.
    • yt-dlp capabilities are now granted only to verified “official” Store plugins (matched against freshly fetched registry checksums); tampering/untrusted cases fail closed.
  • Bug Fixes
    • Improved plugin-driven video metadata parsing (variant kind/alias handling) and adaptive-stream placement/merge behavior.
  • Documentation
    • Updated the plugin development section to describe typed yt-dlp broker usage for the official YouTube plugin.
  • Release Reliability
    • Added automated plugin verification and immutable release automation with checksum/asset and registry consistency checks.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds a constrained yt-dlp broker, checksum-backed official-plugin provenance, provenance-aware store installation, broker-based media paths, and reusable CI/release workflows for manifest, ABI, artifact, release, and registry verification.

Changes

Plugin security and release verification

Layer / File(s) Summary
Broker contracts and request preparation
src-tauri/src/adapters/driven/plugin/ytdlp_broker/*
Adds typed media requests, input and filesystem validation, managed cleanup, selector construction, and legacy compatibility handling.
Trusted yt-dlp execution
src-tauri/src/adapters/driven/plugin/ytdlp_broker/platform.rs, process.rs, output.rs
Discovers approved binaries, controls process environments, bounds output, enforces timeouts, and validates execution behavior.
Official provenance and host grants
src-tauri/src/adapters/driven/plugin/{provenance.rs,extism_loader.rs,capabilities.rs}, src-tauri/src/domain/ports/driven/*
Persists and revalidates plugin checksums, gates yt-dlp host functions, and routes authoritative Store downloads through provenance-aware loading.
Store and IPC integration
src-tauri/src/application/commands/store_install.rs, src-tauri/src/adapters/driving/tauri_ipc.rs
Uses broker-managed download and metadata paths and updates plugin video-variant parsing.
Reusable plugin CI
.github/workflows/plugin-ci.yml
Verifies manifests, SemVer, formatting, linting, native tests, WASM exports, checksums, and canonical artifact contents.
Immutable plugin release
.github/workflows/plugin-release.yml
Publishes verified tag releases, checks exact assets and byte identity, and reports registry inconsistencies.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Store
  participant StoreInstall
  participant PluginLoader
  participant YtDlpBroker
  participant yt-dlp
  Store->>StoreInstall: download authoritative plugin
  StoreInstall->>PluginLoader: load official directory with provenance
  PluginLoader->>PluginLoader: verify manifest and WASM checksums
  PluginLoader->>YtDlpBroker: build granted host functions
  YtDlpBroker->>yt-dlp: execute validated request
  yt-dlp-->>YtDlpBroker: return bounded output
Loading
sequenceDiagram
  participant TagWorkflow
  participant PluginCI
  participant Artifact
  participant GitHubRelease
  participant Registry
  TagWorkflow->>PluginCI: invoke reusable verification workflow
  PluginCI->>Artifact: upload canonical dist bundle
  TagWorkflow->>Artifact: download verified bundle
  TagWorkflow->>GitHubRelease: create or validate immutable assets
  TagWorkflow->>Registry: compare version and checksums
  Registry-->>TagWorkflow: return consistency result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.49% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the two main changes: securing yt-dlp handling and centralizing plugin CI.

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci dependencies configuration rust labels Jul 15, 2026
@socket-security

socket-security Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​extism@​1.30.08010094100100
Addedcargo/​command-group@​5.0.110010093100100

View full report

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 2 regressed benchmarks
✅ 21 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
normalize_max_concurrent 120.8 ns 179.2 ns -32.56%
from_status_code_500 94.7 ns 123.9 ns -23.54%
from_status_code_200 123.3 ns 94.2 ns +30.97%
from_status_code_404 153.1 ns 123.9 ns +23.54%
split 471.9 ns 413.6 ns +14.1%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/lot-1 (c2d55fb) with main (60bb867)

Open in CodSpeed

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 25 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/request.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/platform.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/platform.rs Outdated
Comment thread src-tauri/src/adapters/driven/plugin/capabilities.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/audio.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs Outdated
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/legacy_download.rs Outdated
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/selectors.rs Outdated
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/legacy.rs Outdated

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/workflows/plugin-release.yml Outdated

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 26 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src-tauri/src/adapters/driven/plugin/extism_loader.rs
Comment thread src-tauri/src/adapters/driven/plugin/provenance.rs Outdated
Comment thread src-tauri/src/adapters/driven/plugin/provenance.rs Outdated
Comment thread .github/workflows/plugin-release.yml Outdated
Comment thread .github/workflows/plugin-release.yml

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src-tauri/src/adapters/driven/plugin/provenance.rs Outdated

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src-tauri/src/adapters/driven/plugin/provenance.rs Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/plugin-ci.yml:
- Around line 146-172: Update the “Build verified release bundle” step to remove
any existing dist directory contents before recreating it, ensuring stale files,
directories, and symlinks cannot survive. Preserve the existing canonical asset
copying, checksum generation, and asset-set validation.
- Around line 25-26: Update the actions/checkout step in the plugin CI workflow
to set persist-credentials to false, preventing the checkout token from
remaining available to subsequent Cargo build scripts and tests.
- Around line 106-141: Update the “Verify WASM artifact and ABI exports” step to
inspect the module’s actual WASM export table rather than llvm-nm’s
defined-symbol list. Preserve the package-specific required export sets and fail
with the existing missing-export behavior when any required name is absent from
the exported functions.

In @.github/workflows/plugin-release.yml:
- Around line 162-177: Update the registry lookup around entry selection to
collect all entries whose name matches manifest["name"] and require exactly one
match, rejecting zero or duplicate entries before validating metadata and
checksums. Use the sole matching entry for the existing version and checksum
comparisons, preserving the current error behavior for a missing plugin.

In `@src-tauri/src/adapters/driven/plugin/extism_loader.rs`:
- Around line 85-90: Update the path validation after resolve_path in the plugin
loading flow to use filesystem-aware canonical paths or filesystem identity
comparison for both plugins_dir and provenance_path, preventing case-only
aliases from bypassing containment checks. Preserve the existing
DomainError::ValidationError response for provenance inside the plugin
directory, and add a regression test covering case-insensitive path casing.

In `@src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/platform.rs`:
- Around line 12-18: Update the test setup around find_approved_binary to name
the symlink-escape candidate yt-dlp and place it inside a separate subdirectory
under the approved directory. Ensure the symlink still targets unsafe_binary
outside the approved tree, while valid remains the direct approved executable,
so filename validation passes and target/ancestor validation is exercised.

In `@src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs`:
- Around line 136-152: Update ensure_private_root and the
builder.create(&current) initialization path to treat an AlreadyExists error as
successful concurrent creation, then validate the resulting directory with
validate_private_root. Continue propagating other creation errors unchanged and
preserve the existing private-permission checks.
- Around line 14-24: Update the URL validation around parsed.scheme() to reject
every URL whose scheme is not HTTPS before the provider-specific Generic
canonicality checks. Preserve the existing Generic restrictions for credentials
and non-443 ports, while allowing only HTTPS URLs for all providers.

In `@src-tauri/src/adapters/driving/tauri_ipc.rs`:
- Around line 1808-1810: Update the destination handling around the
produced_canonical rename/copy flow to reserve dest_path atomically without
replacing an existing file. Use an atomic no-replace rename or a
create_new(true) reservation-and-retry loop, and ensure concurrent downloads
select a new path when reservation fails.

In `@src-tauri/src/application/commands/store_install.rs`:
- Around line 87-93: Update the installation flow around the
`tokio::task::spawn_blocking` result to capture both join and loader errors
instead of propagating immediately. Invoke the existing staging-directory
cleanup before returning the captured error, then propagate the result while
preserving the current `AppError` mappings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 760e03d6-f51b-4c4c-aec8-71ae8c390eae

📥 Commits

Reviewing files that changed from the base of the PR and between 60bb867 and 9f1af9a.

⛔ Files ignored due to path filters (1)
  • src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (31)
  • .github/workflows/plugin-ci.yml
  • .github/workflows/plugin-release.yml
  • CHANGELOG.md
  • README.md
  • deny.toml
  • src-tauri/Cargo.toml
  • src-tauri/src/adapters/driven/plugin/capabilities.rs
  • src-tauri/src/adapters/driven/plugin/extism_loader.rs
  • src-tauri/src/adapters/driven/plugin/host_functions.rs
  • src-tauri/src/adapters/driven/plugin/manifest.rs
  • src-tauri/src/adapters/driven/plugin/mod.rs
  • src-tauri/src/adapters/driven/plugin/provenance.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/legacy.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/legacy_download.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/output.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/platform.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/process.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/request.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/selectors.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/audio.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/legacy.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/mod.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/platform.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/process.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/request.rs
  • src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs
  • src-tauri/src/adapters/driving/tauri_ipc.rs
  • src-tauri/src/application/commands/store_install.rs
  • src-tauri/src/domain/ports/driven/plugin_loader.rs
  • src-tauri/src/domain/ports/driven/plugin_store_client.rs
💤 Files with no reviewable changes (1)
  • deny.toml

Comment thread .github/workflows/plugin-ci.yml
Comment thread .github/workflows/plugin-ci.yml Outdated
Comment thread .github/workflows/plugin-ci.yml
Comment thread .github/workflows/plugin-release.yml Outdated
Comment thread src-tauri/src/adapters/driven/plugin/extism_loader.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/tests/platform.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs
Comment thread src-tauri/src/adapters/driven/plugin/ytdlp_broker/validation.rs Outdated
Comment thread src-tauri/src/adapters/driving/tauri_ipc.rs Outdated
Comment thread src-tauri/src/application/commands/store_install.rs Outdated
@mpiton
mpiton merged commit d780e0f into main Jul 16, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci configuration dependencies documentation Improvements or additions to documentation rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant