diff --git a/examples/github_forks/bin/github_forks.py b/examples/github_forks/bin/github_forks.py index 5ffa4e409..46b42a81b 100755 --- a/examples/github_forks/bin/github_forks.py +++ b/examples/github_forks/bin/github_forks.py @@ -130,6 +130,10 @@ def stream_events(self, inputs, ew): owner = input_item["owner"] repo_name = input_item["repo_name"] + # Hint: API auth required?, get a secret from passwords.conf + # self.service.namespace["app"] = input_item["__app"] + # api_token = self.service.storage_passwords["github_api_token"].clear_password + # Get the fork count from the Github API jsondata = _get_github_repos(owner, repo_name) fork_count = jsondata["forks_count"] diff --git a/splunklib/modularinput/utils.py b/splunklib/modularinput/utils.py index 853694a0d..3d42b6326 100644 --- a/splunklib/modularinput/utils.py +++ b/splunklib/modularinput/utils.py @@ -64,11 +64,14 @@ def parse_parameters(param_node): def parse_xml_data(parent_node, child_node_tag): data = {} for child in parent_node: + child_name = child.get("name") if child.tag == child_node_tag: if child_node_tag == "stanza": - data[child.get("name")] = {} + data[child_name] = { + "__app": child.get("app", None) + } for param in child: - data[child.get("name")][param.get("name")] = parse_parameters(param) + data[child_name][param.get("name")] = parse_parameters(param) elif "item" == parent_node.tag: - data[child.get("name")] = parse_parameters(child) + data[child_name] = parse_parameters(child) return data diff --git a/tests/modularinput/data/conf_with_2_inputs.xml b/tests/modularinput/data/conf_with_2_inputs.xml index 95c44bb2a..bcfd81204 100644 Binary files a/tests/modularinput/data/conf_with_2_inputs.xml and b/tests/modularinput/data/conf_with_2_inputs.xml differ diff --git a/tests/modularinput/data/conf_with_invalid_inputs.xml b/tests/modularinput/data/conf_with_invalid_inputs.xml index f3dd460f4..dd399dce7 100644 Binary files a/tests/modularinput/data/conf_with_invalid_inputs.xml and b/tests/modularinput/data/conf_with_invalid_inputs.xml differ diff --git a/tests/modularinput/test_input_definition.py b/tests/modularinput/test_input_definition.py index e814711dd..d0f59a04e 100644 --- a/tests/modularinput/test_input_definition.py +++ b/tests/modularinput/test_input_definition.py @@ -48,12 +48,14 @@ def test_parse_inputdef_with_two_inputs(self): "session_key": "123102983109283019283" } expectedDefinition.inputs["foobar://aaa"] = { + "__app": "search", "param1": "value1", "param2": "value2", "disabled": "0", "index": "default" } expectedDefinition.inputs["foobar://bbb"] = { + "__app": "my_app", "param1": "value11", "param2": "value22", "disabled": "0",