File tree Expand file tree Collapse file tree
netjsonconfig/backends/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434
3535 - name : Install python dependencies
3636 run : |
37- pip install -U " pip==20.2.4" wheel setuptools
37+ pip install -U pip wheel setuptools
3838 pip install -U -r requirements-test.txt
3939
4040 - name : Install netjsonconfig
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ netjsonconfig
77.. image :: https://coveralls.io/repos/openwisp/netjsonconfig/badge.svg
88 :target: https://coveralls.io/r/openwisp/netjsonconfig
99
10- .. image :: https://requires. io/github/openwisp/netjsonconfig/requirements.svg?branch=master
11- :target: https://requires .io/github/openwisp/netjsonconfig/requirements/?branch=master
12- :alt: Requirements Status
10+ .. image :: https://img.shields. io/librariesio/release/ github/openwisp/netjsonconfig
11+ :target: https://libraries .io/github/openwisp/netjsonconfig#repository_dependencies
12+ :alt: Dependency monitoring
1313
1414.. image :: https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square
1515 :target: https://gitter.im/openwisp/general
Original file line number Diff line number Diff line change @@ -3,20 +3,20 @@ netjsonconfig
33=============
44
55.. image :: https://travis-ci.org/openwisp/netjsonconfig.svg
6- :target: https://travis-ci.org/openwisp/netjsonconfig
6+ :target: https://travis-ci.org/openwisp/netjsonconfig
77
88.. image :: https://coveralls.io/repos/openwisp/netjsonconfig/badge.svg
9- :target: https://coveralls.io/r/openwisp/netjsonconfig
9+ :target: https://coveralls.io/r/openwisp/netjsonconfig
1010
11- .. image :: https://requires. io/github/openwisp/netjsonconfig/requirements.svg?branch=master
12- :target: https://requires .io/github/openwisp/netjsonconfig/requirements/?branch=master
13- :alt: Requirements Status
11+ .. image :: https://img.shields. io/librariesio/release/ github/openwisp/netjsonconfig
12+ :target: https://libraries .io/github/openwisp/netjsonconfig#repository_dependencies
13+ :alt: Dependency monitoring
1414
1515.. image :: https://badge.fury.io/py/netjsonconfig.svg
16- :target: http://badge.fury.io/py/netjsonconfig
16+ :target: http://badge.fury.io/py/netjsonconfig
1717
1818.. image :: https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square
19- :target: https://gitter.im/openwisp/general
19+ :target: https://gitter.im/openwisp/general
2020
2121Netjsonconfig is part of the `OpenWISP project <http://openwrt.org >`_ and it's the official
2222configuration engine of `OpenWISP 2 <https://github.com/openwisp/ansible-openwisp2 >`_.
Original file line number Diff line number Diff line change 11import gzip
22import ipaddress
33import json
4+ import re
45import tarfile
56from collections import OrderedDict
67from copy import deepcopy
1314from ...schema import DEFAULT_FILE_MODE
1415from ...utils import evaluate_vars , merge_config
1516
17+ _host_name_re = re .compile (r"^[A-Za-z0-9][A-Za-z0-9\.\-]{1,255}$" )
18+
1619
1720class BaseBackend (object ):
1821 """
@@ -131,6 +134,24 @@ def _cidr_notation(value):
131134 assert False , str (e )
132135 return True
133136
137+ @draft4_format_checker .checks ('hostname' , JsonSchemaError )
138+ def _is_hostname (value ):
139+ """
140+ The hostname validation has been taken from jsonschema~=3.2.0
141+ (jsonschema._format.is_host_name). The newer versions of
142+ jsonschema enforces FQDN validation which is not always
143+ required in OpenWISP. E.g. setting up hostname of a device.
144+ """
145+ if not isinstance (value , str ):
146+ return True
147+ if not _host_name_re .match (value ):
148+ return False
149+ components = value .split ("." )
150+ for component in components :
151+ if len (component ) > 63 :
152+ return False
153+ return True
154+
134155 def validate (self ):
135156 try :
136157 Draft4Validator (self .schema , format_checker = draft4_format_checker ).validate (
Original file line number Diff line number Diff line change 11jinja2 ~= 3.0.0
2- jsonschema >= 3.0 ,< 3.3
3- six
2+ jsonschema ~= 4.4.0
You can’t perform that action at this time.
0 commit comments