MCPcopy Create free account
hub / github.com/freecodexyz/free-code / parsePermissionRule

Function parsePermissionRule

src/utils/permissions/shellRuleMatching.ts:159–184  ·  view source on GitHub ↗
(
  permissionRule: string,
)

Source from the content-addressed store, hash-verified

157 * Parse a permission rule string into a structured rule object.
158 */
159export function parsePermissionRule(
160 permissionRule: string,
161): ShellPermissionRule {
162 // Check for legacy :* prefix syntax first (backwards compatibility)
163 const prefix = permissionRuleExtractPrefix(permissionRule)
164 if (prefix !== null) {
165 return {
166 type: 'prefix',
167 prefix,
168 }
169 }
170
171 // Check for new wildcard syntax (contains * but not :* at end)
172 if (hasWildcards(permissionRule)) {
173 return {
174 type: 'wildcard',
175 pattern: permissionRule,
176 }
177 }
178
179 // Otherwise, it's an exact match
180 return {
181 type: 'exact',
182 command: permissionRule,
183 }
184}
185
186/**
187 * Generate permission update suggestion for an exact command match.

Callers 1

powershellPermissionRuleFunction · 0.85

Calls 2

hasWildcardsFunction · 0.85

Tested by

no test coverage detected