MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / AnalyzeCommandPermissions

Function AnalyzeCommandPermissions

tools/bash/permissions.go:119–137  ·  view source on GitHub ↗
(command string)

Source from the content-addressed store, hash-verified

117}
118
119func AnalyzeCommandPermissions(command string) PermissionResult {
120 subcommands := SplitPipeline(command)
121 if len(subcommands) > MaxSubcommandsForSecurityCheck {
122 return PermissionResult{
123 Allowed: false, Risk: RiskHigh,
124 Reason: fmt.Sprintf("Too many subcommands (%d > %d)", len(subcommands), MaxSubcommandsForSecurityCheck),
125 NeedsUserDecision: true, ParseResult: ParseTooComplex,
126 }
127 }
128 results := make([]PermissionResult, 0, len(subcommands))
129 for _, sub := range subcommands {
130 results = append(results, analyzeSingleCommand(sub))
131 }
132 result := AggregateCompoundPermissions(results)
133 if result.NeedsUserDecision {
134 result.SuggestedRules = generateRuleSuggestions(subcommands)
135 }
136 return result
137}
138
139func analyzeSingleCommand(command string) PermissionResult {
140 cleaned := strings.TrimSpace(command)

Callers 2

initFunction · 0.85

Calls 4

SplitPipelineFunction · 0.85
analyzeSingleCommandFunction · 0.85
generateRuleSuggestionsFunction · 0.85