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
c1bf4cb1
Commit
c1bf4cb1
authored
Jun 05, 2019
by
Tetiana Chupryna
Committed by
Sean McGivern
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move DependenciesController to Security namespace
parent
9b59c91f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
45 deletions
+54
-45
ee/app/controllers/projects/dependencies_controller.rb
ee/app/controllers/projects/dependencies_controller.rb
+0
-43
ee/app/controllers/projects/security/dependencies_controller.rb
.../controllers/projects/security/dependencies_controller.rb
+45
-0
ee/changelogs/unreleased/11759-move-dependencies-controller.yml
...ngelogs/unreleased/11759-move-dependencies-controller.yml
+5
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+3
-1
ee/spec/controllers/projects/security/dependencies_controller_spec.rb
...rollers/projects/security/dependencies_controller_spec.rb
+1
-1
No files found.
ee/app/controllers/projects/dependencies_controller.rb
deleted
100644 → 0
View file @
9b59c91f
# frozen_string_literal: true
module
Projects
class
DependenciesController
<
Projects
::
ApplicationController
SORT_BY_PERMITTED_VALUES
=
%w(name type)
.
freeze
SORT_PERMITTED_VALUES
=
%w(asc desc)
.
freeze
before_action
:ensure_bill_of_materials_feature_flag_enabled
def
index
respond_to
do
|
format
|
format
.
json
do
render
json:
paginated_dependecies
end
end
end
private
def
ensure_bill_of_materials_feature_flag_enabled
render_404
unless
Feature
.
enabled?
(
:bill_of_materials
,
default_enabled:
false
)
end
def
found_dependencies
::
Security
::
DependenciesFinder
.
new
(
project:
@project
,
params:
query_params
).
execute
end
def
query_params
params
.
permit
(
:sort
,
:sort_by
).
delete_if
do
|
key
,
value
|
key
==
:sort_by
&&
!
value
.
in?
(
::
Security
::
DependenciesFinder
::
SORT_BY_VALUES
)
||
key
==
:sort
&&
!
value
.
in?
(
::
Security
::
DependenciesFinder
::
SORT_VALUES
)
end
end
# TODO: add proper implementation of edge cases handling
# format: { report: 'failed' }
# after we'll have more then just mock data
# reference: https://gitlab.com/gitlab-org/gitlab-ee/issues/10075#note_164915787
def
paginated_dependecies
Kaminari
.
paginate_array
(
found_dependencies
).
page
(
params
[
:page
])
end
end
end
ee/app/controllers/projects/security/dependencies_controller.rb
0 → 100644
View file @
c1bf4cb1
# frozen_string_literal: true
module
Projects
module
Security
class
DependenciesController
<
Projects
::
ApplicationController
SORT_BY_PERMITTED_VALUES
=
%w(name type)
.
freeze
SORT_PERMITTED_VALUES
=
%w(asc desc)
.
freeze
before_action
:ensure_bill_of_materials_feature_flag_enabled
def
index
respond_to
do
|
format
|
format
.
json
do
render
json:
paginated_dependecies
end
end
end
private
def
ensure_bill_of_materials_feature_flag_enabled
render_404
unless
Feature
.
enabled?
(
:bill_of_materials
,
default_enabled:
false
)
end
def
found_dependencies
::
Security
::
DependenciesFinder
.
new
(
project:
@project
,
params:
query_params
).
execute
end
def
query_params
params
.
permit
(
:sort
,
:sort_by
).
delete_if
do
|
key
,
value
|
key
==
:sort_by
&&
!
value
.
in?
(
::
Security
::
DependenciesFinder
::
SORT_BY_VALUES
)
||
key
==
:sort
&&
!
value
.
in?
(
::
Security
::
DependenciesFinder
::
SORT_VALUES
)
end
end
# TODO: add proper implementation of edge cases handling
# format: { report: 'failed' }
# after we'll have more then just mock data
# reference: https://gitlab.com/gitlab-org/gitlab-ee/issues/10075#note_164915787
def
paginated_dependecies
Kaminari
.
paginate_array
(
found_dependencies
).
page
(
params
[
:page
])
end
end
end
end
ee/changelogs/unreleased/11759-move-dependencies-controller.yml
0 → 100644
View file @
c1bf4cb1
---
title
:
Move dependencies API endpoint to "security" namespace
merge_request
:
13897
author
:
type
:
changed
ee/config/routes/project.rb
View file @
c1bf4cb1
...
...
@@ -83,7 +83,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources
:dependencies
,
only:
[
:index
]
namespace
:security
do
resources
:dependencies
,
only:
[
:index
]
end
end
end
end
...
...
ee/spec/controllers/projects/dependencies_controller_spec.rb
→
ee/spec/controllers/projects/
security/
dependencies_controller_spec.rb
View file @
c1bf4cb1
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Projects
::
DependenciesController
do
describe
Projects
::
Security
::
DependenciesController
do
describe
'GET index.json'
do
set
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
set
(
:user
)
{
create
(
:user
)
}
...
...
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