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
f71a7f75
Commit
f71a7f75
authored
Jul 27, 2020
by
Philip Cunningham
Committed by
Martin Wortschack
Jul 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show errors in flash if DAST on-demand scan fails
parent
e279b703
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
5 deletions
+38
-5
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
...ripts/on_demand_scans/components/on_demand_scans_form.vue
+12
-3
ee/app/assets/javascripts/on_demand_scans/graphql/run_dast_scan.mutation.graphql
...ts/on_demand_scans/graphql/run_dast_scan.mutation.graphql
+1
-0
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
...d/on_demand_scans/components/on_demand_scans_form_spec.js
+22
-2
locale/gitlab.pot
locale/gitlab.pot
+3
-0
No files found.
ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
View file @
f71a7f75
<
script
>
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
createFlash
from
'
~/flash
'
;
import
{
isAbsolute
,
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
{
...
...
@@ -99,8 +99,17 @@ export default {
mutation
:
runDastScanMutation
,
variables
:
this
.
formData
,
})
.
then
(({
data
:
{
runDastScan
:
{
pipelineUrl
}
}
})
=>
{
redirectTo
(
pipelineUrl
);
.
then
(({
data
:
{
runDastScan
:
{
pipelineUrl
,
errors
}
}
})
=>
{
if
(
errors
?.
length
)
{
createFlash
(
sprintf
(
s__
(
'
OnDemandScans|Could not run the scan: %{backendErrorMessage}
'
),
{
backendErrorMessage
:
errors
.
join
(
'
,
'
),
}),
);
this
.
loading
=
false
;
}
else
{
redirectTo
(
pipelineUrl
);
}
})
.
catch
(
e
=>
{
Sentry
.
captureException
(
e
);
...
...
ee/app/assets/javascripts/on_demand_scans/graphql/run_dast_scan.mutation.graphql
View file @
f71a7f75
...
...
@@ -13,5 +13,6 @@ mutation runDastScan(
}
)
{
pipelineUrl
errors
}
}
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
View file @
f71a7f75
...
...
@@ -194,7 +194,7 @@ describe('OnDemandScansApp', () => {
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
)
.
mockResolvedValue
({
data
:
{
runDastScan
:
{
pipelineUrl
}
}
});
.
mockResolvedValue
({
data
:
{
runDastScan
:
{
pipelineUrl
,
errors
:
[]
}
}
});
const
input
=
findTargetUrlInput
();
input
.
vm
.
$emit
(
'
input
'
,
targetUrl
);
submitForm
();
...
...
@@ -221,7 +221,7 @@ describe('OnDemandScansApp', () => {
});
});
describe
(
'
on error
'
,
()
=>
{
describe
(
'
on
top-level
error
'
,
()
=>
{
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockRejectedValue
();
const
input
=
findTargetUrlInput
();
...
...
@@ -237,5 +237,25 @@ describe('OnDemandScansApp', () => {
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
Could not run the scan. Please try again.
'
);
});
});
describe
(
'
on errors as data
'
,
()
=>
{
beforeEach
(
async
()
=>
{
const
errors
=
[
'
A
'
,
'
B
'
,
'
C
'
];
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
)
.
mockResolvedValue
({
data
:
{
runDastScan
:
{
pipelineUrl
:
null
,
errors
}
}
});
const
input
=
findTargetUrlInput
();
input
.
vm
.
$emit
(
'
input
'
,
targetUrl
);
submitForm
();
});
it
(
'
resets loading state
'
,
()
=>
{
expect
(
wrapper
.
vm
.
loading
).
toBe
(
false
);
});
it
(
'
shows an error flash
'
,
()
=>
{
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
Could not run the scan: A, B, C
'
);
});
});
});
});
locale/gitlab.pot
View file @
f71a7f75
...
...
@@ -16388,6 +16388,9 @@ msgstr ""
msgid "OnDemandScans|Could not run the scan. Please try again."
msgstr ""
msgid "OnDemandScans|Could not run the scan: %{backendErrorMessage}"
msgstr ""
msgid "OnDemandScans|Create new DAST scan"
msgstr ""
...
...
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