Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mtonderski/papp 33712 #37

Closed
wants to merge 13 commits into from
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
55 changes: 2 additions & 53 deletions 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 Expand Up @@ -10665,58 +10665,7 @@
],
"pip39_dependencies": {
"wheel": [
{
"module": "PyJWT",
"input_file": "wheels/py3/PyJWT-2.6.0-py3-none-any.whl"
},
{
"module": "beautifulsoup4",
"input_file": "wheels/py3/beautifulsoup4-4.9.1-py3-none-any.whl"
},
{
"module": "defusedxml",
"input_file": "wheels/shared/defusedxml-0.7.1-py2.py3-none-any.whl"
},
{
"module": "jira",
"input_file": "wheels/py3/jira-3.5.0-py3-none-any.whl"
},
{
"module": "oauthlib",
"input_file": "wheels/shared/oauthlib-3.1.0-py2.py3-none-any.whl"
},
{
"module": "packaging",
"input_file": "wheels/py3/packaging-24.0-py3-none-any.whl"
},
{
"module": "pbr",
"input_file": "wheels/shared/pbr-5.4.4-py2.py3-none-any.whl"
},
{
"module": "python_dateutil",
"input_file": "wheels/shared/python_dateutil-2.8.1-py2.py3-none-any.whl"
},
{
"module": "pytz",
"input_file": "wheels/shared/pytz-2021.1-py2.py3-none-any.whl"
},
{
"module": "requests_oauthlib",
"input_file": "wheels/shared/requests_oauthlib-1.3.1-py2.py3-none-any.whl"
},
{
"module": "requests_toolbelt",
"input_file": "wheels/shared/requests_toolbelt-0.10.1-py2.py3-none-any.whl"
},
{
"module": "six",
"input_file": "wheels/shared/six-1.16.0-py2.py3-none-any.whl"
},
{
"module": "soupsieve",
"input_file": "wheels/py3/soupsieve-2.5-py3-none-any.whl"
}

]
}
}
32 changes: 32 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,33 @@ 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):
try:
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
except KeyError:
mctonderski-splunk marked this conversation as resolved.
Show resolved Hide resolved
return False

def _get_custom_fields_for_issue(self, issue_id, action_result):

try:
Expand All @@ -514,6 +542,10 @@ 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

custom_fields = self._validate_and_update_custom_fields_url(custom_fields)
if not custom_fields:
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
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
beautifulsoup4==4.9.1
jira==3.5.0
oauthlib==3.1.0
pbr==5.4.4
PyJWT==2.6.0
python-dateutil==2.8.1
pytz==2021.1
requests_oauthlib==1.3.1
requests_toolbelt==0.10.1
beautifulsoup4==4.12.3
jira==3.8.0
oauthlib==3.2.2
pbr==6.0.0
PyJWT==2.8.0
python-dateutil==2.9.0.post0
pytz==2024.1
requests_oauthlib==2.0.0
requests_toolbelt==1.0.0
Binary file removed wheels/py3/PyJWT-2.6.0-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/beautifulsoup4-4.9.1-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/jira-3.5.0-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/packaging-24.0-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/soupsieve-2.5-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file removed wheels/shared/oauthlib-3.1.0-py2.py3-none-any.whl
Binary file not shown.
Binary file removed wheels/shared/pbr-5.4.4-py2.py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file removed wheels/shared/pytz-2021.1-py2.py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed wheels/shared/six-1.16.0-py2.py3-none-any.whl
Binary file not shown.
Loading