(cmd: string)
| 221 | // Also resolve the rule's command name to canonical for cross-matching |
| 222 | // e.g., a deny rule for 'rm' should also block 'Remove-Item' |
| 223 | function matchesCommand(cmd: string): boolean { |
| 224 | switch (rule.type) { |
| 225 | case 'exact': |
| 226 | return strEquals(rule.command, cmd) |
| 227 | case 'prefix': |
| 228 | switch (matchMode) { |
| 229 | case 'exact': |
| 230 | return strEquals(rule.prefix, cmd) |
| 231 | case 'prefix': { |
| 232 | if (strEquals(cmd, rule.prefix)) { |
| 233 | return true |
| 234 | } |
| 235 | return strStartsWith(cmd, rule.prefix + ' ') |
| 236 | } |
| 237 | } |
| 238 | break |
| 239 | case 'wildcard': |
| 240 | if (matchMode === 'exact') { |
| 241 | return false |
| 242 | } |
| 243 | return matchWildcardPattern(rule.pattern, cmd, true) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | // Check against the original command |
| 248 | if (matchesCommand(command)) { |
no test coverage detected