Skip to content

Modular Input: Error during ValidationDefinition/InputDefinition when no value for parameter is passed #198

Closed
@jrobins04

Description

@jrobins04

I am able to reproduce this using v1.9.1. This issue happens when the user provides no value for a modular input parameter.
https://github.com/splunk/splunk-sdk-java/blob/master/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java textInNode() line number 38:

static String textInNode(Node node, String errorMessage) throws MalformedDataException {
        Node child = node.getFirstChild();
        if (child.getNodeType() != Node.TEXT_NODE) {
            throw new MalformedDataException(errorMessage);
        } else {
            return ((Text)child).getData();
        }
    }

Here, no null check is performed for the child variable. In case when the modular input parameter has no value, child will be null and child.getNodeType() leads to null pointer.

Sample input to --validate-arguments that triggers the error:

<?xml version="1.0" encoding="utf-16"?>
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <server_host>tiny</server_host>
    <server_uri>https://127.0.0.1:8089</server_uri>
    <checkpoint_dir>/opt/splunk/var/lib/splunk/modinputs</checkpoint_dir>
    <session_key>123102983109283019283</session_key>
    <!-- The items element only ever contains one item element -->
    <item name="aaa">
        <param name="param1">value1</param>
        <param name="param_bug"></param>
        <param name="disabled">0</param>
        <param name="index">default</param>
        <param_list name="multiValue">
            <value>value1</value>
            <value>value2</value>
        </param_list>
        <param_list name="multiValue2">
            <value>value3</value>
            <value>value4</value>
        </param_list>
    </item>
</items>

In the above example param_bug has no value (user did not input any value to the modular input parameter), this causes child to be null in the textInNode() method.

Please let me know if you need any other information regarding this issue.

Similar issue was created previously: #122 back in March 2018, but it was closed stating that it could not reproduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions