コード例 #1
0
def process(output: AgentRawData) -> AgentRawData:
    try:
        while True:
            i = output.find(b'%{')
            if i == -1:
                break
            e = output.find(b'}', i)
            if e == -1:
                break
            # 2.1: Disabled this feature because of the eval() call below. To make this secure it
            # would need some rework. It is a not documented feature and was rarely used. There is a
            # good chance that we can remove this feature. To have the chance to re-enable it
            # quickly, we leave everything in place for now. In case no one complains about the
            # missing feature, remove it with 2.3.
            raise MKGeneralException(
                "Sorry, the agent simulator functions %{...} can not be used anymore. "
                "They have been removed for security reasons. In case you need them, please let "
                "us know.")
            #simfunc = output[i + 2:e]
            #replacement = str(eval(b"agentsim_" + simfunc)).encode("utf-8")  # nosec
            #output = AgentRawData(output[:i] + replacement + output[e + 1:])
    except MKGeneralException:
        raise
    except Exception:
        if cmk.utils.debug.enabled():
            raise

    return output
コード例 #2
0
def process(output: AgentRawData) -> AgentRawData:
    try:
        while True:
            i = output.find(b'%{')
            if i == -1:
                break
            e = output.find(b'}', i)
            if e == -1:
                break
            simfunc = output[i + 2:e]
            replacement = str(eval(b"agentsim_" + simfunc)).encode(
                "utf-8")  # nosec
            output = AgentRawData(output[:i] + replacement + output[e + 1:])
    except Exception as e:
        if cmk.utils.debug.enabled():
            raise

    return output