MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / matchesPattern

Method matchesPattern

internal/plugins/command-runner/validator.go:56–71  ·  view source on GitHub ↗

matchesPattern checks if a command matches an allowed pattern Supports exact matches and template patterns like "systemctl status {service}"

(command, pattern string)

Source from the content-addressed store, hash-verified

54// matchesPattern checks if a command matches an allowed pattern
55// Supports exact matches and template patterns like "systemctl status {service}"
56func (v *Validator) matchesPattern(command, pattern string) bool {
57 // Exact match
58 if command == pattern {
59 return true
60 }
61
62 // Template match
63 template := ParseTemplate(pattern)
64 if len(template.Parameters) == 0 {
65 // No parameters, must be exact match
66 return false
67 }
68
69 // Check if command structure matches template
70 return v.matchesTemplateStructure(command, template)
71}
72
73// matchesTemplateStructure checks if a command matches the structure of a template
74func (v *Validator) matchesTemplateStructure(command string, template CommandTemplate) bool {

Callers 2

ValidateCommandMethod · 0.95
ValidateVMCommandMethod · 0.95

Calls 2

ParseTemplateFunction · 0.85

Tested by

no test coverage detected