MCPcopy Create free account
hub / github.com/github/gh-aw / parseCacheMemoryAllowedExtensions

Function parseCacheMemoryAllowedExtensions

pkg/workflow/cache.go:259–280  ·  view source on GitHub ↗
(cacheMap map[string]any, entry *CacheMemoryEntry)

Source from the content-addressed store, hash-verified

257}
258
259func parseCacheMemoryAllowedExtensions(cacheMap map[string]any, entry *CacheMemoryEntry) error {
260 allowedExts, exists := cacheMap["allowed-extensions"]
261 if !exists {
262 return nil
263 }
264 extArray, ok := allowedExts.([]any)
265 if !ok {
266 return nil
267 }
268 entry.AllowedExtensions = make([]string, 0, len(extArray))
269 for _, ext := range extArray {
270 extStr, ok := ext.(string)
271 if !ok {
272 continue
273 }
274 if !isValidFileExtension(extStr) {
275 return fmt.Errorf("invalid allowed-extension %q: must start with '.' followed by alphanumeric characters only (e.g. .json)", extStr)
276 }
277 entry.AllowedExtensions = append(entry.AllowedExtensions, extStr)
278 }
279 return nil
280}
281
282func applyDefaultAllowedExtensions(entry *CacheMemoryEntry) {
283 if len(entry.AllowedExtensions) == 0 {

Callers 1

parseCacheMemoryEntryFunction · 0.85

Calls 2

isValidFileExtensionFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected