Skip to content

JIRA Integration - On a project's vulnerability report, show count of related Jira issues within a rows activity column

What does this MR do?

It adds counts and links for related Jira issues to the items of the Vulnerabilities Report when the Jira integration is enabled for a project.

Screenshots (strongly suggested)

Screen_Shot_2021-02-09_at_9.40.34_pm

How to test this

  1. Walk through on how to enable the Jira integration for a project: https://www.youtube.com/watch?v=MLl4lndKiYs
  2. I was not able to get the GraphQL endpoint returning any data locally (it does work on Production) so I used the following patch to get around it:
diff --git a/ee/app/assets/javascripts/security_dashboard/graphql/provider.js b/ee/app/assets/javascripts/security_dashboard/graphql/provider.js
index 125b92677d5..24322aac0c6 100644
--- a/ee/app/assets/javascripts/security_dashboard/graphql/provider.js
+++ b/ee/app/assets/javascripts/security_dashboard/graphql/provider.js
@@ -1,6 +1,7 @@
 import Vue from 'vue';
 import VueApollo from 'vue-apollo';
 import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
+import { uniqueId } from 'lodash';
 import createDefaultClient from '~/lib/graphql';
 import introspectionQueryResultData from './fragmentTypes.json';
 
@@ -12,15 +13,50 @@ const fragmentMatcher = new IntrospectionFragmentMatcher({
   introspectionQueryResultData,
 });
 
-const defaultClient = createDefaultClient(
-  {},
-  {
-    cacheConfig: {
-      fragmentMatcher,
+const resolvers = {
+  Vulnerability: {
+    externalIssueLinks: () => {
+      return {
+        __typename: 'VulnerabilityExternalIssueLinkConnection',
+        nodes: [
+          {
+            __typename: 'VulnerabilityExternalIssueLink',
+            id: uniqueId(),
+            externalIssue: {
+              __typename: 'ExternalIssue',
+              externalTracker: 'jira',
+              webUrl: 'https://mparuszewski-gitlab.atlassian.net/browse/GV-11',
+              title: 'jira',
+              createdAt: `${Date.now()}`,
+              relativeReference: uniqueId('JIRA-'),
+            },
+            linkType: 'CREATED',
+          },
+          {
+            __typename: 'VulnerabilityExternalIssueLink',
+            id: uniqueId(),
+            externalIssue: {
+              __typename: 'ExternalIssue',
+              externalTracker: 'jira',
+              webUrl: 'https://mparuszewski-gitlab.atlassian.net/browse/GV-11',
+              title: 'jira',
+              createdAt: `${Date.now()}`,
+              relativeReference: uniqueId('JIRA-'),
+            },
+            linkType: 'CREATED',
+          },
+        ],
+      };
     },
-    assumeImmutableResults: true,
   },
-);
+};
+
+const defaultClient = createDefaultClient(resolvers, {
+  cacheConfig: {
+    fragmentMatcher,
+  },
+  assumeImmutableResults: true,
+});
 
 export default new VueApollo({
   defaultClient,
diff --git a/ee/app/assets/javascripts/security_dashboard/graphql/queries/project_vulnerabilities.query.graphql b/ee/app/assets/javascripts/security_dashboard/graphql/queries/project_vulnerabilities.query.graphql
index 9ff50581356..d269c9e9d96 100644
--- a/ee/app/assets/javascripts/security_dashboard/graphql/queries/project_vulnerabilities.query.graphql
+++ b/ee/app/assets/javascripts/security_dashboard/graphql/queries/project_vulnerabilities.query.graphql
@@ -12,7 +12,6 @@ query project(
   $sort: VulnerabilitySort
   $hasIssues: Boolean
   $hasResolution: Boolean
-  $includeExternalIssueLinks: Boolean = false
 ) {
   project(fullPath: $fullPath) {
     vulnerabilities(
@@ -28,7 +27,7 @@ query project(
     ) {
       nodes {
         ...Vulnerability
-        externalIssueLinks @include(if: $includeExternalIssueLinks) {
+        externalIssueLinks @client {
           nodes {
             issue: externalIssue {
               externalTracker

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #300143 (closed)

Edited by David Pisek

Merge request reports

Loading