Commit e55a9703 authored by Jürg Billeter's avatar Jürg Billeter

Merge branch 'element-path_not_validated' into 'master'

Element path not validated before use

See merge request !937
parents e6e03451 56a54161
Pipeline #36565969 failed with stages
in 855 minutes and 42 seconds
......@@ -219,6 +219,19 @@ class Project():
return self._cache_key
def _validate_node(self, node):
_yaml.node_validate(node, [
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
'fail-on-overlap', 'shell', 'fatal-warnings',
'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
'sources', '(@)'
])
# create_element()
#
# Instantiate and return an element
......@@ -402,6 +415,8 @@ class Project():
"Project requested format version {}, but BuildStream {}.{} only supports up until format version {}"
.format(format_version, major, minor, BST_FORMAT_VERSION))
self._validate_node(pre_config_node)
# FIXME:
#
# Performing this check manually in the absense
......@@ -467,16 +482,7 @@ class Project():
self._load_pass(config, self.config)
_yaml.node_validate(config, [
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
'fail-on-overlap', 'shell', 'fatal-warnings',
'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
])
self._validate_node(config)
#
# Now all YAML composition is done, from here on we just load
......
# Project config for frontend build test
name: test
elephant-path: elements
......@@ -36,6 +36,19 @@ def test_show(cli, datafiles, target, format, expected):
.format(expected, result.output))
@pytest.mark.datafiles(os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"invalid_element_path",
))
def test_show_invalid_element_path(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
result = cli.run(project=project, silent=True, args=[
'show',
"foo.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("target,except_,expected", [
('target.bst', 'import-bin.bst', ['import-dev.bst', 'compose-all.bst', 'target.bst']),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment