Debugging Log Report

2015-06-17T00:00:00
ID DEBUG_LOG_REPORT.NASL
Type nessus
Reporter Tenable
Modified 2017-09-27T00:00:00

Description

Logs generated by other plugins are reported by this plugin. Plugin debugging must be enabled in the policy in order for this plugin to run.

                                        
                                            #TRUSTED 10d86a8661d7b8544980abd939473fb723a7c80c48f7531742cd14f9891c08f5d91b8d85e0acc66beb1df625487573faa4292c1855025f959401a6059b0fc33b350e74120383d6eba8f6c2a89d40bd71ce99d81881f530c768c86deab1ef7c12876c00efe15e537499b14c3e08b8571a65d71a720271fdf27eb277e7a92bd80035567586d4873b32c62290a09005501993c2baf309562b17f74e877b8fad6f96b7679ddd487d0cc6328aebe628bcbbf1b2a1ae980d3ac6defdef4812d75ad18c72e2a6bb817d0fd78897434699d1bbe6fd9cce39479842e5f08a41d5ad010dbdf3e963ba246787041c7a64e8ad72c72635d335666b54a7a16c84a07cd28098ea24959bd2e66705d162084660ea719449887b62261af352312763e12660b9d7ab6c676c678ec187de9540ff76d90c31c7450d78ce0f9cd4c996929ede5cc106c3a17af05a034cf50a125a1830502d25e863b32010aafbdfcbfb2116d12aece79228d45c4809002fefba80cb95d9c373a5994b0853f34a499f8ad8002ccf49dda9e6b6d5c1f9c59a289b9137428f7a1d52269a6def90cbd58c488448e9b6dd9ce378cb72045f88bf2685cadff5bd363c1a8af0f3c65aed04b02a01132b63c7eff9b74eec20d75523d5d4abff39f7ebcd5a2a1a9a633927533cb196c3c6ccc969b0f3b5f1e3f811e33f58dc1477cf204c71a70d6a1c67776d12836ff754af9ada74

#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(84239);

  script_version("1.6");
  script_set_attribute(attribute:"plugin_modification_date", value: "2017/09/27");

  script_name(english:"Debugging Log Report");
  script_summary(english:"Aggregates plugin debugging messages.");

  script_set_attribute(attribute:"synopsis", value:
"This plugin gathers the logs written by other plugins and reports
them.");
  script_set_attribute(attribute:"description", value:
"Logs generated by other plugins are reported by this plugin. Plugin
debugging must be enabled in the policy in order for this plugin
to run.");
  script_set_attribute(attribute:"solution", value:"n/a");
  script_set_attribute(attribute:"risk_factor", value:"None");

  script_set_attribute(attribute:"plugin_publication_date", value:"2015/06/17");

  script_set_attribute(attribute:"plugin_type", value:"combined");
  script_set_attribute(attribute:"agent", value:"all");
  script_set_attribute(attribute:"always_run", value:TRUE);
  script_end_attributes();

  script_category(ACT_END);
  script_family(english:"Settings");
  script_copyright(english:"This script is Copyright (C) 2015-2017 Tenable Network Security, Inc.");

  # Allow this to run for one hour, unless the timeout is already
  # set above one hour. Mostly for MDM debugging.
  if (int(get_preference("plugins_timeout")) <= 3600)
    script_timeout(3600);

  script_require_keys("global_settings/enable_plugin_debugging");
  exit(0);
}

include("misc_func.inc");
include("global_settings.inc");
include("spad_log_func.inc");

get_kb_item_or_exit("global_settings/enable_plugin_debugging");

#increasing the memory limits for MDM debug scans which can be rather large
if (defined_func("set_mem_limits"))
  set_mem_limits(max_alloc_size:256*1024*1024, max_program_size:256*1024*1024);

logs = spad_log_get_report_attachments();
if(empty_or_null(logs))
  exit(0,"No log information to report.");

# Dump directly to plug-in output for SC / older versions
if(!defined_func("nasl_level") || nasl_level() < 5200 ||
   !isnull(get_preference("sc_version"))
)
{
  report = 'The following plugin debug log(s) have been appended:\n\n';
  foreach log (logs)
  {
    report += '=====================================================\n';
    report += 'Start log : '+log['name']+'\n';
    report += '=====================================================\n';
    report += log['value'];
    report += '=====================================================\n';
    report += 'End log : '+log['name']+'\n';
    report += '=====================================================\n';
  }
  security_note(port:0,extra:report);
}
else
{
  security_report_with_attachments(
    port        : 0,
    level       : 0,
    extra       : "Plugin debug log(s) have been attached.",
    attachments : logs
  );
}