MCPcopy Create free account
hub / github.com/conforma/cli / IsFilePathLike

Function IsFilePathLike

internal/validate/vsa/vsa.go:960–983  ·  view source on GitHub ↗

isFilePathLike checks if an identifier looks like a file path This handles the case where name.ParseReference incorrectly accepts file paths as valid image references

(identifier string)

Source from the content-addressed store, hash-verified

958// isFilePathLike checks if an identifier looks like a file path
959// This handles the case where name.ParseReference incorrectly accepts file paths as valid image references
960func IsFilePathLike(identifier string) bool {
961 // Check for relative path prefixes (most reliable indicator)
962 if strings.HasPrefix(identifier, "./") || strings.HasPrefix(identifier, "../") {
963 return true
964 }
965
966 // Check for absolute paths
967 if filepath.IsAbs(identifier) {
968 return true
969 }
970
971 // Check for file extensions (but not for image tags like :latest)
972 if filepath.Ext(identifier) != "" && !strings.Contains(identifier, ":") {
973 return true
974 }
975
976 // Check for path separators but not registry separators
977 // Image references can have / but not \ or multiple / in a row
978 if strings.Contains(identifier, "\\") || strings.Contains(identifier, "//") {
979 return true
980 }
981
982 return false
983}

Callers 1

validateVSAInputFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected