MCPcopy
hub / github.com/opencontainers/runc / validateID

Function validateID

libcontainer/factory_linux.go:192–219  ·  view source on GitHub ↗

validateID checks if the supplied container ID is valid, returning the ErrInvalidID in case it is not. The format of valid ID was never formally defined, instead the code was modified to allow or disallow specific characters. Currently, a valid ID is a non-empty string consisting only of the follo

(id string)

Source from the content-addressed store, hash-verified

190// (such as . or ..) are rejected.
191
192func validateID(id string) error {
193 if len(id) < 1 {
194 return ErrInvalidID
195 }
196
197 // Allowed characters: 0-9 A-Z a-z _ + - .
198 for i := range len(id) {
199 c := id[i]
200 switch {
201 case c >= 'a' && c <= 'z':
202 case c >= 'A' && c <= 'Z':
203 case c >= '0' && c <= '9':
204 case c == '_':
205 case c == '+':
206 case c == '-':
207 case c == '.':
208 default:
209 return ErrInvalidID
210 }
211
212 }
213
214 if string(os.PathSeparator)+id != pathrs.LexicallyCleanPath(string(os.PathSeparator)+id) {
215 return ErrInvalidID
216 }
217
218 return nil
219}

Callers 2

CreateFunction · 0.85
LoadFunction · 0.85

Calls 1

LexicallyCleanPathFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…