irods / irods_rule_engine_plugin_audit_amqp

BSD 3-Clause "New" or "Revised" License
2 stars 14 forks source link

Uncaught exception when "test_mode" is not configured #98

Closed alanking closed 2 years ago

alanking commented 2 years ago

Bug Report

Version, OS and Version

4.3.0.0 (server version 4.3.0), ubuntu:18.04

What did you try to do?

Configure the audit plugin according to the advanced training slide deck:

        "rule_engines": [
            {             
               "instance_name": "irods_rule_engine_plugin-irods_rule_language-instance",
                ...
                ...
                "shared_memory_instance": "irods_rule_language_rule_engine"
            },
            {
                "instance_name": "irods_rule_engine_plugin-audit_amqp-instance",
                "plugin_name": "irods_rule_engine_plugin-audit_amqp",
                "plugin_specific_configuration" : {
                     "amqp_location" : "ANONYMOUS@localhost:5672",
                     "amqp_options" : "",
                     "amqp_topic" : "audit_messages",
                     "pep_regex_to_match" : "audit_.*"
                 }
           },

           {
                "instance_name": "irods_rule_engine_plugin-cpp_default_policy-instance",
...
...
    "rule_engine_namespaces": [
        "", 
        "audit_"
    ], 

Expected behavior

Everything works

Observed behavior (including steps to reproduce, if applicable)

ils is now failing because the agent disappears. This is because the configuration in 4.3.0 server is now fetched/set through the nlohmann::json library, but no exception handling was added for this in this plugin. Here is the offending line: https://github.com/irods/irods_rule_engine_plugin_audit_amqp/blob/ffe953a56b330d8c635d2f28f6e7669ad43d1457/libirods_rule_engine_plugin-audit_amqp.cpp#L83

If "test_mode" is configured, then "log_path_prefix" must also be configured for the same reason.

Three things need to happen here:

  1. Add exception handling for nlohmann::json and std::exception here to avoid this and other uncaught exceptions.
  2. Gracefully continue when "test_mode" and "log_path_prefix" are not found in the configuration because these are not required for the plugin to work properly.
  3. Add a test which does not use "test_mode". This only got past our release process because the test infrastructure always configures "test_mode" and "log_path_prefix".