diff --git a/CHANGELOG.md b/CHANGELOG.md index 6236ee98..5e6a6d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [#278](https://github.com/greenbone/ospd/pull/278) [#279](https://github.com/greenbone/ospd/pull/279) [#281](https://github.com/greenbone/ospd/pull/281) +- Extend results with optional argument URI [#282](https://github.com/greenbone/ospd/pull/282) ### Changes - Modify __init__() method and use new syntax for super(). [#186](https://github.com/greenbone/ospd/pull/186) diff --git a/ospd/ospd.py b/ospd/ospd.py index 0aa1ac05..1367c3f1 100644 --- a/ospd/ospd.py +++ b/ospd/ospd.py @@ -1440,6 +1440,7 @@ def add_scan_log( port: str = '', test_id: str = '', qod: str = '', + uri: str = '', ) -> None: """ Adds a log result to scan_id scan. """ @@ -1454,6 +1455,7 @@ def add_scan_log( test_id, '0.0', qod, + uri, ) def add_scan_error( @@ -1465,6 +1467,7 @@ def add_scan_error( value: str = '', port: str = '', test_id='', + uri: str = '', ) -> None: """ Adds an error result to scan_id scan. """ self.scan_collection.add_result( @@ -1476,6 +1479,7 @@ def add_scan_error( value, port, test_id, + uri, ) def add_scan_host_detail( @@ -1485,10 +1489,11 @@ def add_scan_host_detail( hostname: str = '', name: str = '', value: str = '', + uri: str = '', ) -> None: """ Adds a host detail result to scan_id scan. """ self.scan_collection.add_result( - scan_id, ResultType.HOST_DETAIL, host, hostname, name, value + scan_id, ResultType.HOST_DETAIL, host, hostname, name, value, uri ) def add_scan_alarm( @@ -1502,6 +1507,7 @@ def add_scan_alarm( test_id: str = '', severity: str = '', qod: str = '', + uri: str = '', ) -> None: """ Adds an alarm result to scan_id scan. """ self.scan_collection.add_result( @@ -1515,4 +1521,5 @@ def add_scan_alarm( test_id, severity, qod, + uri, ) diff --git a/ospd/resultlist.py b/ospd/resultlist.py index 074af991..b9962e0d 100644 --- a/ospd/resultlist.py +++ b/ospd/resultlist.py @@ -40,10 +40,11 @@ def add_scan_host_detail_to_list( hostname: str = '', name: str = '', value: str = '', + uri: str = '', ) -> None: """ Adds a host detail result to result list. """ self.add_result_to_list( - ResultType.HOST_DETAIL, host, hostname, name, value, + ResultType.HOST_DETAIL, host, hostname, name, value, uri, ) def add_scan_error_to_list( @@ -54,10 +55,11 @@ def add_scan_error_to_list( value: str = '', port: str = '', test_id='', + uri: str = '', ) -> None: """ Adds an error result to result list. """ self.add_result_to_list( - ResultType.ERROR, host, hostname, name, value, port, test_id, + ResultType.ERROR, host, hostname, name, value, port, test_id, uri, ) def add_scan_log_to_list( @@ -69,6 +71,7 @@ def add_scan_log_to_list( port: str = '', test_id: str = '', qod: str = '', + uri: str = '', ) -> None: """ Adds log result to a list of results. """ self.add_result_to_list( @@ -81,6 +84,7 @@ def add_scan_log_to_list( test_id, '0.0', qod, + uri, ) def add_scan_alarm_to_list( @@ -93,6 +97,7 @@ def add_scan_alarm_to_list( test_id: str = '', severity: str = '', qod: str = '', + uri: str = '', ) -> None: """ Adds an alarm result to a result list. """ self.add_result_to_list( @@ -105,6 +110,7 @@ def add_scan_alarm_to_list( test_id, severity, qod, + uri, ) def add_result_to_list( @@ -118,6 +124,7 @@ def add_result_to_list( test_id: str = '', severity: str = '', qod: str = '', + uri: str = '', ) -> None: result = OrderedDict() # type: Dict @@ -130,7 +137,7 @@ def add_result_to_list( result['hostname'] = hostname result['port'] = port result['qod'] = qod - + result['uri'] = uri self._result_list.append(result) def __iter__(self): diff --git a/ospd/scan.py b/ospd/scan.py index 07289395..a6050407 100644 --- a/ospd/scan.py +++ b/ospd/scan.py @@ -82,6 +82,7 @@ def add_result( test_id: str = '', severity: str = '', qod: str = '', + uri: str = '', ) -> None: """ Add a result to a scan in the table. """ @@ -98,6 +99,7 @@ def add_result( result['hostname'] = hostname result['port'] = port result['qod'] = qod + result['uri'] = uri results = self.scans_table[scan_id]['results'] results.append(result) diff --git a/ospd/xml.py b/ospd/xml.py index 793b02c0..b3b0039f 100644 --- a/ospd/xml.py +++ b/ospd/xml.py @@ -91,6 +91,7 @@ def get_result_xml(result): ('test_id', result['test_id']), ('port', result['port']), ('qod', result['qod']), + ('uri', result['uri']), ]: result_xml.set(name, escape(str(value))) if result['value'] is not None: diff --git a/tests/test_scan_and_result.py b/tests/test_scan_and_result.py index f59b18b1..7b23fc18 100644 --- a/tests/test_scan_and_result.py +++ b/tests/test_scan_and_result.py @@ -77,6 +77,7 @@ def __init__(self, type_, **kwargs): self.test_id = '' self.severity = '' self.qod = '' + self.uri = '' for name, value in kwargs.items(): setattr(self, name, value)