Skip to content

Commit

Permalink
Correct URL, some code optimalisations
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGroundZero committed Apr 8, 2019
1 parent e08dd52 commit ca74209
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 60 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS to Report: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
#
# Copyright
# This project is based on OpenVAS2Report (https://github.com/cr0hn/openvas_to_report) (c) 2015, cr0hn<-AT->cr0hn.com
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ I also plan on adding more functionality as I feel the need for it, or receive r

If you feel like I'd need to implement a new feature, rewrite some code, fix a bug, ...
hit me up on `Twitter <https://twitter.com/DezeStijn>`_
or file an issue on `GitHub <https://github.com/TheGroundZero/openvas_to_report>`_.
or file an issue on `GitHub <https://github.com/TheGroundZero/openvasreporting>`_.

TODO list
---------
Expand Down
2 changes: 1 addition & 1 deletion openvasreporting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS to Report: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
#
# Copyright
# This project is based on OpenVAS2Report (https://github.com/cr0hn/openvas_to_report) (c) 2015, cr0hn<-AT->cr0hn.com
Expand Down
2 changes: 1 addition & 1 deletion openvasreporting/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
from openvasreporting.openvasreporting import main

__author__ = 'TheGroundZero (https://github.com/TheGroundZero)'
Expand Down
2 changes: 1 addition & 1 deletion openvasreporting/libs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
2 changes: 1 addition & 1 deletion openvasreporting/libs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting

"""This file contains data structures"""

Expand Down
2 changes: 1 addition & 1 deletion openvasreporting/libs/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting

import re
from collections import Counter
Expand Down
68 changes: 30 additions & 38 deletions openvasreporting/libs/parsed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting

"""This file contains data structures"""

Expand Down Expand Up @@ -80,15 +80,11 @@ def string2port(info):
return Port(number, protocol)

def __eq__(self, other):
if not isinstance(other, Port):
return False

if other.number != self.number:
return False
if other.protocol != self.protocol:
return False

return True
return (
isinstance(other, Port) and
other.number == self.number and
other.protocol == self.protocol
)


class Host(object):
Expand All @@ -113,15 +109,11 @@ def __init__(self, ip, host_name=""):
self.host_name = host_name

def __eq__(self, other):
if not isinstance(other, Host):
return False

if other.ip != self.ip:
return False
if other.host_name != self.host_name:
return False

return True
return (
isinstance(other, Host) and
other.ip == self.ip and
other.host_name == self.host_name
)


class Vulnerability(object):
Expand Down Expand Up @@ -238,28 +230,28 @@ def __eq__(self, other):
if not isinstance(other, Vulnerability):
raise TypeError("Expected Vulnerability, got '{}' instead".format(type(other)))

if other.cves != self.cves:
return False
if other.threat != self.threat:
return False
if other.name != self.name:
return False
if other.cvss != self.cvss:
return False
if other.description != self.description:
return False
if other.vuln_id != self.vuln_id:
return False
if other.level != self.level:
return False
if other.references != self.references:
if (
other.vuln_id != self.vuln_id or
other.name != self.name or
other.cves != self.cves or
other.cvss != self.cvss or
other.level != self.level or
other.description != self.description or
other.detect != self.detect or
other.insight != self.insight or
other.impact != self.impact or
other.affected != self.affected or
other.solution != self.solution or
other.solution_type != self.solution_type or
other.references != self.references or
other.threat != self.threat or
other.family != self.family
):
return False

for host, port in self.hosts:
for o_host, o_port in other.hosts:
if o_host == host and o_port == port:
break
else:
return False
if o_host != host or o_port != port:
return False

return True
2 changes: 1 addition & 1 deletion openvasreporting/libs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
import re
import sys
import logging
Expand Down
44 changes: 33 additions & 11 deletions openvasreporting/openvasreporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting

import argparse

Expand Down Expand Up @@ -57,17 +57,9 @@ def create_config(input_files, output_file="openvas_report", min_lvl="none", fil
:rtype: Config
"""

min_lvl = min_lvl.lower()[0]
min_lvl = check_level(min_lvl.lower()[0])

if min_lvl in Config.levels().keys():
min_lvl = Config.levels()[min_lvl]
else:
raise ValueError("Invalid value for level parameter, \
must be one of: c[ritical], h[igh], m[edium], l[low], n[one]")

if filetype not in exporters().keys():
raise ValueError("Filetype not supported, got {}, expecting one of {}".format(filetype,
exporters().keys()))
check_filetype(filetype)

if template is not None:
return Config(input_files, output_file, min_lvl, filetype, template)
Expand All @@ -94,3 +86,33 @@ def convert(config):
openvas_info = openvas_parser(config.input_files, config.min_level)

exporters()[config.filetype](openvas_info, config.template, config.output_file)


def check_level(min_lvl):
"""
Check if min_lvl is a correct level
:param min_lvl: min_lvl
:return: min_lvl
:raises: ValueError
"""
if min_lvl in Config.levels().keys():
return Config.levels()[min_lvl]
else:
raise ValueError("Invalid value for level parameter, \
must be one of: c[ritical], h[igh], m[edium], l[low], n[one]")


def check_filetype(filetype):
"""
Check if filetype is a correct filetype
:param filetype: filetype
:return:
:raises: ValueError
"""
if filetype not in exporters().keys():
raise ValueError("Filetype not supported, got {}, expecting one of {}".format(filetype,
exporters().keys()))
2 changes: 1 addition & 1 deletion openvasreporting/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
#
# Project name: OpenVAS Reporting: A tool to convert OpenVAS XML reports into Excel files.
# Project URL: https://github.com/TheGroundZero/openvas_to_report
# Project URL: https://github.com/TheGroundZero/openvasreporting
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup(
name='OpenVAS Reporting',
description='A tool to convert OpenVAS XML into reports.',
version='1.4.2',
version='1.4.3',
long_description=long_description,
long_description_content_type='text/markdown',
author='TheGroundZero (@DezeStijn)',
Expand All @@ -24,7 +24,7 @@
project_urls={
'Source Code': 'https://github.com/TheGroundZero/openvasreporting',
'Documentation': 'https://openvas-reporting.stijncrevits.be',
'Issues': 'https://github.com/TheGroundZero/openvas_to_report/issues/',
'Issues': 'https://github.com/TheGroundZero/openvasreporting/issues/',
},
license='GPL-3.0-or-later',
keywords='OpenVAS OpenVAS-reports Excel xlsxwriter xlsx reporting reports report',
Expand Down

0 comments on commit ca74209

Please sign in to comment.