Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
Seblu
installsystems
Commits
401c15a5
Commit
401c15a5
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
enforce image name and version checking
parent
64d16b0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
installsystems/image.py
+11
-5
11 additions, 5 deletions
installsystems/image.py
with
11 additions
and
5 deletions
installsystems/image.py
+
11
−
5
View file @
401c15a5
...
...
@@ -35,16 +35,19 @@ class Image(object):
@staticmethod
def
check_image_name
(
buf
):
'''
Check if @
name
is a valid image name
Check if @
buf
is a valid image name
'''
return
re
.
match
(
"
[-_\w]+
"
,
buf
)
is
not
None
if
re
.
match
(
"
^[-_\w]+$
"
,
buf
)
is
None
:
raise
Exception
(
"
Invalid image name %s
"
%
buf
)
@staticmethod
def
check_image_version
(
buf
):
'''
Check if @
name
is a valid image version
Check if @
buf
is a valid image version
'''
return
re
.
match
(
"
\d+
"
,
buf
)
is
not
None
if
re
.
match
(
"
^\d+$
"
,
buf
)
is
None
:
raise
Exception
(
"
Invalid image version %s
"
%
buf
)
class
SourceImage
(
Image
):
'''
...
...
@@ -336,6 +339,8 @@ class SourceImage(Image):
cp
.
read
(
descpath
)
for
n
in
(
"
name
"
,
"
version
"
,
"
description
"
,
"
author
"
):
d
[
n
]
=
cp
.
get
(
"
image
"
,
n
)
self
.
check_image_name
(
d
[
"
name
"
])
self
.
check_image_version
(
d
[
"
version
"
])
except
Exception
as
e
:
raise
Exception
(
"
Bad description: %s
"
%
e
)
return
d
...
...
@@ -419,9 +424,10 @@ class PackageImage(Image):
# check description
try
:
desc
=
json
.
loads
(
img_desc
)
self
.
check_image_name
(
desc
[
"
name
"
])
self
.
check_image_version
(
desc
[
"
version
"
])
except
Exception
as
e
:
raise
Exception
(
"
Invalid description: %s
"
%
e
)
# FIXME: we should check valid information here
return
desc
def
show
(
self
,
verbose
=
False
):
...
...
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