Skip to content

Show when a patch needs an opt-in setting - #2085

Draft
Wenxin Jiang (Wenxin-Jiang) wants to merge 7 commits into
mainfrom
wenxin/opt-in-note
Draft

Wenxin Jiang (Wenxin-Jiang) wants to merge 7 commits into
mainfrom
wenxin/opt-in-note

Conversation

@Wenxin-Jiang

Copy link
Copy Markdown
Contributor

LLM Description written by Claude Code:claude-opus-5-5


When a Socket patch only protects users who turn on a setting, the CLI now says so. get, list and apply print the patch's opt-in note, keep it in .socket/manifest.json and their JSON output, and add it to the OpenVEX impact statement. Before this, the CLI printed "Fixes", "Patched packages" and "already patched" with no hint that defaults stay vulnerable.

Problem

Some advisories are fixed upstream only behind an option that is off by default. Socket research is starting to record this (requiresOptIn plus optInNote), and the patches API will return both fields. The CLI's API types and manifest schema had nowhere to keep them, so the note would have been dropped, and vex would have reported the package as not_affected with only "Patched via Socket".

Change

  • PatchResponse, PatchSearchResult, BatchPatchInfo and the manifest PatchRecord gain optional requiresOptIn and optInNote. Missing fields deserialize as None and are not written, so old manifests and API responses keep their exact shape in both directions.
  • get keeps both fields when writing the manifest.
  • Human get, list, apply and scan output print the note for flagged patches. The note is printed as data: control sequences are stripped and multi-line notes are indented. JSON events carry the raw values under details.
  • CLI OpenVEX impact_statement appends the opt-in instruction. The VEX status itself is unchanged.
  • The other ~70 files only add None to struct literals for the new fields.

Testing

  • cargo fmt --all -- --check and cargo clippy --locked --workspace --all-features -- -D warnings pass.
  • cargo test --locked -p socket-patch-core: 8,425 passed, 0 failed.
  • cargo test --locked -p socket-patch-cli --lib --test get --test cli --test apply --test vex --test scan: 1,619 passed, 0 failed.
  • The full local CLI run had 6 failures unrelated to this change: 4 registry fixtures rejected by a local Socket Security CA, and 2 Bun mirror-refusal tests that also fail in isolation. CI runs the full suite.

For the reviewer

  • The server side (research fields, publish hold when the note is missing, API fields) is in separate depscan and patchpedia PRs. This PR is safe to release first, because absent fields change nothing.

🤖 Generated with Claude Code

Preserve optional activation metadata in manifest records and render it in get, list, apply, and OpenVEX output.

Absent fields stay absent when serializing, so existing responses and manifests keep their current shape.

Assisted-by: Claude Code:kimi-k3p1-pro
@cursor

cursor Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Mostly additive CLI and schema surfacing with optional fields; apply/vex behavior is unchanged except for clearer messaging.

Overview
Adds optional requiresOptIn and optInNote from the patches API through core types, manifest records, and download paths so patches that only protect users who change a setting are not silently treated as fully fixed.

get, list, apply, and scan human output now show an opt-in note when the flag is true, with notes passed through terminal_text so control characters cannot hijack the terminal. apply also prints a post-run Opt-in required block for applied or unmatched flagged packages. --json envelopes register opt-in metadata and attach requiresOptIn / optInNote on matching patch events.

Manifest and agent metadata persistence include the new fields (omitted when unset for backward compatibility). OpenVEX impact_statement text appends the opt-in instruction when present.

Reviewed by Cursor Bugbot for commit ef1586f. Configure here.

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ef1586f. Configure here.

.into_iter()
.map(|e| tag_mode(e, Some("vendored"))),
);
env.add_registered_opt_in_to_events();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Scan JSON events omit opt-in details

Medium Severity

scan --json never calls register_opt_in, so Applied/vendored/hosted action events leave details without requiresOptIn and optInNote. The new add_registered_opt_in_to_events hook in merge_vendor_envelope therefore no-ops on scan, while get registers first and those events do carry the fields. Human scan output still prints the note from patch_block.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ef1586f. Configure here.

Refresh same-UUID activation metadata, including clearing it, and record the new fields as known manifest keys.

Hosted, repeated-agent, and dry-run scans render sanitized notes once per patch UUID. Link nested apply deduplication to the UUIDs its caller already showed. Enrich scan JSON events from both batch and detailed API records.

Assisted-by: Claude Code:kimi-k3p1-pro
Suppress a nested note only when its UUID, flag, and full note match what the caller displayed. Keep changed API instructions visible.

Strip control characters from decoded PURLs in note output. Add regressions for differing search/view notes, terminal controls, and UUID deduplication.

Assisted-by: Claude Code:kimi-k3p1-pro
Fetched patch views now override search metadata in get and scan JSON, including changed or cleared instructions. Reused detached vendor records consume the same prefetched view and persist activation metadata even when artifacts and wiring need no work.

Make the manifest schema-key test populate both records so its assertion is not HashMap-order dependent.

Assisted-by: Claude Code:kimi-k3p1-pro
Fetch authoritative patch views for same-UUID detached reuse, including search-based reuse, while preserving existing fields offline.

Move human activation notes after download and persistence. Use one shared formatter keyed by UUID and note, and carry that exact displayed metadata into nested apply deduplication.

Assisted-by: Claude Code:kimi-k3p1-pro
Use fetched or persisted activation metadata after real downloads and one shared preview renderer for dry runs. Defer wet vendored output to the shared vendor step and cover agent, hosted, vendored, agent, apply, and list paths with a parameterized exact-once matrix.

Keep unsupported save-only combinations as zero-request usage errors and preserve offline vendor activation metadata.

Assisted-by: Claude Code:kimi-k3p1-pro
Register manifest and detached vendor metadata for both check JSON envelopes, including already-patched and drift events. Represent detached vendor state in manifest-free JSON without changing unrelated empty applies.

Keep human output deduplicated by UUID and note, and leave direct UUID dry-run rendering to its preview layer. Extend the output matrix with human and JSON assertions for every mode and operation.

Assisted-by: Claude Code:kimi-k3p1-pro
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