Skip to main content

Check out Port for yourselfย 

Create Jira Issue from Dependabot Alert

Overviewโ€‹

This guide will help you implement a self-service action in Port that allows you to create Jira issues from Dependabot alerts. This functionality streamlines vulnerability management by enabling users to quickly create and track issues for security alerts.

You can implement this action in two ways:

  1. GitHub workflow: A more flexible approach that allows for complex workflows and custom logic, suitable for teams that want to maintain their automation in Git.
  2. Synced webhooks: A simpler approach that directly interacts with Jira's API through Port, ideal for quick implementation and minimal setup.

Use casesโ€‹

  • Automatically create Jira issues from Dependabot alerts.
  • Add detailed metadata to Jira issues from Dependabot alerts.
  • Link Dependabot alerts to services in your Port catalog.

Prerequisitesโ€‹

Set up data modelโ€‹

If you haven't installed the Jira integration, you'll need to create blueprints for Jira projects and issues.
However we highly recommend you install the Jira integration to have these automatically set up for you.

Create the Jira Project blueprintโ€‹

  1. Go to your Builder page.

  2. Click on + Blueprint.

  3. Click on the {...} button in the top right corner, and choose "Edit JSON".

  4. Add this JSON schema:

    Jira Project Blueprint (Click to expand)
    {
    "identifier": "jiraProject",
    "description": "A Jira project",
    "title": "Jira Project",
    "icon": "Jira",
    "schema": {
    "properties": {
    "url": {
    "title": "Project URL",
    "type": "string",
    "format": "url",
    "description": "URL to the project in Jira"
    },
    "totalIssues": {
    "title": "Total Issues",
    "type": "number",
    "description": "The total number of issues in the project"
    }
    },
    "required": []
    },
    "mirrorProperties": {},
    "calculationProperties": {},
    "aggregationProperties": {},
    "relations": {}
    }
  5. Click "Save" to create the blueprint.

Create the Repository blueprintโ€‹

You should have installed the Port's GitHub app, which automatically creates a Repository blueprint for you. If you haven't installed the app, you can create the Repository blueprint in Port using the schema below:

Repository Blueprint (Click to expand)
{
"identifier": "githubRepository",
"title": "Repository",
"icon": "Github",
"ownership": {
"type": "Direct"
},
"schema": {
"properties": {
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"url": {
"icon": "DefaultProperty",
"title": "Repository URL",
"type": "string",
"format": "url"
},
"defaultBranch": {
"title": "Default branch",
"type": "string"
},
"last_contributor": {
"title": "Last contributor",
"icon": "TwoUsers",
"type": "string",
"format": "user"
},
"last_push": {
"icon": "GitPullRequest",
"title": "Last push",
"description": "Last commit to the main branch",
"type": "string",
"format": "date-time"
},
"require_code_owner_review": {
"title": "Require code owner review",
"type": "boolean",
"icon": "DefaultProperty",
"description": "Requires review from code owners before a pull request can be merged"
},
"require_approval_count": {
"title": "Require approvals",
"type": "number",
"icon": "DefaultProperty",
"description": "The number of approvals required before merging a pull request"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}

Create the Dependabot Alert blueprint

Create the Dependabot Alert blueprint using this schema:

Dependabot Alert Blueprint (Click to expand)
{
"identifier": "githubDependabotAlert",
"title": "Dependabot Alert",
"icon": "Github",
"schema": {
"properties": {
"severity": {
"icon": "DefaultProperty",
"title": "Severity",
"type": "string",
"enum": [
"low",
"medium",
"high",
"critical"
],
"enumColors": {
"low": "green",
"medium": "orange",
"high": "red",
"critical": "red"
}
},
"state": {
"title": "State",
"type": "string",
"enum": [
"auto_dismissed",
"dismissed",
"fixed",
"open"
],
"enumColors": {
"auto_dismissed": "green",
"dismissed": "green",
"fixed": "green",
"open": "red"
},
"icon": "DefaultProperty"
},
"packageName": {
"icon": "DefaultProperty",
"title": "Package Name",
"type": "string"
},
"packageEcosystem": {
"title": "Package Ecosystem",
"type": "string"
},
"manifestPath": {
"title": "Manifest Path",
"type": "string"
},
"scope": {
"title": "Scope",
"type": "string"
},
"ghsaID": {
"title": "GHSA ID",
"type": "string"
},
"cveID": {
"title": "CVE ID",
"type": "string"
},
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"references": {
"icon": "Vulnerability",
"title": "References",
"type": "array",
"items": {
"type": "string",
"format": "url"
}
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}
Mapping Dependabot Alerts to Repository Blueprint

To effectively manage your Dependabot alerts, map them to your Repository blueprint in Port. This allows you to categorize and link alerts to the appropriate repositories within your catalog, enhancing visibility and traceability. Follow this resource mapping guide for detailed steps on how to map Dependabot alerts.

Implementationโ€‹

You can create Jira issues from Dependabot alerts by leveraging Port's synced webhooks and secrets to directly interact with the Jira's API. This method simplifies the setup by handling everything within Port.

Add Port secrets

Existing secrets

If you have already installed Port's Jira integration, these secrets should already exist in your portal.
To view your existing secrets:

  1. Click on the ... button in the top right corner of your Port application.
  2. Choose Credentials, then click on the Secrets tab.

To add these secrets to your portal:

  1. Click on the ... button in the top right corner of your Port application.

  2. Click on Credentials.

  3. Click on the Secrets tab.

  4. Click on + Secret and add the following secrets:

    • JIRA_API_TOKEN - Your Jira API token

    • JIRA_USER_EMAIL - The email of the Jira user that owns the API token

    • JIRA_AUTH - Base64 encoded string of your Jira credentials. Generate this by running:

      echo -n "your-email@domain.com:your-api-token" | base64

      Replace your-email@domain.com with your Jira email and your-api-token with your Jira API token.

      One time generation

      The base64 encoded string only needs to be generated once and will work for all webhook calls until you change your API token.

Set up self-service action

Follow these steps to create the self-service action:

  1. Head to the self-service page.

  2. Click on the + New Action button.

  3. Click on the {...} Edit JSON button.

  4. Copy and paste the following JSON configuration into the editor.

    Create Jira Issue from Dependabot Alert (Webhook) (Click to expand)
    {
    "identifier": "create_jira_issue_from_dependabot_webhook",
    "title": "Create Jira Issue from Dependabot (Webhook)",
    "icon": "Jira",
    "description": "Creates a Jira issue from dependabot alert using a webhook",
    "trigger": {
    "type": "self-service",
    "operation": "DAY-2",
    "userInputs": {
    "properties": {
    "project": {
    "title": "Project Key",
    "description": "The Jira project key where the issue will be created",
    "icon": "Jira",
    "type": "string"
    },
    "type": {
    "title": "Type",
    "description": "Issue type",
    "icon": "Jira",
    "type": "string",
    "default": "Task",
    "enum": [
    "Task",
    "Story",
    "Bug",
    "Epic"
    ],
    "enumColors": {
    "Task": "blue",
    "Story": "green",
    "Bug": "red",
    "Epic": "pink"
    }
    }
    },
    "required": [
    "type",
    "project"
    ]
    },
    "blueprintIdentifier": "githubDependabotAlert"
    },
    "invocationMethod": {
    "type": "WEBHOOK",
    "url": "https://<JIRA_ORGANIZATION_URL>/rest/api/3/issue",
    "agent": false,
    "synchronized": true,
    "method": "POST",
    "headers": {
    "Authorization": "Basic {{.secrets.JIRA_AUTH}}",
    "Content-Type": "application/json"
    },
    "body": {
    "fields": {
    "project": {
    "key": "{{.inputs.project}}"
    },
    "summary": "Dependabot Alert: {{.entity.title}}",
    "description": {
    "version": 1,
    "type": "doc",
    "content": [
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Severity",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.severity}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "State",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.state}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Package Name",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.packageName}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Package Ecosystem",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.packageEcosystem}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Manifest Path",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.manifestPath}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Scope",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.scope}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "GHSA ID",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.ghsaID}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "CVE ID",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": {{.entity.properties.cveID}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "URL",
    "marks": [
    {
    "type": "strong"
    }
    ]
    },
    {
    "type": "text",
    "text": ": "
    },
    {
    "type": "text",
    "text": "{{.entity.properties.url}}",
    "marks": [
    {
    "type": "link",
    "attrs": {
    "href": "{{.entity.properties.url}}"
    }
    }
    ]
    }
    ]
    }
    ]
    },
    "issuetype": {
    "name": "{{.inputs.type}}"
    },
    "labels": ["port-{{.entity.identifier}}"]
    }
    }
    },
    "requiredApproval": false
    }
  5. Click Save.

Now you should see the Create Jira Issue from Dependabot (Webhook) action in the self-service page. ๐ŸŽ‰

Configure your Jira url

Replace <JIRA_ORGANIZATION_URL> in the webhook URL with your Jira organization URL (e.g., example.atlassian.net).

Let's test it!โ€‹

  1. Head to the self-service page of your portal

  2. Choose either the GitHub workflow or webhook implementation:

    • For GitHub workflow: Click on Create Jira Issue from Dependabot
    • For webhook: Click on Create Jira Issue from Dependabot (Webhook)
  3. Select the Dependabot alert you want to create an issue for

  4. Select the project where the issue will be created

  5. Select the issue type

  6. Click on Execute

  7. Done! wait for the issue to be created in Jira

More Self Service Jira Actions Examplesโ€‹