Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
csentry
Commits
7c89b12f
Commit
7c89b12f
authored
5 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Fix linting warnings
parent
4dc5f41d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/commands.py
+1
-1
1 addition, 1 deletion
app/commands.py
app/models.py
+4
-4
4 additions, 4 deletions
app/models.py
app/utils.py
+1
-0
1 addition, 0 deletions
app/utils.py
app/validators.py
+5
-5
5 additions, 5 deletions
app/validators.py
with
11 additions
and
10 deletions
app/commands.py
+
1
−
1
View file @
7c89b12f
...
...
@@ -80,7 +80,7 @@ def register_cli(app):
db
.
session
.
add
(
instance
)
try
:
db
.
session
.
commit
()
except
sa
.
exc
.
IntegrityError
as
e
:
except
sa
.
exc
.
IntegrityError
:
db
.
session
.
rollback
()
app
.
logger
.
debug
(
f
"
{
instance
}
already exists
"
)
...
...
This diff is collapsed.
Click to expand it.
app/models.py
+
4
−
4
View file @
7c89b12f
...
...
@@ -932,7 +932,7 @@ class Network(CreatedMixin, db.Model):
if
string
is
None
:
return
None
if
VLAN_NAME_RE
.
fullmatch
(
string
)
is
None
:
raise
ValidationError
(
"
Vlan name shall match [A-Za-z0-9\-]{3,25}
"
)
raise
ValidationError
(
r
"
Vlan name shall match [A-Za-z0-9\-]{3,25}
"
)
return
string
def
to_dict
(
self
,
recursive
=
False
):
...
...
@@ -1257,7 +1257,7 @@ class Host(CreatedMixin, SearchableMixin, db.Model):
# Force the string to lowercase
lower_string
=
string
.
lower
()
if
HOST_NAME_RE
.
fullmatch
(
lower_string
)
is
None
:
raise
ValidationError
(
"
Host name shall match [a-z0-9\-]{2,20}
"
)
raise
ValidationError
(
r
"
Host name shall match [a-z0-9\-]{2,20}
"
)
existing_cname
=
Cname
.
query
.
filter_by
(
name
=
lower_string
).
first
()
if
existing_cname
:
raise
ValidationError
(
f
"
Host name matches an existing cname
"
)
...
...
@@ -1360,7 +1360,7 @@ class Interface(CreatedMixin, db.Model):
# Force the string to lowercase
lower_string
=
string
.
lower
()
if
HOST_NAME_RE
.
fullmatch
(
lower_string
)
is
None
:
raise
ValidationError
(
"
Interface name shall match [a-z0-9\-]{2,20}
"
)
raise
ValidationError
(
r
"
Interface name shall match [a-z0-9\-]{2,20}
"
)
if
self
.
host
and
not
lower_string
.
startswith
(
self
.
host
.
name
):
raise
ValidationError
(
f
"
Interface name shall start with the host name
'
{
self
.
host
}
'"
...
...
@@ -1494,7 +1494,7 @@ class Cname(CreatedMixin, db.Model):
# Force the string to lowercase
lower_string
=
string
.
lower
()
if
HOST_NAME_RE
.
fullmatch
(
lower_string
)
is
None
:
raise
ValidationError
(
"
cname shall match [a-z0-9\-]{2,20}
"
)
raise
ValidationError
(
r
"
cname shall match [a-z0-9\-]{2,20}
"
)
existing_interface
=
Interface
.
query
.
filter_by
(
name
=
lower_string
).
first
()
if
existing_interface
:
raise
ValidationError
(
f
"
cname matches an existing interface
"
)
...
...
This diff is collapsed.
Click to expand it.
app/utils.py
+
1
−
0
View file @
7c89b12f
...
...
@@ -155,6 +155,7 @@ def get_query(query, **kwargs):
try
:
query
=
query
.
filter_by
(
**
kwargs
)
except
(
sa
.
exc
.
InvalidRequestError
,
AttributeError
)
as
e
:
current_app
.
logger
.
warning
(
f
"
Invalid query arguments:
{
e
}
"
)
raise
CSEntryError
(
"
Invalid query arguments
"
,
status_code
=
422
)
return
query
...
...
This diff is collapsed.
Click to expand it.
app/validators.py
+
5
−
5
View file @
7c89b12f
...
...
@@ -14,11 +14,11 @@ import re
import
sqlalchemy
as
sa
from
wtforms
import
ValidationError
,
SelectField
ICS_ID_RE
=
re
.
compile
(
"
[A-Z]{3}[0-9]{3}
"
)
HOST_NAME_RE
=
re
.
compile
(
"
^[a-z0-9\-]{2,20}$
"
)
VLAN_NAME_RE
=
re
.
compile
(
"
^[A-Za-z0-9\-]{3,25}$
"
)
MAC_ADDRESS_RE
=
re
.
compile
(
"
^(?:[0-9a-fA-F]{2}[:-]?){5}[0-9a-fA-F]{2}$
"
)
DEVICE_TYPE_RE
=
re
.
compile
(
"
^[A-Za-z0-9]{3,25}$
"
)
ICS_ID_RE
=
re
.
compile
(
r
"
[A-Z]{3}[0-9]{3}
"
)
HOST_NAME_RE
=
re
.
compile
(
r
"
^[a-z0-9\-]{2,20}$
"
)
VLAN_NAME_RE
=
re
.
compile
(
r
"
^[A-Za-z0-9\-]{3,25}$
"
)
MAC_ADDRESS_RE
=
re
.
compile
(
r
"
^(?:[0-9a-fA-F]{2}[:-]?){5}[0-9a-fA-F]{2}$
"
)
DEVICE_TYPE_RE
=
re
.
compile
(
r
"
^[A-Za-z0-9]{3,25}$
"
)
class
NoValidateSelectField
(
SelectField
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment