Skip to content

fix(plugins): Skip scan now actually skips — no more silent gate-blocking#58

Merged
DavidsonGomes merged 1 commit into
developfrom
fix/skip-scan-actually-skips
Apr 26, 2026
Merged

fix(plugins): Skip scan now actually skips — no more silent gate-blocking#58
DavidsonGomes merged 1 commit into
developfrom
fix/skip-scan-actually-skips

Conversation

@DavidsonGomes
Copy link
Copy Markdown
Member

@DavidsonGomes DavidsonGomes commented Apr 26, 2026

Summary

Found by Davidson: the plugin install wizard's Skip scan checkbox didn't do anything useful. Marking it sent `verdict=null` upward, `scanGatePassed` evaluated to `false`, and Confirmar instalação stayed disabled / silently dropped the request. The skip-reason textarea was tagged (required) but had no minimum, no validation feedback, and was never sent to the backend.

What changed

  • Added `'SKIPPED'` to the `ScanVerdict` union and emit it from `handleSkipToggle` when the checkbox is checked.
  • `scanGatePassed` now treats `SKIPPED` as a pass (same as `APPROVE`) — admin already made the call; backend audit-logs the skip regardless.
  • Skip-reason textarea placeholder rewritten as "Motivo (opcional, será registrado no audit log)". No length requirement. No client-side validation. The textarea exists for the audit trail, nothing else.
  • New optional `onSkipReason` callback flows the textarea text up to the install body so the backend's existing `skip_reason` audit field gets populated.
  • Install request now sends `body.skip_scan = true` + `body.skip_reason` when the verdict is `SKIPPED`. Backend (`routes/plugins.py:670+`) already accepts these — only the frontend was failing to emit them.
  • `UpdatePreviewModal` updated to also accept `'SKIPPED'` (it relied on the legacy `null === skip` pattern; both paths now work).

Why no required-reason

Davidson explicitly said justifying every skip is bobagem. The audit trail captures the action (admin id, timestamp, plugin slug, IP, optional reason). Refusing to act unless the admin types 20 characters of justification is friction that doesn't add security — it just teaches admins to type "ja ta ok"-equivalent boilerplate.

Test plan

  • `tsc --noEmit` clean
  • Manual: marking Skip scan allows Confirmar instalação to fire immediately without typing anything; with text, that text reaches the backend audit log.

🤖 Generated with Claude Code

Summary by Sourcery

Allow plugin installations and updates to explicitly bypass the security scan while still recording the action and optional reason for auditing.

Bug Fixes:

  • Fix the Skip scan checkbox so that choosing to skip a scan no longer silently blocks plugin installation.

Enhancements:

  • Introduce a dedicated SKIPPED scan verdict treated as a passing state in install and update flows, replacing the previous implicit null-based skip handling.
  • Propagate an optional skip reason from the security scan UI into the plugin install request so it can be stored in backend audit logs.

…king

Davidson found the install wizard's "Skip scan" checkbox didn't do anything
useful: marking it sent verdict=null upward, scanGatePassed evaluated to
false, and "Confirmar instalação" stayed disabled / silently dropped the
request. The skipReason textarea was tagged "(required)" but had no minimum,
no validation feedback, and was never sent to the backend.

What changed
- Added 'SKIPPED' to ScanVerdict union and emit it from handleSkipToggle
  when the checkbox is checked.
- scanGatePassed now treats SKIPPED as a pass (same as APPROVE) — admin
  already made the call; backend audit-logs the skip regardless.
- Skip reason textarea: placeholder rewritten as "Motivo (opcional, será
  registrado no audit log)". No length requirement. No client-side
  validation. The textarea exists for the audit trail, nothing else.
- New optional onSkipReason callback flows the textarea text up to the
  install body so the backend's existing skip_reason audit field gets
  populated.
- Install request now sends body.skip_scan = true + body.skip_reason when
  the verdict is SKIPPED. Backend (routes/plugins.py:670+) already accepts
  these — only the frontend was failing to emit them.
- UpdatePreviewModal updated to also accept 'SKIPPED' (it relied on the
  legacy null === skip pattern; now both paths work).

Tested
- tsc --noEmit clean
- Manual: marking Skip scan now allows "Confirmar instalação" to fire
  immediately without typing anything; with text, that text reaches the
  backend audit log.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 26, 2026

Reviewer's Guide

Frontend now treats skipping the security scan as an explicit passing verdict, propagates an optional skip reason to the backend, and updates scan gate logic across install/update modals to recognize the new SKIPPED verdict while cleaning up the skip UX.

Sequence diagram for skipping security scan during plugin install

sequenceDiagram
  actor Admin
  participant PluginInstallModal
  participant SecurityScanSection
  participant ApiClient
  participant Backend

  Admin->>PluginInstallModal: Open plugin install modal
  PluginInstallModal->>SecurityScanSection: Render with onVerdict, onSkipReason

  Admin->>SecurityScanSection: Check Skip scan checkbox
  SecurityScanSection->>SecurityScanSection: handleSkipToggle(true)
  SecurityScanSection->>PluginInstallModal: onVerdict(SKIPPED, null)
  SecurityScanSection-->>Admin: Show optional skip reason textarea

  Admin->>SecurityScanSection: Type optional skip reason
  SecurityScanSection->>SecurityScanSection: setSkipReason(text)
  SecurityScanSection->>PluginInstallModal: onSkipReason(text)
  PluginInstallModal->>PluginInstallModal: setSkipReason(text)

  PluginInstallModal->>PluginInstallModal: scanGatePassed = true (verdict SKIPPED)

  Admin->>PluginInstallModal: Click Confirmar instalação
  PluginInstallModal->>PluginInstallModal: Build request body
  PluginInstallModal->>PluginInstallModal: body.skip_scan = true
  PluginInstallModal->>PluginInstallModal: body.skip_reason = trimmed skipReason (if non-empty)

  PluginInstallModal->>ApiClient: POST /plugins/install body
  ApiClient->>Backend: POST /plugins/install body
  Backend-->>ApiClient: 200 OK (install result, audit logs skip)
  ApiClient-->>PluginInstallModal: Install result
  PluginInstallModal-->>Admin: Close modal, show installed plugin
Loading

Updated class diagram for scan verdict and plugin install components

classDiagram
  class ScanVerdict {
    <<union>>
    APPROVE
    WARN
    BLOCK
    SKIPPED
  }

  class ScanResult {
    <<type>>
    +status string
    +findings ScanFinding[]
  }

  class ScanFinding {
    +category string
    +severity string
    +message string
  }

  class SecurityScanSection {
    +sourceUrl string
    +authToken string
    +onVerdict(verdict ScanVerdict, result ScanResult) void
    +onVerdict(verdict null, result null) void
    +onOverride(reason string) void
    +onSkipReason(reason string) void
    -skipScan boolean
    -skipReason string
    -result ScanResult | null
    -error string | null
    -scanning boolean
    -hasRun Ref<boolean>
    +handleSkipToggle(checked boolean) void
  }

  class PluginInstallModal {
    -sourceUrl string
    -uploadedPath string | null
    -authToken string
    -scanVerdict ScanVerdict | null
    -scanResult ScanResult | null
    -overrideReason string
    -warnConfirmed boolean
    -skipReason string
    +scanGatePassed boolean
    +handleScanVerdict(verdict ScanVerdict | null, result ScanResult | null) void
    +handleOverride(reason string) void
    +handleInstall() Promise~void~
  }

  class UpdatePreviewModal {
    -scanVerdict ScanVerdict | null
    -overrideReason string
    -confirmed boolean
    +scanGatePassed boolean
  }

  SecurityScanSection --> ScanResult
  ScanResult --> ScanFinding

  PluginInstallModal o-- SecurityScanSection : renders
  PluginInstallModal --> ScanVerdict : uses
  PluginInstallModal --> ScanResult : stores

  UpdatePreviewModal --> ScanVerdict : uses

  SecurityScanSection --> PluginInstallModal : onVerdict, onSkipReason callbacks
Loading

File-Level Changes

Change Details Files
Introduce explicit SKIPPED scan verdict and wire it into SecurityScanSection behavior and props.
  • Extend ScanVerdict union to include 'SKIPPED' with doc comments explaining semantics.
  • Add optional onSkipReason callback to SecurityScanSection props and pass it through the component.
  • Update handleSkipToggle to emit 'SKIPPED' instead of null when checked, reset local skipReason and call onSkipReason with empty string when unchecked.
  • Wire textarea onChange to both local skipReason state and the onSkipReason callback, and update placeholder copy to indicate optional audit-logged reason.
dashboard/frontend/src/components/SecurityScanSection.tsx
Make plugin install flow treat SKIPPED as a passing scan and send skip metadata to backend.
  • Track skipReason in PluginInstallModal state, fed by SecurityScanSection via onSkipReason.
  • Update scanGatePassed logic to treat 'SKIPPED' verdict as an immediate pass alongside 'APPROVE'.
  • When verdict is 'SKIPPED', add skip_scan=true and optional trimmed skip_reason to the install request body before POSTing.
dashboard/frontend/src/components/PluginInstallModal.tsx
Align update flow scan gate with new SKIPPED verdict while keeping backward compatibility with legacy null-as-skip behavior.
  • Update UpdatePreviewModal scanGatePassed to accept 'SKIPPED' as a pass and clarify that null still represents legacy skip until a result arrives.
dashboard/frontend/src/components/UpdatePreviewModal.tsx

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
Copy Markdown

@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 found 1 issue, and left some high level feedback:

  • In UpdatePreviewModal, the scanGatePassed logic still treats BLOCK as passing on any truthy overrideReason, while the comments (and PluginInstallModal) require ≥20 chars; consider aligning the condition to avoid inconsistent override behavior.
  • Now that ScanVerdict includes 'SKIPPED' and the skip path calls onVerdict('SKIPPED', null), you might want to revisit the scanVerdict === null branch in UpdatePreviewModal (currently documented as a skip) to more clearly distinguish between “still scanning” and “legacy skip” states.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `UpdatePreviewModal`, the `scanGatePassed` logic still treats `BLOCK` as passing on any truthy `overrideReason`, while the comments (and `PluginInstallModal`) require ≥20 chars; consider aligning the condition to avoid inconsistent override behavior.
- Now that `ScanVerdict` includes `'SKIPPED'` and the skip path calls `onVerdict('SKIPPED', null)`, you might want to revisit the `scanVerdict === null` branch in `UpdatePreviewModal` (currently documented as a skip) to more clearly distinguish between “still scanning” and “legacy skip” states.

## Individual Comments

### Comment 1
<location path="dashboard/frontend/src/components/PluginInstallModal.tsx" line_range="73" />
<code_context>
+  //   WARN    = pass when checkbox confirmed
+  //   BLOCK   = pass when admin types a ≥20-char override reason
+  //   SKIPPED = pass immediately (admin chose to bypass; audit logs the action)
   const scanGatePassed =
     scanVerdict === null
       ? false // still scanning
</code_context>
<issue_to_address>
**issue (bug_risk):** BLOCK override rule here uses a ≥20-char requirement, but UpdatePreviewModal only checks for non-empty text.

This modal enforces `overrideReason.trim().length >= 20` for BLOCK, but `UpdatePreviewModal` only checks `(scanVerdict === 'BLOCK' && !!overrideReason)`, so any non-empty string is accepted. Since the comment states BLOCK should require a ≥20-char reason, these flows are out of sync. Please either apply the same length check in `UpdatePreviewModal` or centralize this validation so both modals share it.
</issue_to_address>

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.

// WARN = pass when checkbox confirmed
// BLOCK = pass when admin types a ≥20-char override reason
// SKIPPED = pass immediately (admin chose to bypass; audit logs the action)
const scanGatePassed =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): BLOCK override rule here uses a ≥20-char requirement, but UpdatePreviewModal only checks for non-empty text.

This modal enforces overrideReason.trim().length >= 20 for BLOCK, but UpdatePreviewModal only checks (scanVerdict === 'BLOCK' && !!overrideReason), so any non-empty string is accepted. Since the comment states BLOCK should require a ≥20-char reason, these flows are out of sync. Please either apply the same length check in UpdatePreviewModal or centralize this validation so both modals share it.

@DavidsonGomes DavidsonGomes merged commit d58c492 into develop Apr 26, 2026
4 checks passed
@DavidsonGomes DavidsonGomes deleted the fix/skip-scan-actually-skips branch April 26, 2026 18:20
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