本文整理汇总了Python中plugin.Plugin.check_category方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.check_category方法的具体用法?Python Plugin.check_category怎么用?Python Plugin.check_category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin.Plugin
的用法示例。
在下文中一共展示了Plugin.check_category方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __run_plugin__
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import check_category [as 别名]
def __run_plugin__ (self, filename, verbose, raw):
try:
plugin = Plugin (filename, self.__ossim_config, self.__severity_list, verbose, raw)
except (PluginError, PluginConfigParserError) as e:
if verbose > 0:
print ''
Output.warning (e.msg)
else:
self.__summary.append ({'plugin': e.plugin, 'warning': e.msg})
except Exception as e:
print ''
Output.error ('Unknown error parsing plugin "%s": %s' % (filename, str(e)))
else:
if (plugin.get_enable()) and (plugin.get_checks_len() > 0) and (plugin.check_category (self.__category_list)):
self.__summary.append (plugin.run ())
else:
del plugin
示例2: __run_plugin__
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import check_category [as 别名]
def __run_plugin__(self, filename, verbose, raw):
# Parse the plugin configuration file.
# Check if file exists
if not path.isfile(filename):
msg = 'Plugin file does not exist: %s' % filename
self.__generate_blocked_output(config_file=None,
plugin=filename,
plugin_data={},
sections=[],
error_msg=msg)
return
# Check for file extension.
if not filename.endswith('.plg'):
msg = 'File extension is not .plg'
self.__generate_blocked_output(config_file=None,
plugin=filename,
plugin_data={},
sections=[],
error_msg=msg)
return
# Check for db connections and some other basic param config
cfg_msg = ''
for key in self.__successful_config.keys():
if not self.__successful_config[key]['result']:
cfg_msg = ';'.join([cfg_msg, self.__successful_config[key]['error']])
if cfg_msg != '':
self.__generate_blocked_output(config_file=None,
plugin=filename,
plugin_data={},
sections=[],
error_msg=cfg_msg)
config_file = None
try:
config_file = self.__load_plugin_file(filename)
except PluginError as e:
self.__generate_blocked_output(config_file=None,
plugin=e.plugin,
plugin_data={},
sections=[],
error_msg=e.msg)
return
# Fill the Plugin Object
if config_file:
try:
plugin = Plugin(filename,
config_file,
self.__alienvault_config,
self.__severity_list,
self.__appliance_type_list,
self.__ignore_dummy_platform,
verbose,
raw)
if (plugin.get_checks_len() > 0) and (plugin.check_category(self.__category_list)):
result = plugin.run()
self.__in_strike_zone &= result.get('strike_zone', True)
self.__summary[plugin.get_name()] = result
else:
del plugin
except (PluginError, PluginConfigParserError, CheckError) as e:
if verbose > 0:
Output.warning(e.msg)
sections = []
try:
sections = config_file.sections()
except Exception:
pass
self.__generate_blocked_output(config_file=config_file,
plugin=e.plugin,
plugin_data=e.kwargs,
sections=sections,
error_msg=e.msg)
except KeyError, msg:
Output.error('Unknown error running plugin "%s": %s' % (filename, str(msg)))