OpenVAS2Report as a library¶
You can user openvas2Report as a library. It’s easy.
Configuration object¶
All the actions in package has a common configuration object called Config
. We need to configure it before to run.
This code display the Config objects and mark the parameters accepted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # --------------------------------------------------------------------------
class Config(object):
"""Program configuration"""
# ----------------------------------------------------------------------
def __init__(self, input_files, output_file, template=None, lang="en", excluded=None, scope=None):
"""
:param input_files: input file path
:type input_files: list(str)
:param output_file: output file path and name
:type output_file: str
:param template: path to template
:type template: str
:param lang: language
:type lang: str
:param excluded: path to file with excluded hosts.
:type excluded: str
:param scope: path to file with scope hosts
:type scope: str
:raises: TypeError, ValueError
|
The code is auto-explained. Then, we import them from openvas_to_report.api
:
from openvas_to_report.api import Config
config = Config(["openvas_report1.xml", "openvas_report2.xml"],
"results.xslx",
"en",
"excluded_hosts.txt",
"scope_host.txt")
Run actions¶
I called action to these tasks or functions that you also can run in command line way.
After instance the config object, we can call actions:
from openvas_to_report.api import Config, convert, crop
# Convert to Excel
config_convert = Config(["openvas_report1.xml", "openvas_report2.xml"],
"results.xslx",
"en")
convert(config)
# Crop XML file
config_convert = Config(["openvas_report1.xml", "openvas_report2.xml"],
"results_filtered.xml")
crop(config)