Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Oct 7, 2019
2 parents 1023f0d + b3df9c0 commit 98a868c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
stage: installation tests
install: skip
script: ./tests/docker/build
env: DISTRO=centos-latest PYVER=2
env: DISTRO=centos-latest PYVER=3

# Ubuntu, latest
- <<: *installation-stage
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Change log

.. note:: **Upgrade notes**: after upgrading, run the ``arouteserver setup-templates`` command to sync the local templates with those distributed with the new version. More details on the `Upgrading <https://arouteserver.readthedocs.io/en/latest/INSTALLATION.html#upgrading>`__ section of the documentation.

v0.22.2
-------

- Fix: prevent environment variables with unknown escapes (like `\u`) from interrupting the execution.

Related: `issue #50 on GitHub <https://github.com/pierky/arouteserver/issues/50>`_.

v0.22.1
-------

Expand Down
3 changes: 1 addition & 2 deletions pierky/arouteserver/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def expand_include(lines):

def expand_env_vars(doc):
res = doc
for v in os.environ:
res = re.sub("\$\{" + v + "\}", os.environ[v], res)
res = os.path.expandvars(res)
res = re.sub("\$\{[A-Za-z0-9_]+\}", "", res)
return res

Expand Down
2 changes: 1 addition & 1 deletion pierky/arouteserver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__version__ = "0.22.1" # pragma: no cover
__version__ = "0.22.2-alpha3" # pragma: no cover
COPYRIGHT_YEAR = 2019 # pragma: no cover
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ include(`base.m4')

RUN yum -y update && yum -y install epel-release
RUN yum -y update && yum -y install \
python-pip \
python-devel \
python3-pip \
python3-devel \
gcc

ENV python=python3
ENV pip=pip3

include(`install.m4')
17 changes: 17 additions & 0 deletions tests/static/test_cfg_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,3 +1411,20 @@ def test_env_vars_corrupted(self):
" router_id: ${ROUTER_ID\n"
)
self._contains_err("Invalid IPv4 address: ${ROUTER_ID")

@mock.patch.dict(os.environ, {"ROUTER_ID": "192.0.2.1", "BAD_ESCAPE": r"\u"})
def test_env_vars_bad_escape(self):
"""{}: environment variables: ok (bad escape)"""

self.cfg._load_from_yaml(
"cfg:\n"
" rs_as: 999\n"
" router_id: ${ROUTER_ID}\n"
" filtering:\n"
" global_black_list_pref: ${GLOBAL_BLACK_LIST_PREF}\n"
)
self.cfg.parse()
self._contains_err()

self.assertEqual(self.cfg["router_id"], "192.0.2.1")
self.assertEqual(self.cfg["filtering"]["global_black_list_pref"], None)

0 comments on commit 98a868c

Please sign in to comment.