Commit 371fca38 authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Expose `detectedAt` information for vulnerabilities on GraphQL

This new information directly maps to `created_at` attributes of
vulnerabilities.
parent efd14c49
...@@ -17325,6 +17325,11 @@ type Vulnerability { ...@@ -17325,6 +17325,11 @@ type Vulnerability {
""" """
description: String description: String
"""
Timestamp of when the vulnerability was first detected
"""
detectedAt: Time!
""" """
GraphQL ID of the vulnerability GraphQL ID of the vulnerability
""" """
......
...@@ -50987,6 +50987,24 @@ ...@@ -50987,6 +50987,24 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "detectedAt",
"description": "Timestamp of when the vulnerability was first detected",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "id", "name": "id",
"description": "GraphQL ID of the vulnerability", "description": "GraphQL ID of the vulnerability",
...@@ -2580,6 +2580,7 @@ Represents a vulnerability. ...@@ -2580,6 +2580,7 @@ Represents a vulnerability.
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `description` | String | Description of the vulnerability | | `description` | String | Description of the vulnerability |
| `detectedAt` | Time! | Timestamp of when the vulnerability was first detected |
| `id` | ID! | GraphQL ID of the vulnerability | | `id` | ID! | GraphQL ID of the vulnerability |
| `identifiers` | VulnerabilityIdentifier! => Array | Identifiers of the vulnerability. | | `identifiers` | VulnerabilityIdentifier! => Array | Identifiers of 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 |
......
...@@ -66,5 +66,9 @@ module Types ...@@ -66,5 +66,9 @@ module Types
description: 'The project on which the vulnerability was found', description: 'The project on which the vulnerability was found',
authorize: :read_project, authorize: :read_project,
resolve: -> (obj, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, obj.project_id).find } resolve: -> (obj, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, obj.project_id).find }
field :detected_at, Types::TimeType, null: false,
description: 'Timestamp of when the vulnerability was first detected',
method: :created_at
end end
end end
...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do ...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do
let_it_be(:vulnerability) { create(:vulnerability, project: project) } let_it_be(:vulnerability) { create(:vulnerability, project: project) }
let(:fields) do let(:fields) do
%i[userPermissions id title description user_notes_count state severity report_type resolved_on_default_branch vulnerability_path location scanner primary_identifier identifiers project issueLinks] %i[userPermissions id title description user_notes_count state severity report_type resolved_on_default_branch vulnerability_path location scanner primary_identifier identifiers project issueLinks detected_at]
end end
before do before do
......
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