guilhemmarchand / TA-jira-service-desk-simple-addon

Atlasian JIRA add-on for Splunk alert actions
11 stars 9 forks source link

No Proxy function for jirarest.py and jirafill.py #91

Closed kruj0 closed 3 years ago

kruj0 commented 3 years ago

hello, the two python scripts do not use proxy setting from the gui. So its not possible to get rest information from jira and create an issue from the alert action drilldown.

i needed to add following lines into both to use the app in my environment with a http proxy:

here the example from the jirarest.py: ` def generate(self):

  for stanza in confs:
        ...
        if stanza.name == "proxy":
         ...
            for key, value in stanza.content.items():
                if key == "proxy_enabled":
                    proxy_enabled = value
                if key == "proxy_port":
                    proxy_port = value
                if key == "proxy_rdns":
                    proxy_rdns = value
                if key == "proxy_type":
                    proxy_type = value
                if key == "proxy_url":
                    proxy_url = value
    if proxy_url:
       proxy_dict= {
          "http" : proxy_url + ":" + proxy_port,
          "https" : proxy_url + ":" + proxy_port
          }
   ...
  def get_jira_info(self, username, password, url, proxy_dict, endpoint):
    response = requests.get(
        url=self.jira_url(url, endpoint),
        auth=(username, password),
        verify=False,
        proxies=proxy_dict
    )
  ...
        if jira_method == "GET":
            jira_fields_response = requests.get(
                url=str(url) + '/' + str(self.target),
                auth=(username, password),
                verify=False,
                proxies=proxy_dict
            )
  ...

` please check the requests function and add the proxies settings to them.

kruj0 commented 3 years ago

here are my changes: https://github.com/8lex/TA-jira-service-desk-simple-addon/commit/c18c5ce35859cc851c37ffe52cf198c02cde3077

guilhemmarchand commented 3 years ago

Thanks @8lex ! This is very interesting and really cool, I remember I wanted to have the SSL verification option to be taken into account as well.

I will check this very soon and incorporate your change ;-)

guilhemmarchand commented 3 years ago

@8lex Many thanks for your help with this, this is working perfectly fine. Only midification I made is adding the following:

        proxy_url = None
        proxy_dict = None

Otherwise Python would generate an error with variables called before assignment if one is not using a proxy. Will be in the release shortly.

guilhemmarchand commented 3 years ago

Available in release 1.0.30 @8lex in Splunk Base. Many thanks for your contribution, it's been greatly useful!