MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getRuleByContentsForToolName

Function getRuleByContentsForToolName

src/utils/permissions/permissions.ts:362–390  ·  view source on GitHub ↗
(
  context: ToolPermissionContext,
  toolName: string,
  behavior: PermissionBehavior,
)

Source from the content-addressed store, hash-verified

360
361// Used to break circular dependency where a Tool calls this function
362export function getRuleByContentsForToolName(
363 context: ToolPermissionContext,
364 toolName: string,
365 behavior: PermissionBehavior,
366): Map<string, PermissionRule> {
367 const ruleByContents = new Map<string, PermissionRule>()
368 let rules: PermissionRule[] = []
369 switch (behavior) {
370 case 'allow':
371 rules = getAllowRules(context)
372 break
373 case 'deny':
374 rules = getDenyRules(context)
375 break
376 case 'ask':
377 rules = getAskRules(context)
378 break
379 }
380 for (const rule of rules) {
381 if (
382 rule.ruleValue.toolName === toolName &&
383 rule.ruleValue.ruleContent !== undefined &&
384 rule.ruleBehavior === behavior
385 ) {
386 ruleByContents.set(rule.ruleValue.ruleContent, rule)
387 }
388 }
389 return ruleByContents
390}
391
392/**
393 * Runs PermissionRequest hooks for headless/async agents that cannot show

Callers 3

matchingRulesForInputFunction · 0.85
getPatternsByRootFunction · 0.85
getRuleByContentsForToolFunction · 0.85

Calls 4

getAllowRulesFunction · 0.85
getDenyRulesFunction · 0.85
getAskRulesFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected