Package burp.mcp.util
Class ApprovalManager
java.lang.Object
burp.mcp.util.ApprovalManager
Coordinates operator approvals for prompt-gated tool calls and out-of-scope
targets.
Flow: a tool call that needs approval creates (or reuses) a
ApprovalManager.PendingApproval and waits briefly for a UI decision.
If the operator answers in time the decision is applied immediately; if not,
the call returns a pending token and the agent retries the same call while
the operator can still answer from the Burp UI. Decisions are cached on the
pending request until it is consumed or its TTL expires, so nothing executes
after the client has stopped waiting.
Thread-safe. UI callbacks (ApprovalManager.Listener) fire on whichever thread
triggered the event and must be marshalled to the EDT by the listener.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEverything a pending approval needs to describe itself.static final classOne operator decision covering the permission and/or scope requirement.static interfaceUI hook; callbacks run on the calling thread.static final classstatic final classA pending (or already resolved but not yet consumed) approval request.static enumDecision for a permission-gated tool.static enumDecision for an out-of-scope target.static enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ApprovalManager.Listener listener) await(ApprovalManager.PendingApproval pending, long waitMs) Wait up towaitMsfor a decision.booleanCancel a pending request (server stop, UI cancel, expiry).voidCancel every pending request (e.g. listener shutdown).voidclearAll()Cancel pending requests and drop all session grants (test/reset helper).voidvoidconsume(ApprovalManager.PendingApproval pending) Remove a pending request after its allow decision has been consumed.Look up an unconsumed pending by client + fingerprint, or null.findOrCreate(ApprovalManager.Context ctx, long ttlMs) Find the pending approval for this client + fingerprint, or create it.Unresolved pending requests, oldest first.booleanisOriginGranted(String origin) booleanisToolGranted(String toolName) intvoidremoveListener(ApprovalManager.Listener listener) booleanresolve(String id, ApprovalManager.Decision decision) Record an operator decision.booleanrevokeOriginGrant(String origin) booleanrevokeToolGrant(String toolName) voidsetScopeAdder(Consumer<String> adder) Scope mutation callback used for ADD_TO_SCOPE decisions.voidExpire unresolved pendings past their TTL and prune resolved ones.
-
Constructor Details
-
ApprovalManager
public ApprovalManager()
-
-
Method Details
-
findOrCreate
Find the pending approval for this client + fingerprint, or create it. Resolved-but-unconsumed (denied) pendings are returned so retries get the cached decision instead of a second prompt. -
find
Look up an unconsumed pending by client + fingerprint, or null. -
await
Wait up towaitMsfor a decision. Only one waiter per pending request; extra callers are told PENDING immediately so retries cannot tie up worker threads. -
resolve
Record an operator decision. Applies session grants and scope additions immediately, so they take effect even if the client never retries.- Returns:
- true when this call made the decision, false if unknown/already decided.
-
cancel
Cancel a pending request (server stop, UI cancel, expiry). -
consume
Remove a pending request after its allow decision has been consumed. -
sweepExpired
public void sweepExpired()Expire unresolved pendings past their TTL and prune resolved ones. -
cancelAll
Cancel every pending request (e.g. listener shutdown). -
isToolGranted
-
isOriginGranted
-
getToolGrants
-
getOriginGrants
-
revokeToolGrant
-
revokeOriginGrant
-
clearSessionGrants
public void clearSessionGrants() -
clearAll
public void clearAll()Cancel pending requests and drop all session grants (test/reset helper). -
getPending
Unresolved pending requests, oldest first. -
pendingCount
public int pendingCount() -
getById
-
addListener
-
removeListener
-
setScopeAdder
Scope mutation callback used for ADD_TO_SCOPE decisions.
-