MCPcopy Create free account
hub / github.com/apache/mesos / validateID

Function validateID

src/common/validation.cpp:46–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44namespace validation {
45
46Option<Error> validateID(const string& id)
47{
48 if (id.empty()) {
49 return Error("ID must not be empty");
50 }
51
52 if (id.length() > NAME_MAX) {
53 return Error(
54 "ID must not be greater than " +
55 stringify(NAME_MAX) + " characters");
56 }
57
58 // The ID cannot be exactly these special path components.
59 if (id == "." || id == "..") {
60 return Error("'" + id + "' is disallowed");
61 }
62
63 // Rules on invalid characters in the ID:
64 // - Control characters are obviously not allowed.
65 // - Slashes are disallowed as IDs are likely mapped to directories in Mesos.
66 auto invalidCharacter = [](char c) {
67 return iscntrl(c) ||
68 c == os::POSIX_PATH_SEPARATOR ||
69 c == os::WINDOWS_PATH_SEPARATOR;
70 };
71
72 if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
73 return Error("'" + id + "' contains invalid characters");
74 }
75
76 return None();
77}
78
79
80// These IDs are valid as long as they meet the common ID requirements

Callers 8

validateContainerIdFunction · 0.85
getPersistentVolumePathFunction · 0.85
validateTaskIDFunction · 0.85
validateExecutorIDFunction · 0.85
validateSlaveIDFunction · 0.85
validateFrameworkIDFunction · 0.85
validateFrameworkIdFunction · 0.85
foreachFunction · 0.85

Calls 6

NoneClass · 0.85
ErrorFunction · 0.50
stringifyFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected