Tanium Hygiene Assessment Tool (THAT) Main workflow module.
tanium_hat.main.
Main
[source]¶Bases: object
Main workflow class for THAT.
Must call tanium_hat.main.Main.start()
in order to start the workflow.
Examples
>>> # initialize the Main class
>>> main = that.main.Main()
>>> # use the default configuration file
>>> main.start()
>>> # or, use a specific configuration file
>>> main.start(config_file="my_config.ini")
CONFIG
¶dict –
tanium_hat.main.Main.load_config_file()
PCONFIG
¶dict –
tanium_hat.main.Main.parse_config_contents()
LOG
¶LH_CON
¶LH_FILE
¶logging.handlers.RotatingFileHandler
–
tanium_hat.main.Main.add_file_logging()
ERRORS
¶dict –
tanium_hat.main.Main.err_handler()
EXCEPTIONS
¶dict –
tanium_hat.main.Main.err_handler()
WEQUESTS
¶tanium_kit.wequests.Wequests
–
add_file_logging
()[source]¶Add a file log handler to the root logger that gets DEBUG and above log messages.
tanium_hat.main.Main.LH_FILE
with the file log handlercheck_internet
()[source]¶Check to see if an internet connection is available.
Uses tanium_hat.constants.INTERNET_TEST_URL
as the url to use for checking internet connectivity.
Returns: | ret –
|
---|---|
Return type: | bool |
check_pytan_admin
(role_name=u'Administrator')[source]¶Check if the current pytan user has the Administrator role in Tanium.
tanium_hat.main.Main.get_user_obj()
to get the user objectcollect_analyze_results
()[source]¶Collect analayze_data results from plugins.
tanium_hat.main.Main.PCONFIG
under the key “config”.tanium_hat.plugin.Plugin.ANALYZE_RESULTS
under the key “plugin_name” for each enabled plugin.Returns: | ret –
|
---|---|
Return type: | dict |
collect_internet_results
()[source]¶Collect get_internet_data results from plugins.
tanium_hat.plugin.Plugin.GID_RESULTS
into ret.Returns: | ret –
|
---|---|
Return type: | dict |
collect_tanium_results
()[source]¶Collect get_tanium_data results from plugins.
tanium_hat.plugin.Plugin.GTD_RESULTS
into ret.Returns: | ret –
|
---|---|
Return type: | list |
config_check_abs
(value, section, entry, **kwargs)[source]¶Pre-pend value if it is not absolute.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_bool
(value, section, entry, **kwargs)[source]¶Convert value into boolean.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_crypt
(value, section, entry, **kwargs)[source]¶Check if value is cryptable.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_empty
(value, section, entry, **kwargs)[source]¶Check if value is empty.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_int
(value, section, entry, **kwargs)[source]¶Convert value into integer.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_tmpl
(value, section, entry, **kwargs)[source]¶Templatize value.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
config_check_value
(section, entry, **kwargs)[source]¶Check if value is defined in config file.
os.environ
for THAT_ENTRY and uses that as value if definedtanium_hat.main.Main.CONFIG
is defined/is a dict, asks user for value if nottanium_hat.main.Main.CONFIG
for entry and uses that as value if foundParameters: | |
---|---|
Returns: | ret –
|
Return type: |
config_tmpl
(value, src, quiet=False)[source]¶Templatize a value.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
err_handler
(err_str, src=None)[source]¶Error handler.
tanium_kit.tools.orig_tb()
to get the current exception string, if anytanium_hat.main.Main.EXCEPTIONS
tanium_hat.main.Main.ERRORS
Parameters: | err_str (str ) –
|
---|
get_config_entry
(section, entry, **kwargs)[source]¶Get the value of an entry from self.CONFIG.
If value not supplied or is not the right type, prompt user for value.
Parameters: |
|
---|---|
Returns: | value –
|
Return type: |
|
get_enabled_plugins
()[source]¶Determine which plugins to enable.
plugin_modules
in tanium_hat.main.Main.PCONFIG
to check config/ask user if the plugin is enabledget_handler
()[source]¶Get a PyTan Handler.
Returns: | ret –
|
---|---|
Return type: | pytan.handler.Handler |
get_local_plugins
()[source]¶Find the plugins that are available locally.
tanium_hat.constants.PLUGINS_FOUND
to find matching pluginstanium_hat.main.Main.load_module()
to load each plugin that is foundtanium_hat.main.Main.load_module()
to reload newer pluginsplugin_modules
in tanium_hat.main.Main.PCONFIG
with plugin name -> plugin module mappingget_module_json
(name, url)[source]¶Get json for a module from the Tanium platform server using PyTan.
get_plugin_option
(option_name, pname, pmod)[source]¶Get a plugin option and templatize it for a given plugin.
tanium_hat.options.PLUGINS
tanium_hat.main.Main.get_plugin_tmpl()
to build a dict for use in templatingParameters: |
|
---|---|
Returns: | ret –
|
Return type: |
get_plugin_tmpl
(pname, pmod)[source]¶Build a dict to use in templating plugin options.
Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
get_user_obj
()[source]¶Get the user object for the current user.
tanium_kit.pytanx.get_user_obj()
to get the user objectReturns: | user_obj –
|
---|---|
Return type: | taniumpy.object_types.user.User |
jump_ship
(lvl=99)[source]¶Method called to exit due to error.
Parameters: | lvl (int , optional) –
|
---|
keep_going
(m)[source]¶Ask the user if they wish to keep going using prompt m
.
Exit if they say no.
Parameters: | m (str ) –
|
---|
load_config_file
(path)[source]¶Use IniReader() to turn ini file at path
into a dictionary.
Parameters: | path (str ) –
|
---|---|
Returns: | ret –
|
Return type: | dict |
load_enabled_plugins
()[source]¶Load enabled plugins.
plugin_modules
in tanium_hat.main.Main.PCONFIG
for enabled pluginstanium_hat.plugin.Plugin
object for each enabled pluginplugins
in tanium_hat.main.Main.PCONFIG
with plugin name -> plugin object mappingload_layout_def
()[source]¶Load the python layout definition file.
layout_File
from tanium_hat.main.Main.PCONFIG
tanium_hat.main.Main.load_module()
to load the moduletanium_hat.main.Main.load_module()
to reload any new layout filetanium_hat.pptx_builder.val_layouts()
to validate the layouts in the layout definition fileload_layout_pptx
()[source]¶Load the PPTX file referenced by the layout definition file.
layout_mod.PPTX_INPUT_FILE
from tanium_hat.main.Main.PCONFIG
load_module
(path, mod_type, mod_attrs=[])[source]¶Load a python file into a module.
imp.load_source()
to read the file at runtime and load it in as a python module.Parameters: |
|
---|---|
Returns: | ret –
|
Return type: |
makedir
(path)[source]¶Make a directory and all leading directories as needed.
Parameters: | path (str ) –
|
---|
mode_analyze_data
()[source]¶Run analyze_data for plugins, collect results, create PPTX file.
tanium_hat.main.Main.run_plugins()
to call tanium_hat.plugin.Plugin.analyze_data()
on every plugintanium_hat.main.Main.collect_analyze_results()
to get the results of analyze_data for all pluginstanium_hat.pptx_builder.PptxBuilder
to create the PPTX file.mode_get_internet_data
()[source]¶Run get_internet_data for plugins and write results.
tanium_hat.main.Main.run_plugins()
to call tanium_hat.plugin.Plugin.get_internet_data()
on every plugintanium_hat.main.Main.collect_internet_results()
to get the results of get_internet_data for all pluginstanium_hat.main.Main.write_csv()
to write results to tanium_hat.constants.INTERNET_FILE_NAME
in data_pathmode_get_tanium_data
()[source]¶Run get_tanium_data for plugins and write results.
tanium_hat.main.Main.get_handler()
to get a PyTan handler connection to Tanium.tanium_hat.main.Main.run_plugins()
to call tanium_hat.plugin.Plugin.get_tanium_data()
on every plugintanium_hat.main.Main.collect_tanium_results()
to get the results of get_tanium_data for all pluginstanium_hat.main.Main.write_csv()
to write results to that_stats.csv in data_pathtanium_hat.main.Main.write_json_files()
to write json pages from Tanium.parse_config_analyze
()[source]¶Parse options that are only asked if the user supplied yes to analyze_data.
analyze_data
is False in tanium_hat.main.Main.PCONFIG
tanium_hat.options.ANALYZE
to determine base options to search for/asktanium_hat.main.Main.load_layout_def()
to load the python layout definition file as a moduletanium_hat.main.Main.load_layout_pptx()
to load the PPTX file referenced in the python layout definition fileparse_config_base
()[source]¶Parse base options that are always asked.
tanium_hat.options.BASE
to determine base options to search for/askparse_config_contents
()[source]¶Read the tanium_hat.main.Main.CONFIG
dictionary for keys and prompt user for missing values.
tanium_hat.main.Main.PCONFIG
with the output of tanium_hat.main.base_pconfig()
tanium_hat.main.Main.parse_config_base()
to parse the config for base optionstanium_hat.main.Main.parse_config_plugins()
to parse the config for plugin optionstanium_hat.main.Main.parse_config_analyze()
to parse the config for analyze data optionstanium_hat.main.Main.parse_config_tanium()
to parse the config for get tanium data optionsparse_config_plugins
()[source]¶Parse options that are asked for plugins.
tanium_hat.main.Main.get_local_plugins()
to load locally available pluginstanium_hat.main.Main.get_enabled_plugins()
to check which plugins get loadedtanium_hat.main.Main.load_enabled_plugins()
to load enabled pluginsparse_config_tanium
()[source]¶Parse options that are only asked if the user supplied yes to get_tanium_data.
get_tanium_data
is False in tanium_hat.main.Main.PCONFIG
tanium_hat.options.TANIUM
to determine base options to search for/askpre_flight
()[source]¶Read configuration file and start file logging.
tanium_hat.main.Main.CONFIG
with the dict parsed from tanium_hat.main.Main.CONFIG_FILE
tanium_hat.main.Main.add_file_logging()
to setup file loggingtanium_hat.main.Main.parse_config_contents()
to parse the configurationregister_zipper
()[source]¶Create a zip file of the data_path when python script exits.
tanium_kit.zipper.mkzip()
to create a zip file of the data_pathatexit.register()
to register the zipper function to run when this script reaches the end of execution (due to error or not)run_plugin
(mode, plugin_name, plugin_obj)[source]¶Run a plugin using mode.
Parameters: |
|
---|
run_plugins
(mode)[source]¶Run all plugins using mode.
tanium_hat.main.Main.sorted_plugins()
to get a list of plugins sorted by priority ordertanium_hat.main.Main.run_plugin()
to run the mode for for pluginParameters: | mode (str ) –
|
---|
save_file
(out, filename, path, prompt=False, binary=False, **kwargs)[source]¶Save a file in binary or text mode.
Parameters: |
|
---|---|
Returns: | file_path –
|
Return type: |
sorted_plugins
(d=1000)[source]¶Sort the plugins based on priority.
tanium_hat.plugin.Plugin.get_order()
to get the plugin priorityParameters: | d (int , optional) –
|
---|---|
Returns: | ret –
|
Return type: | list |
start
(**kwargs)[source]¶Main workflow entry point for THAT.
Parameters: | config_file (str , optional) –
|
---|
track_items
(name, obj, attr)[source]¶Pull items from object and add them into this object by name.
Parameters: |
---|
valid_tmpl_keys
()[source]¶Produce a list of valid template keys.
Returns: | ret –
|
---|---|
Return type: | str |
write_csv
(results, path, **kwargs)[source]¶Write a csv file.
tanium_kit.excel_writer.ExcelWriter
to pre-parse a list of dicts for writing to CSVParameters: | |
---|---|
Returns: | ret –
|
Return type: |
|
write_file
(path, out)[source]¶Write a file.
data_path
from tanium_hat.main.Main.PCONFIG
Parameters: |
---|
write_json_files
()[source]¶Write JSON files to the data_path.
tanium_hat.main.Main.get_info_json()
to fetch info.jsontanium_hat.main.Main.write_file()
to write info.json to data_pathtanium_hat.constants.MODULE_JSON_ITEMS
, get the json from the url using tanium_hat.main.Main.get_module_json()
, and write the json using tanium_hat.main.Main.write_file()
to data_pathtanium_hat.main.
base_pconfig
()[source]¶Create a baseline PCONFIG (parsed config) dict.
tanium_hat.constants
tanium_hat.version.TOOL_DICT
now
time formatted string from tanium_hat.constants.NOW_FORMAT
prepared_on
time formatted string from tanium_hat.constants.PREPARED_ON_FORMAT
that_version
tanium_hat.version.__version__
platform
output from platform.platform()
python_version
output from sys.version
pathsep
output from os.sep
Returns: | ret –
|
---|---|
Return type: | dict |