summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-11-12 15:44:45 +0000
committerJürg Billeter <j@bitron.ch>2018-11-12 15:44:45 +0000
commite55a9703f9567953ee5675da4725940c08ec90eb (patch)
tree7632354c442f8eef2516611b6f84d707d3794931
parente6e034516ad8050b76f271b130d66d3a135223b8 (diff)
parent56a54161240cc843ee74e227a2af1f4be55a57f4 (diff)
downloadbuildstream-e55a9703f9567953ee5675da4725940c08ec90eb.tar.gz
Merge branch 'element-path_not_validated' into 'master'
Element path not validated before use See merge request BuildStream/buildstream!937
-rw-r--r--buildstream/_project.py26
-rw-r--r--tests/frontend/invalid_element_path/project.conf4
-rw-r--r--tests/frontend/show.py13
3 files changed, 33 insertions, 10 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 5280cf667..85c82b6e0 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -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
diff --git a/tests/frontend/invalid_element_path/project.conf b/tests/frontend/invalid_element_path/project.conf
new file mode 100644
index 000000000..7b09276e1
--- /dev/null
+++ b/tests/frontend/invalid_element_path/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+elephant-path: elements
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index ac2e71407..d6e153e2b 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -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']),