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
f903717c
Commit
f903717c
authored
Feb 19, 2022
by
Samantha Ming
Committed by
Savas Vedova
Feb 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add security training to vulnerability modal
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/346067
parent
174311a0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
7 deletions
+84
-7
ee/app/assets/javascripts/vue_shared/security_reports/components/vulnerability_details.vue
...red/security_reports/components/vulnerability_details.vue
+32
-2
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
...pts/vulnerabilities/components/vulnerability_training.vue
+9
-3
ee/app/controllers/ee/projects/pipelines_controller.rb
ee/app/controllers/ee/projects/pipelines_controller.rb
+1
-0
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/vulnerability_details_spec.js.snap
...mponents/__snapshots__/vulnerability_details_spec.js.snap
+12
-0
ee/spec/frontend/vue_shared/security_reports/components/vulnerability_details_spec.js
...security_reports/components/vulnerability_details_spec.js
+15
-1
ee/spec/frontend/vue_shared/security_reports/grouped_security_reports_app_spec.js
...red/security_reports/grouped_security_reports_app_spec.js
+3
-0
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
...c/frontend/vulnerabilities/vulnerability_training_spec.js
+12
-1
No files found.
ee/app/assets/javascripts/vue_shared/security_reports/components/vulnerability_details.vue
View file @
f903717c
...
...
@@ -3,10 +3,17 @@ import { GlFriendlyWrap, GlLink, GlBadge, GlSafeHtmlDirective } from '@gitlab/ui
import
{
REPORT_TYPES
}
from
'
ee/security_dashboard/store/constants
'
;
import
FalsePositiveAlert
from
'
ee/vulnerabilities/components/false_positive_alert.vue
'
;
import
GenericReportSection
from
'
ee/vulnerabilities/components/generic_report/report_section.vue
'
;
import
{
SUPPORTING_MESSAGE_TYPES
}
from
'
ee/vulnerabilities/constants
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
SUPPORTING_MESSAGE_TYPES
,
VULNERABILITY_TRAINING_HEADING
,
}
from
'
ee/vulnerabilities/constants
'
;
import
{
convertObjectPropsToCamelCase
,
convertArrayOfObjectsToCamelCase
,
}
from
'
~/lib/utils/common_utils
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
CodeBlock
from
'
~/vue_shared/components/code_block.vue
'
;
import
VulnerabilityTraining
from
'
ee/vulnerabilities/components/vulnerability_training.vue
'
;
import
getFileLocation
from
'
../store/utils/get_file_location
'
;
import
{
bodyWithFallBack
}
from
'
./helpers
'
;
import
SeverityBadge
from
'
./severity_badge.vue
'
;
...
...
@@ -23,11 +30,17 @@ export default {
GlLink
,
GlBadge
,
FalsePositiveAlert
,
VulnerabilityTraining
,
},
directives
:
{
SafeHtml
:
GlSafeHtmlDirective
,
},
props
:
{
vulnerability
:
{
type
:
Object
,
required
:
true
}
},
data
()
{
return
{
showTraining
:
false
,
};
},
computed
:
{
url
()
{
return
this
.
vulnerability
.
request
?.
url
||
getFileLocation
(
this
.
vulnLocation
);
...
...
@@ -141,6 +154,9 @@ export default {
hasRecordedResponse
()
{
return
Boolean
(
this
.
constructedRecordedResponse
);
},
camelCaseFormattedIdentifiers
()
{
return
convertArrayOfObjectsToCamelCase
(
this
.
identifiers
);
},
},
methods
:
{
getHeadersAsCodeBlockLines
(
headers
)
{
...
...
@@ -175,6 +191,12 @@ export default {
?
[
`
${
method
}
${
url
}
\n`
,
headerLines
,
'
\n\n
'
,
bodyWithFallBack
(
body
)].
join
(
''
)
:
''
;
},
handleShowTraining
(
showVulnerabilityTraining
)
{
this
.
showTraining
=
showVulnerabilityTraining
;
},
},
i18n
:
{
VULNERABILITY_TRAINING_HEADING
,
},
};
</
script
>
...
...
@@ -309,5 +331,13 @@ export default {
class=
"gl-mt-4"
:details=
"vulnerability.details"
/>
<div
v-if=
"identifiers"
v-show=
"showTraining"
>
<vulnerability-detail
:label=
"$options.i18n.VULNERABILITY_TRAINING_HEADING.title"
>
<vulnerability-training
:identifiers=
"camelCaseFormattedIdentifiers"
@
show-vulnerability-training=
"handleShowTraining"
/>
</vulnerability-detail>
</div>
</div>
</
template
>
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
View file @
f903717c
...
...
@@ -65,10 +65,10 @@ export default {
},
computed
:
{
showVulnerabilityTraining
()
{
return
(
return
Boolean
(
this
.
glFeatures
.
secureVulnerabilityTraining
&&
this
.
enabledSecurityTrainingProviders
?.
length
&&
this
.
identifiers
?.
length
this
.
enabledSecurityTrainingProviders
?.
length
&&
this
.
identifiers
?.
length
,
);
},
enabledSecurityTrainingProviders
()
{
...
...
@@ -84,6 +84,12 @@ export default {
},
},
watch
:
{
showVulnerabilityTraining
:
{
immediate
:
true
,
handler
(
showVulnerabilityTraining
)
{
this
.
$emit
(
'
show-vulnerability-training
'
,
showVulnerabilityTraining
);
},
},
supportedIdentifier
:
{
immediate
:
true
,
handler
(
supportedIdentifier
)
{
...
...
ee/app/controllers/ee/projects/pipelines_controller.rb
View file @
f903717c
...
...
@@ -11,6 +11,7 @@ module EE
before_action
do
push_frontend_feature_flag
(
:pipeline_security_dashboard_graphql
,
project
,
type: :development
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:graphql_code_quality_full_report
,
project
,
type: :development
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:secure_vulnerability_training
,
project
,
default_enabled: :yaml
)
end
feature_category
:license_compliance
,
[
:licenses
]
...
...
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/vulnerability_details_spec.js.snap
View file @
f903717c
...
...
@@ -200,5 +200,17 @@ key2: value2
<!---->
<!---->
<div
style="display: none;"
>
<vulnerability-detail-stub
label="Training"
>
<vulnerability-training-stub
identifiers="[object Object],[object Object]"
/>
</vulnerability-detail-stub>
</div>
</div>
`;
ee/spec/frontend/vue_shared/security_reports/components/vulnerability_details_spec.js
View file @
f903717c
...
...
@@ -9,7 +9,7 @@ import GenericReportSection from 'ee/vulnerabilities/components/generic_report/r
import
{
SUPPORTING_MESSAGE_TYPES
}
from
'
ee/vulnerabilities/constants
'
;
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
VulnerabilityTraining
from
'
ee/vulnerabilities/components/vulnerability_training.vue
'
;
import
{
mockFindings
}
from
'
../mock_data
'
;
function
makeVulnerability
(
changes
=
{})
{
...
...
@@ -23,6 +23,9 @@ describe('VulnerabilityDetails component', () => {
wrapper
=
mountExtended
(
VulnerabilityDetails
,
{
propsData
:
{
vulnerability
},
provide
,
stubs
:
{
VulnerabilityTraining
:
true
,
},
});
};
...
...
@@ -135,6 +138,17 @@ describe('VulnerabilityDetails component', () => {
);
});
it
(
'
renders vulnerability training
'
,
()
=>
{
const
identifiers
=
[{
externalType
:
'
cwe
'
},
{
externalType
:
'
cve
'
}];
const
vulnerability
=
makeVulnerability
({
identifiers
});
componentFactory
(
vulnerability
);
expect
(
wrapper
.
findComponent
(
VulnerabilityTraining
).
props
()).
toMatchObject
({
identifiers
,
});
});
describe
(
'
does not render XSS links
'
,
()
=>
{
// eslint-disable-next-line no-script-url
const
badUrl
=
'
javascript:alert("")
'
;
...
...
ee/spec/frontend/vue_shared/security_reports/grouped_security_reports_app_spec.js
View file @
f903717c
...
...
@@ -86,6 +86,9 @@ describe('Grouped security reports app', () => {
const
createWrapper
=
(
propsData
,
options
,
provide
)
=>
{
wrapper
=
mount
(
GroupedSecurityReportsApp
,
{
propsData
,
stubs
:
{
VulnerabilityTraining
:
true
,
},
mocks
:
{
$apollo
:
{
queries
:
{
...
...
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
View file @
f903717c
import
Vue
from
'
vue
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
...
...
@@ -110,6 +110,17 @@ describe('VulnerabilityTraining component', () => {
expect
(
wrapper
.
html
()).
toBeFalsy
();
});
it
(
'
watches showVulnerabilityTraining and emits change
'
,
async
()
=>
{
createApolloProvider
();
createComponent
();
await
waitForQueryToBeLoaded
();
await
nextTick
();
// Note: the event emits twice - the second time is when the query is loaded
expect
(
wrapper
.
emitted
(
'
show-vulnerability-training
'
)).
toEqual
([[
false
],
[
true
]]);
});
});
describe
(
'
with title slot
'
,
()
=>
{
...
...
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