Commit 819526d1 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '258810-2-itteration-be' into 'master'

Add MergeRequest to VulnerabilityType in GraphQL

See merge request gitlab-org/gitlab!50082
parents 927f1801 6353e01e
...@@ -167,6 +167,8 @@ module Types ...@@ -167,6 +167,8 @@ module Types
description: 'Indicates if the merge request is mergeable' description: 'Indicates if the merge request is mergeable'
field :commits_without_merge_commits, Types::CommitType.connection_type, null: true, field :commits_without_merge_commits, Types::CommitType.connection_type, null: true,
calls_gitaly: true, description: 'Merge request commits excluding merge commits' calls_gitaly: true, description: 'Merge request commits excluding merge commits'
field :security_auto_fix, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if the merge request is created by @GitLab-Security-Bot.'
def approved_by def approved_by
object.approved_by_users object.approved_by_users
...@@ -229,6 +231,10 @@ module Types ...@@ -229,6 +231,10 @@ module Types
def commits_without_merge_commits def commits_without_merge_commits
object.recent_commits.without_merge_commits object.recent_commits.without_merge_commits
end end
def security_auto_fix
object.author == User.security_bot
end
end end
end end
......
---
title: Add MergeRequest to VulnerabilityType in GraphQL
merge_request: 50082
author:
type: added
...@@ -13456,6 +13456,11 @@ type MergeRequest implements CurrentUserTodos & Noteable { ...@@ -13456,6 +13456,11 @@ type MergeRequest implements CurrentUserTodos & Noteable {
full: Boolean = false full: Boolean = false
): String! ): String!
"""
Indicates if the merge request is created by @GitLab-Security-Bot.
"""
securityAutoFix: Boolean
""" """
Indicates if the merge request will be rebased Indicates if the merge request will be rebased
""" """
...@@ -25001,6 +25006,11 @@ type Vulnerability implements Noteable { ...@@ -25001,6 +25006,11 @@ type Vulnerability implements Noteable {
""" """
location: VulnerabilityLocation location: VulnerabilityLocation
"""
Merge request that fixes the vulnerability.
"""
mergeRequest: MergeRequest
""" """
All notes on this noteable All notes on this noteable
""" """
......
...@@ -37121,6 +37121,20 @@ ...@@ -37121,6 +37121,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "securityAutoFix",
"description": "Indicates if the merge request is created by @GitLab-Security-Bot.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "shouldBeRebased", "name": "shouldBeRebased",
"description": "Indicates if the merge request will be rebased", "description": "Indicates if the merge request will be rebased",
...@@ -72824,6 +72838,20 @@ ...@@ -72824,6 +72838,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "mergeRequest",
"description": "Merge request that fixes the vulnerability.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "MergeRequest",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "notes", "name": "notes",
"description": "All notes on this noteable", "description": "All notes on this noteable",
...@@ -2088,6 +2088,7 @@ Autogenerated return type of MarkAsSpamSnippet. ...@@ -2088,6 +2088,7 @@ Autogenerated return type of MarkAsSpamSnippet.
| `rebaseCommitSha` | String | Rebase commit SHA of the merge request | | `rebaseCommitSha` | String | Rebase commit SHA of the merge request |
| `rebaseInProgress` | Boolean! | Indicates if there is a rebase currently in progress for the merge request | | `rebaseInProgress` | Boolean! | Indicates if there is a rebase currently in progress for the merge request |
| `reference` | String! | Internal reference of the merge request. Returned in shortened format by default | | `reference` | String! | Internal reference of the merge request. Returned in shortened format by default |
| `securityAutoFix` | Boolean | Indicates if the merge request is created by @GitLab-Security-Bot. |
| `shouldBeRebased` | Boolean! | Indicates if the merge request will be rebased | | `shouldBeRebased` | Boolean! | Indicates if the merge request will be rebased |
| `shouldRemoveSourceBranch` | Boolean | Indicates if the source branch of the merge request will be deleted after merge | | `shouldRemoveSourceBranch` | Boolean | Indicates if the source branch of the merge request will be deleted after merge |
| `sourceBranch` | String! | Source branch of the merge request | | `sourceBranch` | String! | Source branch of the merge request |
...@@ -3772,6 +3773,7 @@ Represents a vulnerability. ...@@ -3772,6 +3773,7 @@ Represents a vulnerability.
| `identifiers` | VulnerabilityIdentifier! => Array | Identifiers of the vulnerability. | | `identifiers` | VulnerabilityIdentifier! => Array | Identifiers of the vulnerability. |
| `issueLinks` | VulnerabilityIssueLinkConnection! | List of issue links related to the vulnerability | | `issueLinks` | VulnerabilityIssueLinkConnection! | List of issue links related to the vulnerability |
| `location` | VulnerabilityLocation | Location metadata for the vulnerability. Its fields depend on the type of security scan that found the vulnerability | | `location` | VulnerabilityLocation | Location metadata for the vulnerability. Its fields depend on the type of security scan that found the vulnerability |
| `mergeRequest` | MergeRequest | Merge request that fixes the vulnerability. |
| `notes` | NoteConnection! | All notes on this noteable | | `notes` | NoteConnection! | All notes on this noteable |
| `primaryIdentifier` | VulnerabilityIdentifier | Primary identifier of the vulnerability. | | `primaryIdentifier` | VulnerabilityIdentifier | Primary identifier of the vulnerability. |
| `project` | Project | The project on which the vulnerability was found | | `project` | Project | The project on which the vulnerability was found |
......
...@@ -78,6 +78,9 @@ module Types ...@@ -78,6 +78,9 @@ module Types
description: 'Indicates whether there is a solution available for this vulnerability.', description: 'Indicates whether there is a solution available for this vulnerability.',
resolver_method: :has_solutions? resolver_method: :has_solutions?
field :merge_request, ::Types::MergeRequestType, null: true,
description: 'Merge request that fixes the vulnerability.'
def user_notes_count def user_notes_count
::Gitlab::Graphql::Aggregations::Vulnerabilities::LazyUserNotesCountAggregate.new(context, object) ::Gitlab::Graphql::Aggregations::Vulnerabilities::LazyUserNotesCountAggregate.new(context, object)
end end
...@@ -106,6 +109,10 @@ module Types ...@@ -106,6 +109,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end end
def merge_request
object.finding&.merge_request_feedback&.merge_request
end
def has_solutions? def has_solutions?
object.finding&.remediations&.any? object.finding&.remediations&.any?
end end
......
...@@ -30,6 +30,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do ...@@ -30,6 +30,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do
notes notes
external_issue_links external_issue_links
has_solutions has_solutions
merge_request
discussions] discussions]
end end
......
...@@ -29,7 +29,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do ...@@ -29,7 +29,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
total_time_spent reference author merged_at commit_count current_user_todos total_time_spent reference author merged_at commit_count current_user_todos
conflicts auto_merge_enabled approved_by source_branch_protected conflicts auto_merge_enabled approved_by source_branch_protected
default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies
has_ci mergeable commits_without_merge_commits has_ci mergeable commits_without_merge_commits security_auto_fix
] ]
if Gitlab.ee? if Gitlab.ee?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment