Skip to content

Remediation suggestions for findings (tiered: explain / suggest-diff / auto-apply) #39

Description

@mesrikanthreddy

When

After M1–M8 are fully built and we have the big-picture view of kshield in action. Not before.

Current state

  • remediation.py already exists and is wired into the single-file /api/v1/scan path, but it only has real logic for one finding type: Broken Access Control. The generated patch is hardcoded and wrong in most cases — it always inserts @app.get('/unverified-access-fix', dependencies=[Depends(AuthenticationGuard)]) regardless of the route's actual HTTP method or path, and AuthenticationGuard doesn't exist anywhere in the codebase. Every other finding type just returns "Review your code logic manually." with no patch.
  • /api/v1/apply-patch (in actions.py) already applies that patch directly to disk via git apply. Given the patch above is templated/wrong, this endpoint currently ships a broken auto-apply feature for its one supported case.
  • The new repo-wide /api/v1/audit path (M1–M6) does not call remediation at all — none of its findings carry a remediation field.

Proposed direction — all three tiers, scoped by finding type

Tier What Candidate finding types
Explain only Clear description of why + what a correct fix looks like, no generated code AI Structural Hallucination, Syntax Violation
Suggest a diff, never auto-apply Patch shown for human review, not applied automatically Broken Access Control, Possible Typosquat, Undeclared Dependency
Auto-apply candidate Only where mechanically unambiguous TBD — likely none of the current finding types qualify without a human in the loop

A concrete improvement available once we get here

For Broken Access Control specifically: instead of inserting a fake guard, use graph_builder.py's route.guard_names to find a route elsewhere in the same repo that already has a real guard, and suggest applying that same guard with the flagged route's actual method/path. Contextually correct instead of templated.

Decisions to make when this is picked up

  1. Fix or retire the existing /apply-patch disk-write endpoint — it currently ships a broken patch for its only supported case.
  2. Whether the audit path's findings need remediation output in the same milestone, or as a follow-up.

Filed by request — implementation deliberately deferred until all milestones are complete.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions