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

AppInspect 3.8.0 reports failure with splunk-sdk 2.0.2 #594

Closed
matt-gan opened this issue Oct 28, 2024 · 15 comments
Closed

AppInspect 3.8.0 reports failure with splunk-sdk 2.0.2 #594

matt-gan opened this issue Oct 28, 2024 · 15 comments

Comments

@matt-gan
Copy link

I am developing an app using splunk-sdk 2.0.2, but AppInspect 3.8.0 reports a failure with this version. The failure is related to existing v1 search endpoints
image

The same AppInspect report shows the SDK version as 2.0.2
image

@ashwinvenkatesha
Copy link

I am seeing this issue with v2.1.0 of Splunk SDK
I am in the middle of upgrading our TA to use the latest Splunk SDK
am I supposed to update client.py
if not self.disable_v2_api: return self.post("search/v2/parser", q=query, **kwargs) return self.get("search/parser", q=query, **kwargs)

@haraksin-jpl
Copy link

haraksin-jpl commented Jan 17, 2025

This is still broken via appinspect CLI version 3.9.1 and the Splunk SDK 2.1.0

@haraksin-jpl
Copy link

I have submitted a splunk support ticket to help with this issue.

@bigboynaruto
Copy link

Hi @matt-gan , @ashwinvenkatesha , @haraksin-jpl ,

I am looking into this. By any chance, did you modify the files under lib/splunklib? For example, run a code formatter?

Would it be possible to share a sample app as a minimal reproducible example?

@haraksin-jpl
Copy link

@bigboynaruto no formatters loaded or anything. I can produce a sample app soon.

@bigboynaruto
Copy link

bigboynaruto commented Jan 21, 2025

Thanks, will be waiting for a sample package.
In the meantime, a few more questions:

  1. Does it only happen locally or via API as well?
  2. Which OS and python version do you use locally?
  3. If API has the same issue, could you make another submission?

@haraksin-jpl
Copy link

Doing this with https://github.com/manasmbellani/athena-dnssplunkapp after upgrading to the latest splunklib in the lib directory reproduces this error for me. Answers:

  1. Locally and via API as well
  2. OS is Kali Linux v2024.2, python is 3.8.6, but it also happens on python 3.11.4
  3. Yes, I made the submission and will submit the request ID to my support ticket.

@bigboynaruto
Copy link

bigboynaruto commented Jan 22, 2025

Looks like there is a difference on line 572 of splunklib/client.py, your version contains post instead of get.

$> diff client.py ~/splunk-sdk-python/splunklib/client.py
572c572
<         return self.post("search/parser", q=query, **kwargs)
---
>         return self.get("search/parser", q=query, **kwargs)

Here is the latest source code:

return self.get("search/parser", q=query, **kwargs)

Edit: updated the source code permalink.

@haraksin-jpl
Copy link

haraksin-jpl commented Jan 22, 2025

That's the old code - even when you update splunklib to the latest release it fails appinspect with the same error. I believe appinspect is just checking for non-v2 search endpoints, so it's flagging not on the post vs get but on the search/parser path without the v2 in the middle.

@bigboynaruto
Copy link

AppInspect has the entire file allowlisted, meaning, the failure should not be triggered if the contents were exactly the same as the version on Github. Otherwise, the file is not recognised.
Would it be possible to provide a reproducible package containing the latest splunklib?

@haraksin-jpl
Copy link

I see - seems like this is fixed then. I guess the fix is to just clobber the entire splunklib with the latest release. Thanks so much - we can close this and the support ticket with this resolution.

@bigboynaruto
Copy link

Glad to hear it!

@matt-gan Could you confirm if you are still experiencing the problem? If not, could you close the issue?

@arcsector
Copy link

Looks like the issue can be marked as stale

@matt-gan
Copy link
Author

matt-gan commented Jan 30, 2025

Apologies, I missed these updates in my inbox and I forgot about this as there was no update on this issue for a long time

I'll close the issue, though I haven't really used this SDK since then, so I can't confirm if the issue is resolved. If I do encounter it again, I'll create a new issue

@max-ipinfo
Copy link

max-ipinfo commented Feb 5, 2025

AppInspect has the entire file allowlisted, meaning, the failure should not be triggered if the contents were exactly the same as the version on Github. Otherwise, the file is not recognised.

@bigboynaruto thanks for the insight! That was the root-cause of the problem for me.

I just tried copying the splunklib directory from Github and after comparing the two versions, found out that they were indeed not strictly the same:

$ git diff
diff --git a/foo_app/bin/splunklib/client.py b/foo_app/bin/splunklib/client.py
index 59b31c3..ee390c9 100644
--- a/foo_app/bin/splunklib/client.py
+++ b/foo_app/bin/splunklib/client.py
@@ -779,7 +779,7 @@ class Endpoint:
         # For example, "/services/search/jobs" is using API v1
         api_version = 1
 
-        versionSearch = re.search(r'(?:servicesNS\/[^/]+\/[^/]+|services)\/[^/]+\/v(\d+)\/', path)
+        versionSearch = re.search('(?:servicesNS\/[^/]+\/[^/]+|services)\/[^/]+\/v(\d+)\/', path)
         if versionSearch:
             api_version = int(versionSearch.group(1))

I had "fixed" splunklib to take care of the following warning in AppInspect:

splunklib/client.py:782: SyntaxWarning: invalid escape sequence '\/' 
 versionSearch = re.search('(?:servicesNS\/[^/]+\/[^/]+|services)\/[^/]+\/v(\d+)\/', path)`

But I'll revert my change to get my app validating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants