Skip to content

Fix outdated detector API usage in scanning modules#48

Open
kavya-seth-vns wants to merge 1 commit into
OWASP:mainfrom
kavya-seth-vns:fix-detector-inspect-api
Open

Fix outdated detector API usage in scanning modules#48
kavya-seth-vns wants to merge 1 commit into
OWASP:mainfrom
kavya-seth-vns:fix-detector-inspect-api

Conversation

@kavya-seth-vns

@kavya-seth-vns kavya-seth-vns commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #44

Summary

This PR updates the scanning utilities to use the current detector API and resolves the runtime failures caused by outdated detector interface usage.

Changes

  • Replaced deprecated detector.detect() calls with detector.inspect().

  • Updated DetectionResult field access to match the current API:

    • detectedmatched
  • Updated the affected modules:

    • scan.py
    • tools.py
    • streaming.py
    • rag.py

Validation

The issue was reproduced before the fix:

AttributeError: 'PromptInjectionDetector' object has no attribute 'detect'

After applying the changes:

  • scan() executes successfully.
  • scan_tool_output() executes successfully.
  • StreamScanner.feed() executes successfully.
  • scan_rag_input() executes successfully.

Testing

Executed the full test suite:

96 passed, 10 xfailed

Additionally, the following runtime checks were verified successfully:

  • scan("hello")
  • scan_tool_output("hello")
  • StreamScanner().feed("hello")
  • scan_rag_input("hello")

These changes align the scanning modules with the current Detector protocol and eliminate the AttributeError caused by calls to the removed detect() method.

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.

[bug] detector.detect() raises AttributeError — 4 modules broken, confirmed at runtime

1 participant