-
Notifications
You must be signed in to change notification settings - Fork 11
BREAKING CHANGE: remove btool and replace it with splunk.rest #441
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
Merged
hetangmodi-crest
merged 16 commits into
develop
from
breaking/change_btool_to_rest_with_backup
Jun 19, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
619a53e
feat: init commit, new function to retrieve stanzas based on rest
sgoral-splunk ae2b3ab
feat: init commit, new function to retrieve stanzas based on rest
sgoral-splunk b069211
breaking change: replace btool with splunk rest
sgoral-splunk 012e6c5
test: added splunk to sys.path
sgoral-splunk 087f2a7
test: update sys.path for splunk libraries
hetangmodi-crest 7cd7a9c
test: add splunk's module patch
sgoral-splunk dfb4aed
test: add splunk's module patch
sgoral-splunk 48eeb6e
test: mock simpleRequest
sgoral-splunk e2a5712
test: fix make splunk home
sgoral-splunk 519ad53
chore: add docs, changes after review
sgoral-splunk d291cd3
test: change procArgs for splunk cli_common
sgoral-splunk 713b3ef
test: fix integration tests, add deprecation for create_from_token
sgoral-splunk eb152ef
chore: add ImportError to getSessionKey and make_splunkhome_path
sgoral-splunk ae17291
chore: review fidings
sgoral-splunk 6214372
chore: changes after review
sgoral-splunk aeb46d8
chore: fix precommit
sgoral-splunk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Removed usage of btool command from solnlib | ||
|
||
As of version 7.0.0, the `btool` command has been removed from solnlib. Configuration stanzas and keys should now be accessed via the REST API. | ||
Additionally, the `splunkenv` module can only be used in environments where Splunk is installed, as it relies on Splunk-specific methods for making internal calls. | ||
|
||
## Session key is now mandatory in some of the functions | ||
|
||
The affected functions now require a valid `session_key` to operate correctly. While solnlib attempts to retrieve the `session_key` automatically, | ||
there are scenarios—such as within a modular input script—where this is not possible. In such cases, you must explicitly provide the `session_key` | ||
to ensure proper authorization. Affected functions are: | ||
|
||
* `get_splunk_host_info` | ||
* `get_splunkd_access_info` | ||
* `get_scheme_from_hec_settings` | ||
* `get_splunkd_uri` | ||
* `get_conf_key_value` | ||
* `get_conf_stanza` | ||
|
||
## Changed arguments in `get_conf_key_value` and `get_conf_stanza` | ||
|
||
As of version 7.0.0, the following changes have been made to the function: | ||
|
||
`get_conf_key_value` now requires 4 mandatory arguments: | ||
|
||
* `conf_name` | ||
* `stanza` | ||
* `key` | ||
* `app_name` (new) | ||
|
||
`get_conf_stanza` now requires 3 mandatory arguments: | ||
|
||
* `conf_name` | ||
* `stanza` | ||
* `app_name` (new) | ||
|
||
Both functions also accept the following optional arguments: | ||
|
||
* `session_key` - Used for authentication. If not provided, a 401 Unauthorized error may occur depending on the context. | ||
* `users` - Limits results returned by the configuration endpoint. Defaults to `nobody`. | ||
* `raw_output` - If set to `True`, the full decoded JSON response is returned. | ||
This should be enabled when `app_name` is set to the global context `(/-/)`, as the Splunk REST API may return multiple entries in that case. | ||
|
||
## The `get_session_key` function has been removed from solnlib | ||
|
||
This function relied on reading the `scheme`, `host` and `port` using the deprecated btool utility, which is no longer supported. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright 2025 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
"""This module provide settings that can be used to disable/switch features.""" | ||
|
||
use_btool = False | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would require this setting to be passed from add-on developers, or provide a way to them to override this setting if they want to use btool.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here was to make some kind of backdoor. It's not a feature that user can choose which apprach use, he will be forced to use api but in case of any issue on production env, admins will be able to temporary switch this flag.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test where we switch this flag to True and then ensure the test suite passes, thus ensuring the same behaviour when some developers make this change in prod or pre-prod env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some test for that e.g.
tests.unit.test_splunkenv.test_splunkd_uri_backdoor