Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
de0602ad
Commit
de0602ad
authored
Aug 31, 2021
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow dots in Helm channel, but forbid repeated dots
Changelog: changed
parent
fe980078
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
8 deletions
+31
-8
lib/api/helm_packages.rb
lib/api/helm_packages.rb
+4
-3
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+1
-1
spec/lib/gitlab/regex_spec.rb
spec/lib/gitlab/regex_spec.rb
+11
-1
spec/requests/api/helm_packages_spec.rb
spec/requests/api/helm_packages_spec.rb
+15
-3
No files found.
lib/api/helm_packages.rb
View file @
de0602ad
...
@@ -11,7 +11,8 @@ module API
...
@@ -11,7 +11,8 @@ module API
feature_category
:package_registry
feature_category
:package_registry
PACKAGE_FILENAME
=
'package.tgz'
PACKAGE_FILENAME
=
'package.tgz'
FILE_NAME_REQUIREMENTS
=
{
HELM_REQUIREMENTS
=
{
channel:
API
::
NO_SLASH_URL_PART_REGEX
,
file_name:
API
::
NO_SLASH_URL_PART_REGEX
file_name:
API
::
NO_SLASH_URL_PART_REGEX
}.
freeze
}.
freeze
...
@@ -33,7 +34,7 @@ module API
...
@@ -33,7 +34,7 @@ module API
requires
:id
,
type:
String
,
desc:
'The ID or full path of a project'
requires
:id
,
type:
String
,
desc:
'The ID or full path of a project'
end
end
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
namespace
':id/packages/helm'
do
namespace
':id/packages/helm'
,
requirements:
HELM_REQUIREMENTS
do
desc
'Download a chart index'
do
desc
'Download a chart index'
do
detail
'This feature was introduced in GitLab 14.0'
detail
'This feature was introduced in GitLab 14.0'
end
end
...
@@ -58,7 +59,7 @@ module API
...
@@ -58,7 +59,7 @@ module API
requires
:channel
,
type:
String
,
desc:
'Helm channel'
,
regexp:
Gitlab
::
Regex
.
helm_channel_regex
requires
:channel
,
type:
String
,
desc:
'Helm channel'
,
regexp:
Gitlab
::
Regex
.
helm_channel_regex
requires
:file_name
,
type:
String
,
desc:
'Helm package file name'
requires
:file_name
,
type:
String
,
desc:
'Helm package file name'
end
end
get
":channel/charts/:file_name.tgz"
,
requirements:
FILE_NAME_REQUIREMENTS
do
get
":channel/charts/:file_name.tgz"
do
authorize_read_package!
(
authorized_user_project
)
authorize_read_package!
(
authorized_user_project
)
package_file
=
Packages
::
Helm
::
PackageFilesFinder
.
new
(
authorized_user_project
,
params
[
:channel
],
file_name:
"
#{
params
[
:file_name
]
}
.tgz"
).
most_recent!
package_file
=
Packages
::
Helm
::
PackageFilesFinder
.
new
(
authorized_user_project
,
params
[
:channel
],
file_name:
"
#{
params
[
:file_name
]
}
.tgz"
).
most_recent!
...
...
lib/gitlab/regex.rb
View file @
de0602ad
...
@@ -131,7 +131,7 @@ module Gitlab
...
@@ -131,7 +131,7 @@ module Gitlab
end
end
def
helm_channel_regex
def
helm_channel_regex
@helm_channel_regex
||=
%r{
\A
[-
\.\_
a-zA-Z0-9]+
\z
}
.
freeze
@helm_channel_regex
||=
%r{
\A
([a-zA-Z0-9](
\.
|-|_)?){1,63}(?<!
\.
|-|_)
\z
}
.
freeze
end
end
def
helm_package_regex
def
helm_package_regex
...
...
spec/lib/gitlab/regex_spec.rb
View file @
de0602ad
...
@@ -653,13 +653,23 @@ RSpec.describe Gitlab::Regex do
...
@@ -653,13 +653,23 @@ RSpec.describe Gitlab::Regex do
it
{
is_expected
.
to
match
(
'release'
)
}
it
{
is_expected
.
to
match
(
'release'
)
}
it
{
is_expected
.
to
match
(
'my-repo'
)
}
it
{
is_expected
.
to
match
(
'my-repo'
)
}
it
{
is_expected
.
to
match
(
'my-repo42'
)
}
it
{
is_expected
.
to
match
(
'My-Re_po'
)
}
it
{
is_expected
.
to
match
(
'my_repo42'
)
}
it
{
is_expected
.
to
match
(
'1.2.3'
)
}
it
{
is_expected
.
to
match
(
'v1.2.3-beta-12'
)
}
# Do not allow empty
# Do not allow empty
it
{
is_expected
.
not_to
match
(
''
)
}
it
{
is_expected
.
not_to
match
(
''
)
}
# Do not allow Unicode
# Do not allow Unicode
it
{
is_expected
.
not_to
match
(
'hé'
)
}
it
{
is_expected
.
not_to
match
(
'hé'
)
}
it
{
is_expected
.
not_to
match
(
'.1.23'
)
}
it
{
is_expected
.
not_to
match
(
'1..23'
)
}
it
{
is_expected
.
not_to
match
(
'1.2.3.'
)
}
it
{
is_expected
.
not_to
match
(
'1..2.3.'
)
}
it
{
is_expected
.
not_to
match
(
'1/../2.3.'
)
}
it
{
is_expected
.
not_to
match
(
'1/..%2F2.3.'
)
}
end
end
describe
'.helm_package_regex'
do
describe
'.helm_package_regex'
do
...
...
spec/requests/api/helm_packages_spec.rb
View file @
de0602ad
...
@@ -18,11 +18,11 @@ RSpec.describe API::HelmPackages do
...
@@ -18,11 +18,11 @@ RSpec.describe API::HelmPackages do
let_it_be
(
:other_package
)
{
create
(
:npm_package
,
project:
project
)
}
let_it_be
(
:other_package
)
{
create
(
:npm_package
,
project:
project
)
}
describe
'GET /api/v4/projects/:id/packages/helm/:channel/index.yaml'
do
describe
'GET /api/v4/projects/:id/packages/helm/:channel/index.yaml'
do
let
(
:url
)
{
"/projects/
#{
project_id
}
/packages/helm/stable/index.yaml"
}
let
(
:project_id
)
{
project
.
id
}
let
(
:channel
)
{
'stable'
}
let
(
:url
)
{
"/projects/
#{
project_id
}
/packages/helm/
#{
channel
}
/index.yaml"
}
context
'with a project id'
do
context
'with a project id'
do
let
(
:project_id
)
{
project
.
id
}
it_behaves_like
'handling helm chart index requests'
it_behaves_like
'handling helm chart index requests'
end
end
...
@@ -31,6 +31,18 @@ RSpec.describe API::HelmPackages do
...
@@ -31,6 +31,18 @@ RSpec.describe API::HelmPackages do
it_behaves_like
'handling helm chart index requests'
it_behaves_like
'handling helm chart index requests'
end
end
context
'with dot in channel'
do
let
(
:channel
)
{
'with.dot'
}
subject
{
get
api
(
url
)
}
before
do
project
.
update!
(
visibility:
'public'
)
end
it_behaves_like
'returning response status'
,
:success
end
end
end
describe
'GET /api/v4/projects/:id/packages/helm/:channel/charts/:file_name.tgz'
do
describe
'GET /api/v4/projects/:id/packages/helm/:channel/charts/:file_name.tgz'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment