MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / isPathAllowed

Method isPathAllowed

modules/clibridge/clibridge.go:147–166  ·  view source on GitHub ↗
(relPath string)

Source from the content-addressed store, hash-verified

145}
146
147func (m *CLIBridgeModule) isPathAllowed(relPath string) bool {
148 dataDir := configs.GetFilePathsConfig().DataFiles.String()
149
150 absPath := filepath.Clean(filepath.Join(dataDir, relPath))
151
152 if !strings.HasPrefix(absPath, filepath.Clean(dataDir)) {
153 return false
154 }
155
156 for _, allowed := range m.getAllowedPaths() {
157 if allowed == `/*` {
158 return true
159 }
160 allowedAbs := filepath.Clean(filepath.Join(dataDir, allowed))
161 if strings.HasPrefix(absPath, allowedAbs) {
162 return true
163 }
164 }
165 return false
166}
167
168func (m *CLIBridgeModule) resolveArgs(args []string) ([]string, error) {
169 if len(args) == 0 {

Callers 1

resolveArgsMethod · 0.95

Calls 3

getAllowedPathsMethod · 0.95
GetFilePathsConfigFunction · 0.92
StringMethod · 0.65

Tested by

no test coverage detected