Skip to content

feat(security): RQ-2426 — Developer Script Mode preference#363

Open
dinex-dev wants to merge 1 commit into
masterfrom
feat/RQ-2426-dev-script-mode
Open

feat(security): RQ-2426 — Developer Script Mode preference#363
dinex-dev wants to merge 1 commit into
masterfrom
feat/RQ-2426-dev-script-mode

Conversation

@dinex-dev

@dinex-dev dinex-dev commented Jul 17, 2026

Copy link
Copy Markdown
Member

RQ-2426 — Developer Script Mode preference (desktop)

Ticket: RQ-2426 (part of RQ-3555) · PR 2 of 3 (proxy → desktop → web)

What

Adds the devScriptMode desktop user preference and wires it into the proxy so
"code" Modify Request/Response rules run in the secure sandbox by default, with
an opt-in Developer Script Mode (full host access).

  • userPreference schema/types + GET/UPDATE_DEV_SCRIPT_MODE actions
    (fail-safe: only an explicit boolean true / "true" enables it).
  • getDevScriptMode() threaded into proxyConfig in startProxyServer.
  • storage-cache applies the toggle live on the running proxy (no restart),
    mirroring the allowInsecureCerts pattern.

⚠️ Blocked on PR 1 — dep bump required before merge

This PR does not yet bump @requestly/requestly-proxy. Once
requestly-proxy#118 merges and publishes, bump the dependency here to that version —
that's what actually delivers safe-by-default execution to the app.

Not included (separate concern)

The Electron-42/Node-24 dev-run fix (dev-entry.cjs + start:main) is intentionally
excluded — it's a dev-tooling fix unrelated to RQ-2426.

Release note (breaking for power users)

After updating, existing code rules that use require/fs/process will be blocked
until the user enables Developer Script Mode. Built-in/example code rules (pure JSON
transforms) are unaffected.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a DEV script-execution mode preference for code rules.
    • Added controls to read and update the mode.
    • The setting can be applied to the running proxy without restarting.
  • Bug Fixes

    • Invalid or missing values now safely default DEV mode to disabled.
    • DEV mode is disabled by default, preserving sandboxed execution.

…ring

Adds the desktop `devScriptMode` user preference and threads it into the proxy so
"code" rules run sandboxed by default, with an opt-in full-access dev mode.

- userPreference schema/types + GET/UPDATE_DEV_SCRIPT_MODE actions (fail-safe:
  only an explicit boolean/"true" enables it).
- getDevScriptMode() → threaded into proxyConfig in startProxyServer.
- storage-cache applies it live on the running proxy (no restart), mirroring
  allowInsecureCerts.

Pairs with requestly-proxy RQ-2426 (safe/dev modes) and the interceptor web toggle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a boolean devScriptMode user preference with safe defaults, schema/type support, and GET/UPDATE actions. The proxy startup configuration now reads this preference, and running proxy instances receive live updates through setDevScriptMode. Update parsing accepts boolean true and the strings "true" or "1"; other values resolve to false.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a Developer Script Mode preference and related security-oriented behavior.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/RQ-2426-dev-script-mode

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dinex-dev
dinex-dev marked this pull request as ready for review July 17, 2026 08:46

@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: 1

🤖 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 `@src/renderer/services/storage-cache.ts`:
- Around line 49-56: Update the live preference application flow around
appliedLive, setAllowInsecureCerts, and setDevScriptMode so appliedLive is true
only when both methods exist and complete successfully. If either method is
unavailable or throws, preserve the false state so the fallback proxy restart is
triggered.
🪄 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: 812af10c-d9cd-4432-b088-c4ed6dc5e9b9

📥 Commits

Reviewing files that changed from the base of the PR and between 96f930b and f6a7394.

📒 Files selected for processing (7)
  • src/lib/storage/action-processors/user-preference.ts
  • src/lib/storage/schemas/userPreferenceSchema.ts
  • src/lib/storage/types/action-types.ts
  • src/lib/storage/types/user-preference.ts
  • src/renderer/actions/proxy/startProxyServer.ts
  • src/renderer/actions/storage/cacheUtils.ts
  • src/renderer/services/storage-cache.ts

Comment on lines +49 to +56
// RQ-2426: apply the DEV script-mode toggle live on the running proxy too.
// Only an explicit `true` enables it (full host access); anything else is
// the safe sandbox.
if (rqProxy?.setDevScriptMode) {
rqProxy.setDevScriptMode(newUserPreferences?.devScriptMode === true);
}
} catch (e) {
console.log("Failed to apply allowInsecureCerts live", e);
console.log("Failed to apply allowInsecureCerts/devScriptMode live", e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Ensure the fallback restart triggers if setDevScriptMode is unavailable.

Currently, appliedLive is set to true when setAllowInsecureCerts is present, regardless of whether setDevScriptMode exists. If an older proxy build has setAllowInsecureCerts but lacks setDevScriptMode, appliedLive will still evaluate to true, preventing the fallback proxy restart. This will cause the devScriptMode preference change to be silently ignored until the proxy restarts naturally.

To guarantee that the proxy restarts when any live update fails, appliedLive should only be true if both methods are available and applied successfully.

🐛 Proposed fix
-        let appliedLive = false;
+        let appliedLive = true;
         try {
           const rqProxy: any = RQProxyProvider.getInstance();
           if (rqProxy?.setAllowInsecureCerts) {
             rqProxy.setAllowInsecureCerts(!!newUserPreferences?.allowInsecureCerts);
-            appliedLive = true;
+          } else {
+            appliedLive = false;
           }
           // RQ-2426: apply the DEV script-mode toggle live on the running proxy too.
           // Only an explicit `true` enables it (full host access); anything else is
           // the safe sandbox.
           if (rqProxy?.setDevScriptMode) {
             rqProxy.setDevScriptMode(newUserPreferences?.devScriptMode === true);
+          } else {
+            appliedLive = false;
           }
         } catch (e) {
+          appliedLive = false;
           console.log("Failed to apply allowInsecureCerts/devScriptMode live", e);
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// RQ-2426: apply the DEV script-mode toggle live on the running proxy too.
// Only an explicit `true` enables it (full host access); anything else is
// the safe sandbox.
if (rqProxy?.setDevScriptMode) {
rqProxy.setDevScriptMode(newUserPreferences?.devScriptMode === true);
}
} catch (e) {
console.log("Failed to apply allowInsecureCerts live", e);
console.log("Failed to apply allowInsecureCerts/devScriptMode live", e);
// RQ-2426: apply the DEV script-mode toggle live on the running proxy too.
// Only an explicit `true` enables it (full host access); anything else is
// the safe sandbox.
if (rqProxy?.setDevScriptMode) {
rqProxy.setDevScriptMode(newUserPreferences?.devScriptMode === true);
} else {
appliedLive = false;
}
} catch (e) {
appliedLive = false;
console.log("Failed to apply allowInsecureCerts/devScriptMode live", e);
🤖 Prompt for 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.

In `@src/renderer/services/storage-cache.ts` around lines 49 - 56, Update the live
preference application flow around appliedLive, setAllowInsecureCerts, and
setDevScriptMode so appliedLive is true only when both methods exist and
complete successfully. If either method is unavailable or throws, preserve the
false state so the fallback proxy restart is triggered.

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