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

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

Fix - Configuration of the account fails if trailing slash is left in the URL #127

Closed tscheid closed 1 year ago

tscheid commented 2 years ago

Hi Guilhem, We have a local Jira installation, when I explore the REST API I get
JSONDecodeError at "/opt/splunk/lib/python3.7/json/decoder.py", line 353 : Expecting ',' delimiter: line 1 column 69 (char 68) and in the search.log something like 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: JSONDecodeError at "/opt/splunk/lib/python3.7/json/decoder.py", line 353 : Expecting ',' delimiter: line 1 column 69 (char 68) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: Traceback: 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/etc/apps/TA-jira-service-desk-simple-addon/lib/splunklib/searchcommands/search_command.py", line 780, in _process_protocol_v2 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: self._execute(ifile, None) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/etc/apps/TA-jira-service-desk-simple-addon/lib/splunklib/searchcommands/generating_command.py", line 207, in _execute 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: self._execute_v2(ifile, self.generate()) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/etc/apps/TA-jira-service-desk-simple-addon/lib/splunklib/searchcommands/search_command.py", line 961, in _execute_v2 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: self._execute_chunk_v2(process, result) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/etc/apps/TA-jira-service-desk-simple-addon/lib/splunklib/searchcommands/generating_command.py", line 215, in _execute_chunk_v2 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: for row in process: 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/etc/apps/TA-jira-service-desk-simple-addon/bin/jirarest.py", line 271, in generate 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: data = {'_time': time.time(), '_raw': str(json.dumps(json.loads(json_response, strict=False), indent=4))} 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/lib/python3.7/json/init.py", line 361, in loads 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: return cls(**kw).decode(s) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/lib/python3.7/json/decoder.py", line 337, in decode 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: File "/opt/splunk/lib/python3.7/json/decoder.py", line 353, in raw_decode 12-09-2021 11:42:51.480 ERROR ChunkedExternProcessor - stderr: obj, end = self.scan_once(s, idx) I configured basic authentication using username and password, no ssl verification. I also tried API token, didn't work either

guilhemmarchand commented 2 years ago

Hi @tscheid

This only means that you are likely failing to authenticate properly.

If you are a Cloud customer of Jira:

You need to use your username with basic authentication, then in the password box you use the API token you created.

If you are using Jira on-prem:

You want to use a PAT based authentication, or basic with username / password

In any case, you want to test the authentication ideally if you can (unless you are a Splunk Cloud customer):

https://ta-jira-service-desk-simple-addon.readthedocs.io/en/latest/troubleshoot.html

tscheid commented 2 years ago

Hi Guilhem,

A test with curl -k https:///rest/api/latest/projecthttps://%3cip:port%3e/rest/api/latest/project --user splunktest:splunktest

Is successful, this is on-prem

From: Guilhem Marchand @.> Sent: Thursday, December 9, 2021 12:09 PM To: guilhemmarchand/TA-jira-service-desk-simple-addon @.> Cc: Thomas Scheidegger @.>; Mention @.> Subject: Re: [guilhemmarchand/TA-jira-service-desk-simple-addon] JSONDecodeError (Issue #127)

Hi @tscheidhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftscheid&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=K49dm8TvS9nThB%2FEUQ%2BAfy6WoixPxb7fiFwWiB1EwR4%3D&reserved=0

This only means that you are likely failing to authenticate properly.

If you are a Cloud customer of Jira:

You need to use your username with basic authentication, then in the password box you use the API token you created.

If you are using Jira on-prem:

You want to use a PAT based authentication, or basic with username / password

In any case, you want to test the authentication ideally if you can (unless you are a Splunk Cloud customer):

https://ta-jira-service-desk-simple-addon.readthedocs.io/en/latest/troubleshoot.htmlhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fta-jira-service-desk-simple-addon.readthedocs.io%2Fen%2Flatest%2Ftroubleshoot.html&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=HM3JFLJ9EKFa2byJelra6eU2AEBLPMI8Yhdq5rTX5HY%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fguilhemmarchand%2FTA-jira-service-desk-simple-addon%2Fissues%2F127%23issuecomment-989752349&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=N1GhaekKLzx32t7eBL0mBUuKZsffnEPnnJIqwqBm1yE%3D&reserved=0, or unsubscribehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAJRDXJMV5HQIOSWYZNVC4WDUQCE6RANCNFSM5JWE2XSA&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Qfcy%2BMBZ0XFo%2B6cb1x8StxEdRVmv%2FTpe48R6QaabFfA%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=0rPReDQ76k5v6rlqhy206It%2FFBXHZ1IRMejHOIUdChw%3D&reserved=0 or Androidhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7Cc3ad9bc886524e049b8308d9bb04607f%7C650ee2c3347146d78fef108c3ce3c414%7C0%7C0%7C637746449744565150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=5IWurklgdzhcsuivR0tEvtVEg0OweBoHo946A5jGHJc%3D&reserved=0.

guilhemmarchand commented 2 years ago

@tscheid

Can you screenshot your app configuration window

In the URL you need to put the server and port but not the rest of the URL which is added automatically.

For the credentials, on premise you would prefer to use PAT but you can use password too

tscheid commented 2 years ago

Is it possible that this is caused by the fact that I have to use IP instead of a hostname? image

tscheid commented 2 years ago

image

guilhemmarchand commented 2 years ago

@tscheid

I will double check but please:

Both IP/fqdn will work

tscheid commented 2 years ago

Removing https:// and the trailing / did indeed fix it. I obviously didn't understand the documentation Thanks for your help

guilhemmarchand commented 2 years ago

Perfect @tscheid glad it's ok now

I will verify, the backend should remove the trailing slash and normally the https is supposed to be verified if present I suspect the trailing slash to be the root cause but I need to check