Add details to Vulnerability GraphQL
What does this MR do?
Related to #290761 (closed)
This change adds new field to Vulnerability GraphQL API that allows to fetch additional information about vulnerability.
Request:
query {
vulnerability(id: "gid://gitlab/Vulnerability/395") {
id
details {
__typename
... on VulnerabilityDetailText {
fieldName
name {
lang
value
}
description {
lang
value
}
value {
lang
value
}
}
... on VulnerabilityDetailList {
fieldName
name {
lang
value
}
description {
lang
value
}
items {
__typename
... on VulnerabilityDetailFileLocation {
fieldName
fileName
lineStart
lineEnd
}
... on VulnerabilityDetailCode {
fieldName
lang
value
}
... on VulnerabilityDetailList {
fieldName
name {
lang
value
}
items {
__typename
... on VulnerabilityDetailFileLocation {
fieldName
fileName
lineStart
lineEnd
}
... on VulnerabilityDetailCode {
fieldName
lang
value
}
}
}
}
}
... on VulnerabilityDetailBase {
fieldName
name {
lang
value
}
description {
lang
value
}
}
}
}
}
Response:
{
"data": {
"vulnerability": {
"id": "gid://gitlab/Vulnerability/395",
"details": [
{
"__typename": "VulnerabilityDetailText",
"fieldName": "fp_reason",
"name": [
{
"lang": "en",
"value": "FP Reason"
}
],
"description": [
{
"lang": "en",
"value": "A False Positive (FP) in the context of vulnerabilities is a reported vulnerability that isnt actually a vulnerability"
}
],
"value": [
{
"lang": "en",
"value": "This was automatically determined to be a false positive due to only constants values being used"
}
]
},
{
"__typename": "VulnerabilityDetailList",
"fieldName": "fp_location",
"name": [
{
"lang": "en",
"value": "FP Location"
}
],
"description": [
{
"lang": "en",
"value": "Where the False Positive (FP) occurred"
}
],
"items": [
{
"__typename": "VulnerabilityDetailFileLocation",
"fieldName": null,
"fileName": "app/controllers/users_controller.rb",
"lineStart": 42,
"lineEnd": 42
},
{
"__typename": "VulnerabilityDetailCode",
"fieldName": null,
"lang": null,
"value": " list_cmd = User.lst\n▶ exec(list_cmd)\n end"
}
]
},
{
"__typename": "VulnerabilityDetailList",
"fieldName": "fp_data_flows",
"name": [
{
"lang": "en",
"value": "FP Data Flows"
}
],
"description": [
{
"lang": "en",
"value": "The distinct data flows used to determine the vulnerability is a False Positive (FP)"
}
],
"items": [
{
"__typename": "VulnerabilityDetailList",
"fieldName": "list_cmd",
"name": [
{
"lang": "en",
"value": "list_cmd"
}
],
"items": [
{
"__typename": "VulnerabilityDetailFileLocation",
"fieldName": null,
"fileName": "app/models/user.rb",
"lineStart": 7,
"lineEnd": 7
},
{
"__typename": "VulnerabilityDetailCode",
"fieldName": null,
"lang": null,
"value": " def self.lst\n▶ return \"getent passwd\"\n end"
},
{
"__typename": "VulnerabilityDetailFileLocation",
"fieldName": null,
"fileName": "app/controllers/users_controller.rb",
"lineStart": 41,
"lineEnd": 41
},
{
"__typename": "VulnerabilityDetailCode",
"fieldName": null,
"lang": null,
"value": " def list_users\n▶ list_cmd = User.lst\n exec(list_cmd)"
},
{
"__typename": "VulnerabilityDetailFileLocation",
"fieldName": null,
"fileName": "app/controllers/users_controller.rb",
"lineStart": 42,
"lineEnd": 42
},
{
"__typename": "VulnerabilityDetailCode",
"fieldName": null,
"lang": null,
"value": " list_cmd = User.lst\n▶ exec(list_cmd)\n end"
}
]
}
]
}
]
}
}
}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Alan (Maciej) Paruszewski