Skip to content

feat: add MaybeDontAnalyzer security analyzer#2142

Open
robotdan wants to merge 1 commit intoOpenHands:mainfrom
maybedont:degroff/maybedont-analyzer
Open

feat: add MaybeDontAnalyzer security analyzer#2142
robotdan wants to merge 1 commit intoOpenHands:mainfrom
maybedont:degroff/maybedont-analyzer

Conversation

@robotdan
Copy link

@robotdan robotdan commented Feb 20, 2026

Summary

Adds MaybeDontAnalyzer, a new SecurityAnalyzerBase implementation that validates agent actions against policy rules configured in a Maybe Don't Gateway instance.

  • Calls the gateway's POST /api/v1/action/validate endpoint before action execution
  • Maps ActionEvent fields (tool_name, tool_call.arguments, thought, summary) to the gateway's request format
  • Maps the gateway's risk_level response directly to SecurityRisk (HIGH/MEDIUM/LOW/UNKNOWN)
  • Graceful degradation: all errors (timeout, unreachable, 500, invalid JSON) return UNKNOWN
  • Follows the GraySwan analyzer patterns: Pydantic fields, lazy httpx client, model_post_init env var resolution, set_events/close lifecycle

How it fits with existing integrations

Layer What Covers
Security Analyzer (this PR) Pre-execution validation via REST endpoint ALL actions: shell commands, file ops, browser, tool calls
MCP Proxy (existing docs) Execution-time validation + proxying Only MCP tool calls routed through the gateway

MaybeDont doc for OpenHands

Configuration

from openhands.sdk.security.maybedont import MaybeDontAnalyzer

analyzer = MaybeDontAnalyzer()  # defaults to http://localhost:8080
# or
analyzer = MaybeDontAnalyzer(gateway_url="http://my-gateway:8080")
# or via env var
# MAYBE_DONT_GATEWAY_URL=http://my-gateway:8080

Files

File Purpose
openhands-sdk/openhands/sdk/security/maybedont/analyzer.py MaybeDontAnalyzer class
openhands-sdk/openhands/sdk/security/maybedont/__init__.py Package export
openhands-sdk/openhands/sdk/security/__init__.py Added to module __all__
tests/sdk/security/maybedont/test_maybedont_analyzer.py 41 unit tests
examples/01_standalone_sdk/40_maybedont_security_analyzer.py Usage example

Test plan

  • uv run pytest tests/sdk/security/maybedont/ -v — 41 tests pass
  • uv run pytest tests/sdk/security/ -v — 119 tests pass (no regressions)
  • make format && make lint — clean
  • Integration tested against a live Maybe Don't Gateway (CEL deny rule for rm -rf → HIGH, safe commands → LOW)

🤖 Generated with Claude Code

Implements a SecurityAnalyzerBase that validates agent actions against
policy rules configured in a Maybe Don't Gateway instance. Calls the
gateway's POST /api/v1/action/validate endpoint and maps the response
risk_level directly to SecurityRisk.

- MaybeDontAnalyzer class following GraySwan patterns
- 41 tests covering init, request building, risk mapping, error handling,
  HTTP lifecycle, and end-to-end security_risk flow
- Example script (40_maybedont_security_analyzer.py)
- Exported from openhands.sdk.security module

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

Comments