splunk / addonfactory-solutions-library-python

SDK for Developing Solutions in Splunk Enterprise with Python
https://splunk.github.io/addonfactory-solutions-library-python/
Apache License 2.0
17 stars 7 forks source link

fix: standalone HECEventwriter #380

Closed zugf closed 3 months ago

zugf commented 4 months ago

When create_from_token() is invoked, it triggers the HECEventWriter constructor with scheme, host, and port set to None. This leads to a get_splunkd_access_info() call, which throws an exception if the HEC URI doesn’t reference the local machine. As this call is unnecessary in such cases, its invocation has been relocated within the if-statement

github-actions[bot] commented 4 months ago

CLA Assistant Lite bot All contributors have signed the COC ✍️ ✅
Posted by the CLA Assistant Lite bot.

zugf commented 4 months ago

Where can I find the CLA document and how do I sign it?

artemrys commented 4 months ago

@zugf thanks for the proposed fix!

you can find CLA here - CLA.md and Code of Conduct here - CODE_OF_CONDUCT.md.

in order to sign CLA and CoC - please post a comment "I have read the CLA Document and I hereby accept the CLA" and then another comment "I have read the Code of Conduct and I hereby accept the Terms"

zugf commented 4 months ago

I have read the Code of Conduct and I hereby accept the Terms

zugf commented 4 months ago

I have read the CLA Document and I hereby accept the CLA

hetangmodi-crest commented 4 months ago

hmm, the update makes sense. Can you please add unit test case for it as well so we can capture this behaviour?

artemrys commented 4 months ago

@zugf we can help you with tests if you don't feel comfortable with approaching them yourself :)

zugf commented 4 months ago

To avoid code duplication, I’ve refactored test_hec_event_writer into a parametrized test.

The last 5 lines of the code have been extracted into a separate unit test.

The behaviour will be tested by the last parameter set (create_hec_event_writercreate_from_tokenexternal_host, False).

This simulates a machine without a Splunk installation that uses the HEC to push events to a different machine. Existing monkey patch functionality is used to unset SPLUNK_HOME.

hetangmodi-crest commented 4 months ago

@zugf , can you please sign the commits, and we can proceed to merge the changes (signing commits guide).

zugf commented 4 months ago

Commits are signed. Have a good weekend Florian

srv-rr-github-token commented 3 months ago

:tada: This issue has been resolved in version 5.1.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: