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
b9cbdeaf
Commit
b9cbdeaf
authored
Apr 30, 2021
by
Zamir Martins Filho
Committed by
Andrew Fontaine
Apr 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 404 on alert details
parent
876a10fd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
12 deletions
+14
-12
ee/app/controllers/projects/threat_monitoring_controller.rb
ee/app/controllers/projects/threat_monitoring_controller.rb
+3
-1
ee/app/helpers/policy_helper.rb
ee/app/helpers/policy_helper.rb
+2
-2
ee/app/views/projects/threat_monitoring/alert_details.html.haml
.../views/projects/threat_monitoring/alert_details.html.haml
+1
-1
ee/config/routes/project.rb
ee/config/routes/project.rb
+1
-1
ee/spec/controllers/projects/threat_monitoring_controller_spec.rb
...controllers/projects/threat_monitoring_controller_spec.rb
+5
-5
ee/spec/helpers/policy_helper_spec.rb
ee/spec/helpers/policy_helper_spec.rb
+2
-2
No files found.
ee/app/controllers/projects/threat_monitoring_controller.rb
View file @
b9cbdeaf
...
...
@@ -14,9 +14,11 @@ module Projects
feature_category
:web_firewall
# rubocop: disable CodeReuse/ActiveRecord
def
alert_details
@alert_i
d
=
project
.
alert_management_alerts
.
find
(
params
[
:id
]).
id
@alert_i
id
=
AlertManagement
::
AlertsFinder
.
new
(
current_user
,
project
,
params
.
merge
(
domain:
'threat_monitoring'
)).
execute
.
first!
.
i
id
end
# rubocop: enable CodeReuse/ActiveRecord
def
edit
@environment
=
project
.
environments
.
find
(
params
[
:environment_id
])
...
...
ee/app/helpers/policy_helper.rb
View file @
b9cbdeaf
...
...
@@ -14,9 +14,9 @@ module PolicyHelper
details
.
merge
(
edit_details
)
end
def
threat_monitoring_alert_details_data
(
project
,
alert_id
)
def
threat_monitoring_alert_details_data
(
project
,
alert_i
i
d
)
{
'alert-id'
=>
alert_id
,
'alert-id'
=>
alert_i
i
d
,
'project-path'
=>
project
.
full_path
,
'project-id'
=>
project
.
id
,
'project-issues-path'
=>
project_issues_path
(
project
),
...
...
ee/app/views/projects/threat_monitoring/alert_details.html.haml
View file @
b9cbdeaf
-
add_to_breadcrumbs
s_
(
'ThreatMonitoring|Threat Monitoring'
),
project_threat_monitoring_path
(
@project
)
-
page_title
s_
(
'ThreatMonitoring|Alert Details'
)
#js-alert_details
{
data:
threat_monitoring_alert_details_data
(
@project
,
@alert_id
)
}
#js-alert_details
{
data:
threat_monitoring_alert_details_data
(
@project
,
@alert_i
i
d
)
}
ee/config/routes/project.rb
View file @
b9cbdeaf
...
...
@@ -40,7 +40,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:subscriptions
,
only:
[
:create
,
:destroy
]
resource
:threat_monitoring
,
only:
[
:show
],
controller: :threat_monitoring
do
get
'/alerts/:i
d'
,
action:
'alert_details'
,
constraints:
{
id:
/\d+/
},
as: :threat_monitoring_alert
get
'/alerts/:i
id'
,
action:
'alert_details'
,
constraints:
{
i
id:
/\d+/
},
as: :threat_monitoring_alert
resources
:policies
,
only:
[
:new
,
:edit
],
controller: :threat_monitoring
end
...
...
ee/spec/controllers/projects/threat_monitoring_controller_spec.rb
View file @
b9cbdeaf
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
ThreatMonitoringController
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
:
cilium
,
project:
project
)
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
:
threat_monitoring
,
project:
project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
describe
'GET show'
do
...
...
@@ -239,9 +239,9 @@ RSpec.describe Projects::ThreatMonitoringController do
end
describe
'GET threat monitoring alerts'
do
let
(
:alert_i
d
)
{
alert
.
id
}
let
(
:alert_i
id
)
{
alert
.
i
id
}
subject
{
get
:alert_details
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
d:
alert_
id
}
}
subject
{
get
:alert_details
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
i
id:
alert_i
id
}
}
context
'with authorized user'
do
before
do
...
...
@@ -284,7 +284,7 @@ RSpec.describe Projects::ThreatMonitoringController do
end
context
'when id is invalid'
do
let
(
:alert_id
)
{
nil
}
let
(
:alert_i
i
d
)
{
nil
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
ActionController
::
UrlGenerationError
)
...
...
@@ -292,7 +292,7 @@ RSpec.describe Projects::ThreatMonitoringController do
end
context
'when id is not found'
do
let
(
:alert_id
)
{
non_existing_record_id
}
let
(
:alert_i
i
d
)
{
non_existing_record_id
}
it
'renders not found'
do
subject
...
...
ee/spec/helpers/policy_helper_spec.rb
View file @
b9cbdeaf
...
...
@@ -62,11 +62,11 @@ RSpec.describe PolicyHelper do
let
(
:alert
)
{
build
(
:alert_management_alert
,
project:
project
)
}
context
'when a new alert is created'
do
subject
{
helper
.
threat_monitoring_alert_details_data
(
project
,
alert
.
id
)
}
subject
{
helper
.
threat_monitoring_alert_details_data
(
project
,
alert
.
i
i
d
)
}
it
'returns expected policy data'
do
expect
(
subject
).
to
match
({
'alert-id'
=>
alert
.
id
,
'alert-id'
=>
alert
.
i
i
d
,
'project-path'
=>
project
.
full_path
,
'project-id'
=>
project
.
id
,
'project-issues-path'
=>
project_issues_path
(
project
),
...
...
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