emulator: fail if object_id of requirement starts with slash

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
remotes/origin/feature_files_export
Steven Armstrong 13 years ago
parent d346364544
commit f285d9e64e
  1. 15
      lib/cdist/emulator.py

@ -106,8 +106,19 @@ def run(argv):
# Record requirements
if "require" in os.environ:
requirements = os.environ['require']
log.debug("%s:Writing requirements: %s" % (cdist_object.path, requirements))
cdist_object.requirements.extend(requirements.split(" "))
for requirement in requirements.split(" "):
requirement_parts = requirement.split(os.sep, 1)
requirement_parts.reverse()
requirement_type_name = requirement_parts.pop()
try:
requirement_object_id = requirement_parts.pop()
except IndexError:
# no object id, must be singleton
requirement_object_id = 'singleton'
if requirement_object_id.startswith('/'):
raise core.IllegalObjectIdError(requirement_object_id, 'object_id may not start with /')
log.debug("Recording requirement: %s -> %s" % (cdist_object.path, requirement))
cdist_object.requirements.append(rement_object_id)
# Record / Append source
cdist_object.source.append(object_source)

Loading…
Cancel
Save