Skip to content

Commit

Permalink
PAPP-3712 - accomodate case where JIRA is behind proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mctonderski-splunk committed Jul 12, 2024
1 parent 38eacab commit 66d7b54
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/phantomcyber/dev-cicd-tools
rev: v1.17
rev: v1.18
hooks:
- id: org-hook
- id: package-app-dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Connector Version: 3.7.2
Product Vendor: Atlassian
Product Name: Jira
Product Version Supported (regex): ".\*"
Minimum Product Version: 6.1.1
Minimum Product Version: 6.2.1

This app integrates with JIRA to perform several ticket management actions

Expand Down
2 changes: 1 addition & 1 deletion jira.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"product_vendor": "Atlassian",
"product_name": "Jira",
"product_version_regex": ".*",
"min_phantom_version": "6.1.1",
"min_phantom_version": "6.2.1",
"latest_tested_versions": [
"On prem v8.21.0",
"Cloud Copyright (c) 2002 - 2023 Atlassian Corporation Pty Ltd."
Expand Down
30 changes: 30 additions & 0 deletions jira_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import time
from builtins import str
from datetime import datetime
from urllib.parse import urlparse, urlunparse

import dateutil
import phantom.app as phantom
Expand Down Expand Up @@ -491,6 +492,30 @@ def _list_projects(self, param):

return action_result.set_status(phantom.APP_SUCCESS)

def _get_base_url_from_url_path(self, url):
parsed_url = urlparse(url)
return f"{parsed_url.scheme}://{parsed_url.netloc}"

def _update_base_url_in_url_path(self, url, new_base):
parsed_url = urlparse(url)
new_parsed_base = urlparse(new_base)
return urlunparse((
new_parsed_base.scheme, new_parsed_base.netloc,
parsed_url.path, parsed_url.params,
parsed_url.query, parsed_url.fragment
))

def _validate_and_update_custom_fields_url(self, custom_fields):
allowed_values = custom_fields['custom_field']['allowed_values']
for value in allowed_values:
if 'self' not in value:
continue
self_url = value['self']
base_url = self._get_base_url_from_url_path(self_url)
if base_url != self._base_url:
value['self'] = self._update_base_url_in_url_path(self_url, self._base_url)
return custom_fields

def _get_custom_fields_for_issue(self, issue_id, action_result):

try:
Expand All @@ -514,6 +539,11 @@ def _get_custom_fields_for_issue(self, issue_id, action_result):
{}".format(error_message)
return action_result.set_status(phantom.APP_ERROR, error_text), None, None

try:
custom_fields = self._validate_and_update_custom_fields_url(custom_fields)
except KeyError:
return action_result.set_status(phantom.APP_ERROR, "Unable to validate custom fields"), None, None

return phantom.APP_SUCCESS, custom_fields, fields_meta

def _replace_custom_id_with_name(self, input_fields, custom_id_to_name, action_result):
Expand Down

0 comments on commit 66d7b54

Please sign in to comment.