Spaces:
Runtime error
Runtime error
Download src/lib/exec-approval-utils.ts from Powerman9x/HuggingClaw-MissionControl: direct link, hf CLI and curl.
- Browser
- Download file 734 Bytes
-
https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/exec-approval-utils.ts
- Command line
-
hf download hf://spaces/Powerman9x/HuggingClaw-MissionControl@123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/exec-approval-utils.ts
-
curl -L -o exec-approval-utils.ts https://huggingface.co/spaces/Powerman9x/HuggingClaw-MissionControl/resolve/123e7c19b0ce60c8dc66ff876e0d2402eafbbbca/src/lib/exec-approval-utils.ts
734 Bytes
| /** | |
| * Glob-style pattern matching for exec approval allowlists. | |
| * Supports `*` as a wildcard that matches any characters. | |
| */ | |
| export function matchesGlobPattern(pattern: string, command: string): boolean { | |
| const p = pattern.toLowerCase().trim() | |
| const c = command.toLowerCase().trim() | |
| if (!p) return false | |
| if (p === c) return true | |
| if (!p.includes('*')) return false | |
| const regex = new RegExp('^' + p.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*') + '$') | |
| return regex.test(c) | |
| } | |
| /** | |
| * Find all patterns from a list that match a given command. | |
| */ | |
| export function findMatchingPatterns(patterns: string[], command: string): string[] { | |
| return patterns.filter(pattern => matchesGlobPattern(pattern, command)) | |
| } | |