Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
cubicweb
cubes
api
Commits
b974ab06d0c1
Commit
b974ab06d0c1
authored
2 years ago
by
Arnaud Vergnet
Browse files
Options
Downloads
Patches
Plain Diff
fix: improve config path checks
parent
52aa18a21e84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!17
fix: improve config path checks
Pipeline
#135213
passed
2 years ago
Stage: lint
Stage: tests
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cubicweb_api/util.py
+10
-3
10 additions, 3 deletions
cubicweb_api/util.py
with
10 additions
and
3 deletions
cubicweb_api/util.py
+
10
−
3
View file @
b974ab06
...
...
@@ -39,9 +39,9 @@
path_prefix
:
str
=
(
repo
.
get_option_value
(
"
api-path-prefix
"
)
or
API_PATH_DEFAULT_PREFIX
)
match
=
re
.
match
(
"
^[a-zA-Z0-9-_@.&+!*(),/]{1,
30
}$
"
,
path_prefix
)
match
=
re
.
match
(
"
^
/
[a-zA-Z0-9-_@.&+!*(),/]{1,
29
}$
"
,
path_prefix
)
if
match
:
return
path_prefix
.
rstrip
(
"
/
"
)
else
:
if
len
(
path_prefix
)
>
30
:
raise
ConfigurationError
(
...
...
@@ -43,9 +43,16 @@
if
match
:
return
path_prefix
.
rstrip
(
"
/
"
)
else
:
if
len
(
path_prefix
)
>
30
:
raise
ConfigurationError
(
"
api-path-prefix is too long. Max size allowed is 30 characters.
"
f
"
api-path-prefix
'
{
path_prefix
}
'
is too long.
"
f
"
Max size allowed is 30 characters.
"
f
"
Current size is
{
len
(
path_prefix
)
}
.
"
)
if
not
path_prefix
.
startswith
(
"
/
"
):
raise
ConfigurationError
(
f
"
api-path-prefix
'
{
path_prefix
}
'
does not start with
'
/
'
.
"
"
Prefix should start with
'
/
'
to be validated by openapi
"
)
raise
ConfigurationError
(
...
...
@@ -49,6 +56,6 @@
)
raise
ConfigurationError
(
"
api-path-prefix contains invalid characters.
"
f
"
api-path-prefix
'
{
path_prefix
}
'
contains invalid characters.
"
"
Allowed characters are: a-zA-Z0-9-_@.&+!*(),/
"
)
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