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

feat: splunk hec token handling #803

Closed

Conversation

mkolasinski-splunk
Copy link
Contributor

@mkolasinski-splunk mkolasinski-splunk commented Nov 26, 2023

  • add self handling for HEC token - PSA now discovers or creates HEC token if it is missing and passes to other deployments. For backward compatibility, if splunk-hec-token is provided via CL argument, this approach is not being used
  • splunk-hec-token CLI argument no longer has default value
  • add pytest_exception_interact in plugin.py to exit entire test suite in case of Exception occurence

@mkolasinski-splunk mkolasinski-splunk force-pushed the feat/splunk-hec-token-handling branch from 97cf053 to c123fca Compare November 26, 2023 00:57
@mkolasinski-splunk mkolasinski-splunk force-pushed the feat/splunk-hec-token-handling branch from 60b40bb to 93fdbd7 Compare November 26, 2023 18:49
Copy link

semgrep-app bot commented Nov 26, 2023

Semgrep found 2 disabled-cert-validation findings:

Certificate verification has been explicitly disabled. This
permits insecure connections to insecure servers. Re-enable
certification validation.

Ignore this finding from disabled-cert-validation.

@mkolasinski-splunk mkolasinski-splunk changed the title faet: splunk hec token handling feat: splunk hec token handling Nov 26, 2023
@mkolasinski-splunk mkolasinski-splunk force-pushed the feat/splunk-hec-token-handling branch from 5d8beb4 to 48cb591 Compare November 26, 2023 19:15
@mkolasinski-splunk mkolasinski-splunk force-pushed the feat/splunk-hec-token-handling branch from 2f24137 to 2ffb7d7 Compare November 27, 2023 09:54
@mkolasinski-splunk mkolasinski-splunk changed the base branch from main to develop November 27, 2023 10:10
@mkolasinski-splunk mkolasinski-splunk marked this pull request as ready for review November 27, 2023 10:10
@@ -323,6 +324,13 @@ def pytest_addoption(parser):
help="Should execute test or not (True|False)",
default="True",
)
group.addoption(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you move this line below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just by mistake, restoring previous order now.

if is_responsive_splunk(splunk_info) and is_responsive_hec(
request, splunk_info
):
sleep(20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 20 seconds sleeping if both conditions are okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if both conditions are met, as far as I observed, docker container is not fully initialized yet, it performs still few steps, including cleanup of existing HEC tokens. This sleep assures that we don't perform any actions until docker container is fully spinned. I didn't figure out a better solution (I decided not to parse container logs waiting for "Ansible playbook complete" as I don't think it's needed here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may lead to flaky tests, what if the CI is slower than we expect?

Why can't we improve the already existing code and add 1 more check to lambda?

pytest_splunk_addon/splunk.py Show resolved Hide resolved
pytest_splunk_addon/plugin.py Show resolved Hide resolved
pytest_splunk_addon/splunk.py Show resolved Hide resolved
Copy link
Member

@artemrys artemrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am honestly not sure if we should proceed with this approach. I do not see a huge value in creating token dynamically, I think using the existing option is simpler and less error prone.

I would suggest just placing a deprecation warning message when default HEC token is used (if there is a way to do that), if it is not possible then put a deprecation notice into the help message for HEC token option like you already did.


RESPONSIVE_SPLUNK_TIMEOUT = 300 # seconds
# Default splunk HEC token name, matching token name when token created via env variable for CI purposes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change it accidentally, it breaks the CI?

@@ -109,8 +118,7 @@ def pytest_addoption(parser):
"--splunk-hec-token",
action="store",
dest="splunk_hec_token",
default="9b741d03-43e9-4164-908b-e09102327d22",
help='Splunk HTTP event collector token. default is "9b741d03-43e9-4164-908b-e09102327d22" If an external forwarder is used provide HEC token of forwarder.',
help="Deprecated option. Splunk HTTP event collector token. If an external forwarder is used provide HEC token of forwarder.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a default value it is a breaking change?

if is_responsive_splunk(splunk_info) and is_responsive_hec(
request, splunk_info
):
sleep(20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may lead to flaky tests, what if the CI is slower than we expect?

Why can't we improve the already existing code and add 1 more check to lambda?

@artemrys
Copy link
Member

@mkolasinski-splunk we don't need this PR anymore?

@artemrys artemrys marked this pull request as draft January 3, 2024 16:13
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2024
@mkolasinski-splunk mkolasinski-splunk deleted the feat/splunk-hec-token-handling branch August 28, 2024 10:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants