Chandan Singh pushed to branch chandan/fix-bad-filename-disaster at BuildStream / buildstream
Commits:
-
3295f9b5
by Chandan Singh at 2019-01-03T00:32:45Z
-
142fafbf
by Chandan Singh at 2019-01-03T00:32:45Z
-
0e8ff35b
by Chandan Singh at 2019-01-03T00:32:45Z
-
298cf7f6
by Tristan Maat at 2019-01-03T00:32:45Z
-
07f8692b
by Javier Jardón at 2019-01-03T00:32:45Z
13 changed files:
- .gitlab-ci.yml
- buildstream/_ostree.py
- buildstream/_signals.py
- buildstream/element.py
- dev-requirements.txt
- doc/Makefile
- doc/source/format_declaring.rst
- setup.cfg
- tests/frontend/buildcheckout.py
- + tests/frontend/project/elements/invalid-chars-in-dep.bst
- tests/frontend/project/project.conf
- tests/testutils/http_server.py
- tests/testutils/site.py
Changes:
1 |
-image: buildstream/testsuite-debian:9-master-123-7ce6581b
|
|
1 |
+image: buildstream/testsuite-debian:9-06bab030-b848172c
|
|
2 | 2 |
|
3 | 3 |
cache:
|
4 | 4 |
key: "$CI_JOB_NAME-"
|
... | ... | @@ -91,23 +91,23 @@ source_dist: |
91 | 91 |
- ${COVERAGE_DIR}
|
92 | 92 |
|
93 | 93 |
tests-debian-9:
|
94 |
- image: buildstream/testsuite-debian:9-master-123-7ce6581b
|
|
94 |
+ image: buildstream/testsuite-debian:9-06bab030-b848172c
|
|
95 | 95 |
<<: *tests
|
96 | 96 |
|
97 | 97 |
tests-fedora-27:
|
98 |
- image: buildstream/testsuite-fedora:27-master-123-7ce6581b
|
|
98 |
+ image: buildstream/testsuite-fedora:27-06bab030-b848172c
|
|
99 | 99 |
<<: *tests
|
100 | 100 |
|
101 | 101 |
tests-fedora-28:
|
102 |
- image: buildstream/testsuite-fedora:28-master-123-7ce6581b
|
|
102 |
+ image: buildstream/testsuite-fedora:28-06bab030-b848172c
|
|
103 | 103 |
<<: *tests
|
104 | 104 |
|
105 | 105 |
tests-ubuntu-18.04:
|
106 |
- image: buildstream/testsuite-ubuntu:18.04-master-123-7ce6581b
|
|
106 |
+ image: buildstream/testsuite-ubuntu:18.04-06bab030-b848172c
|
|
107 | 107 |
<<: *tests
|
108 | 108 |
|
109 | 109 |
overnight-fedora-28-aarch64:
|
110 |
- image: buildstream/testsuite-fedora:aarch64-28-master-123-7ce6581b
|
|
110 |
+ image: buildstream/testsuite-fedora:aarch64-28-06bab030-32a101f6
|
|
111 | 111 |
tags:
|
112 | 112 |
- aarch64
|
113 | 113 |
<<: *tests
|
... | ... | @@ -120,7 +120,7 @@ overnight-fedora-28-aarch64: |
120 | 120 |
tests-unix:
|
121 | 121 |
# Use fedora here, to a) run a test on fedora and b) ensure that we
|
122 | 122 |
# can get rid of ostree - this is not possible with debian-8
|
123 |
- image: buildstream/testsuite-fedora:27-master-123-7ce6581b
|
|
123 |
+ image: buildstream/testsuite-fedora:27-06bab030-b848172c
|
|
124 | 124 |
<<: *tests
|
125 | 125 |
variables:
|
126 | 126 |
BST_FORCE_BACKEND: "unix"
|
... | ... | @@ -140,7 +140,7 @@ tests-unix: |
140 | 140 |
|
141 | 141 |
tests-fedora-missing-deps:
|
142 | 142 |
# Ensure that tests behave nicely while missing bwrap and ostree
|
143 |
- image: buildstream/testsuite-fedora:28-master-123-7ce6581b
|
|
143 |
+ image: buildstream/testsuite-fedora:28-06bab030-b848172c
|
|
144 | 144 |
<<: *tests
|
145 | 145 |
|
146 | 146 |
script:
|
... | ... | @@ -34,7 +34,7 @@ from ._exceptions import BstError, ErrorDomain |
34 | 34 |
|
35 | 35 |
# pylint: disable=wrong-import-position,wrong-import-order
|
36 | 36 |
gi.require_version('OSTree', '1.0')
|
37 |
-from gi.repository import GLib, Gio, OSTree # nopep8
|
|
37 |
+from gi.repository import GLib, Gio, OSTree # noqa
|
|
38 | 38 |
|
39 | 39 |
|
40 | 40 |
# For users of this file, they must expect (except) it.
|
... | ... | @@ -38,7 +38,7 @@ def terminator_handler(signal_, frame): |
38 | 38 |
terminator_ = terminator_stack.pop()
|
39 | 39 |
try:
|
40 | 40 |
terminator_()
|
41 |
- except: # pylint: disable=bare-except
|
|
41 |
+ except: # noqa pylint: disable=bare-except
|
|
42 | 42 |
# Ensure we print something if there's an exception raised when
|
43 | 43 |
# processing the handlers. Note that the default exception
|
44 | 44 |
# handler won't be called because we os._exit next, so we must
|
... | ... | @@ -1568,7 +1568,7 @@ class Element(Plugin): |
1568 | 1568 |
utils._force_rmtree(rootdir)
|
1569 | 1569 |
|
1570 | 1570 |
with _signals.terminator(cleanup_rootdir), \
|
1571 |
- self.__sandbox(rootdir, output_file, output_file, self.__sandbox_config) as sandbox: # nopep8
|
|
1571 |
+ self.__sandbox(rootdir, output_file, output_file, self.__sandbox_config) as sandbox: # noqa
|
|
1572 | 1572 |
|
1573 | 1573 |
# By default, the dynamic public data is the same as the static public data.
|
1574 | 1574 |
# The plugin's assemble() method may modify this, though.
|
1 | 1 |
coverage == 4.4.0
|
2 |
-pep8
|
|
3 | 2 |
pylint
|
4 | 3 |
pytest >= 3.9
|
4 |
+pytest-codestyle >= 1.4.0
|
|
5 | 5 |
pytest-cov >= 2.5.0
|
6 | 6 |
pytest-datafiles >= 2.0
|
7 | 7 |
pytest-env
|
8 |
-pytest-pep8
|
|
9 | 8 |
pytest-pylint
|
10 | 9 |
pytest-xdist
|
11 | 10 |
pytest-timeout
|
... | ... | @@ -6,10 +6,10 @@ |
6 | 6 |
# we dont use the standard `sphinx-build` and `sphinx-apidoc` entry points.
|
7 | 7 |
#
|
8 | 8 |
# The following technique works as long as sphinx is installed for python3,
|
9 |
-# regardless of the entry point which might be in /usr/bin or PATH, but
|
|
10 |
-# will stop working in sphinx >= 2.0. Hopefully by then, the mentioned
|
|
11 |
-# bug will be fixed and we can use a standard python3 specific script to
|
|
12 |
-# invoke sphnix.
|
|
9 |
+# regardless of the entry point which might be in /usr/bin or PATH.
|
|
10 |
+#
|
|
11 |
+# Since Sphinx 2.0 is planned to be Python 3-only, this workaround should not
|
|
12 |
+# be needed once Spinx 2.0 is released, and we upgrade to it
|
|
13 | 13 |
#
|
14 | 14 |
SPHINXOPTS =
|
15 | 15 |
SPHINXBUILD = python3 -m sphinx
|
... | ... | @@ -526,3 +526,27 @@ read-only variables are also dynamically declared by BuildStream: |
526 | 526 |
build, support for this is conditional on the element type
|
527 | 527 |
and the build system used (any element using 'make' can
|
528 | 528 |
implement this).
|
529 |
+ |
|
530 |
+ |
|
531 |
+Naming elements
|
|
532 |
+---------------
|
|
533 |
+When naming the element files, use the following rules:
|
|
534 |
+ |
|
535 |
+* The name of the file must have ``.bst`` extension.
|
|
536 |
+ |
|
537 |
+* All characters in the name must be printable 7-bit ASCII characters.
|
|
538 |
+ |
|
539 |
+* Following characters are reserved and must not be part of the name:
|
|
540 |
+ |
|
541 |
+ - ``<`` (less than)
|
|
542 |
+ - ``>`` (greater than)
|
|
543 |
+ - ``:`` (colon)
|
|
544 |
+ - ``"`` (double quote)
|
|
545 |
+ - ``/`` (forward slash)
|
|
546 |
+ - ``\`` (backslash)
|
|
547 |
+ - ``|`` (vertical bar)
|
|
548 |
+ - ``?`` (question mark)
|
|
549 |
+ - ``*`` (asterisk)
|
|
550 |
+ |
|
551 |
+BuildStream will attempt to raise warnings when any of these rules are violated
|
|
552 |
+but that may not always be possible.
|
... | ... | @@ -11,20 +11,11 @@ parentdir_prefix = BuildStream- |
11 | 11 |
test=pytest
|
12 | 12 |
|
13 | 13 |
[tool:pytest]
|
14 |
-addopts = --verbose --basetemp ./tmp --pep8 --pylint --pylint-rcfile=.pylintrc --cov=buildstream --cov-config .coveragerc --durations=20
|
|
14 |
+addopts = --verbose --basetemp ./tmp --codestyle --pylint --pylint-rcfile=.pylintrc --cov=buildstream --cov-config .coveragerc --durations=20
|
|
15 | 15 |
norecursedirs = tests/integration/project integration-cache tmp __pycache__ .eggs
|
16 | 16 |
python_files = tests/*/*.py
|
17 |
-pep8maxlinelength = 119
|
|
18 |
-pep8ignore =
|
|
19 |
- * E129
|
|
20 |
- * E125
|
|
21 |
- doc/source/conf.py ALL
|
|
22 |
- tmp/* ALL
|
|
23 |
- */lib/python3* ALL
|
|
24 |
- */bin/* ALL
|
|
25 |
- buildstream/_fuse/fuse.py ALL
|
|
26 |
- .eggs/* ALL
|
|
27 |
- *_pb2.py ALL
|
|
28 |
- *_pb2_grpc.py ALL
|
|
17 |
+codestyle_max_line_length = 119
|
|
18 |
+codestyle_ignore = E129 E125 W504 W605
|
|
19 |
+codestyle_exclude = doc/source/conf.py buildstream/_fuse/fuse.py buildstream/_protos/**/*py
|
|
29 | 20 |
env =
|
30 | 21 |
D:BST_TEST_SUITE=True
|
... | ... | @@ -3,6 +3,7 @@ import tarfile |
3 | 3 |
import hashlib
|
4 | 4 |
import pytest
|
5 | 5 |
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
|
6 |
+from tests.testutils.site import IS_WINDOWS
|
|
6 | 7 |
|
7 | 8 |
from buildstream import _yaml
|
8 | 9 |
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
... | ... | @@ -85,6 +86,41 @@ def test_build_invalid_suffix_dep(datafiles, cli, strict, hardlinks): |
85 | 86 |
result.assert_main_error(ErrorDomain.LOAD, "bad-element-suffix")
|
86 | 87 |
|
87 | 88 |
|
89 |
+@pytest.mark.skipif(IS_WINDOWS, reason='Not available on Windows')
|
|
90 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
91 |
+def test_build_invalid_filename_chars(datafiles, cli):
|
|
92 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
93 |
+ element_name = 'invalid-chars|<>-in-name.bst'
|
|
94 |
+ |
|
95 |
+ # The name of this file contains characters that are not allowed by
|
|
96 |
+ # BuildStream, using it should raise a warning.
|
|
97 |
+ element = {
|
|
98 |
+ 'kind': 'stack',
|
|
99 |
+ }
|
|
100 |
+ _yaml.dump(element, os.path.join(project, 'elements', element_name))
|
|
101 |
+ |
|
102 |
+ result = cli.run(project=project, args=strict_args(['build', element_name], 'non-strict'))
|
|
103 |
+ result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name")
|
|
104 |
+ |
|
105 |
+ |
|
106 |
+@pytest.mark.skipif(IS_WINDOWS, reason='Not available on Windows')
|
|
107 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
108 |
+def test_build_invalid_filename_chars_dep(datafiles, cli):
|
|
109 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
110 |
+ element_name = 'invalid-chars|<>-in-name.bst'
|
|
111 |
+ |
|
112 |
+ # The name of this file contains characters that are not allowed by
|
|
113 |
+ # BuildStream, and is listed as a dependency of 'invalid-chars-in-dep.bst'.
|
|
114 |
+ # This should also raise a warning.
|
|
115 |
+ element = {
|
|
116 |
+ 'kind': 'stack',
|
|
117 |
+ }
|
|
118 |
+ _yaml.dump(element, os.path.join(project, 'elements', element_name))
|
|
119 |
+ |
|
120 |
+ result = cli.run(project=project, args=strict_args(['build', 'invalid-chars-in-dep.bst'], 'non-strict'))
|
|
121 |
+ result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name")
|
|
122 |
+ |
|
123 |
+ |
|
88 | 124 |
@pytest.mark.datafiles(DATA_DIR)
|
89 | 125 |
@pytest.mark.parametrize("deps", [("run"), ("none"), ("build")])
|
90 | 126 |
def test_build_checkout_deps(datafiles, cli, deps):
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ This element itself has a valid name, but depends on elements that have
|
|
5 |
+ invalid names. This should also result in a warning.
|
|
6 |
+ |
|
7 |
+depends:
|
|
8 |
+- invalid-chars|<>-in-name.bst
|
... | ... | @@ -5,3 +5,4 @@ element-path: elements |
5 | 5 |
|
6 | 6 |
fatal-warnings:
|
7 | 7 |
- bad-element-suffix
|
8 |
+- bad-characters-in-name
|
... | ... | @@ -29,7 +29,7 @@ class RequestHandler(SimpleHTTPRequestHandler): |
29 | 29 |
expected_password, directory = self.server.users[user]
|
30 | 30 |
if password == expected_password:
|
31 | 31 |
return directory
|
32 |
- except:
|
|
32 |
+ except: # noqa
|
|
33 | 33 |
raise Unauthorized('unauthorized')
|
34 | 34 |
return None
|
35 | 35 |
|
... | ... | @@ -52,5 +52,6 @@ except ImportError: |
52 | 52 |
HAVE_ARPY = False
|
53 | 53 |
|
54 | 54 |
IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux')
|
55 |
+IS_WINDOWS = (os.name == 'nt')
|
|
55 | 56 |
|
56 | 57 |
MACHINE_ARCH = Platform.get_host_arch()
|