MCPcopy Create free account
hub / github.com/Permify/permify / loadFromFile

Function loadFromFile

pkg/schema/loader.go:108–120  ·  view source on GitHub ↗

End loadFromURL

(path string)

Source from the content-addressed store, hash-verified

106 return string(body), nil // Return body
107} // End loadFromURL
108func loadFromFile(path string) (string, error) { // Load schema from file
109 // Clean the path
110 cleanPath := filepath.Clean(path)
111 // Check if the cleaned path is trying to traverse directories
112 if filepath.IsAbs(cleanPath) || strings.HasPrefix(cleanPath, "..") {
113 return "", errors.New("invalid file path")
114 }
115 content, err := os.ReadFile(path) // Read file
116 if err != nil { // Read failed
117 return "", err // Return error
118 } // Read succeeded
119 return string(content), nil // Return content
120} // End loadFromFile
121// loadInline is a function that handles inline schema types.
122func loadInline(schema string) (string, error) { // Load inline schema
123 // Add validation if necessary. For example:

Callers 1

loader_test.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected