Skip to content

Commit

Permalink
Merge pull request greenbone#166 from janowagner/unified_vt_solution
Browse files Browse the repository at this point in the history
Add solution method to solution element
  • Loading branch information
jjnicola committed Nov 8, 2019
2 parents 3d6c77c + 98e8620 commit 7a8e125
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [20.4] (unreleased)

### Added
- Add solution method to solution of vt object. [#166](https://github.com/greenbone/ospd/pull/166)

## [2.0.1] (unreleased)

### Added
Expand Down
17 changes: 16 additions & 1 deletion doc/OSP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<name>Open Scanner Protocol</name>
<abbreviation>OSP</abbreviation>
<summary>The Open Scanner Protocol</summary>
<version>1.2</version>
<version>20.04</version>

<!-- Types. -->

Expand Down Expand Up @@ -953,6 +953,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<summary>Solution type, for example "VendorFix"</summary>
<type>string</type>
</attrib>
<attrib>
<name>method</name>
<summary>Solution method, for example "DebianAPTUpgrade"</summary>
<type>string</type>
</attrib>
</pattern>
</ele>
<ele>
Expand Down Expand Up @@ -1302,6 +1307,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
<summary>An ovaldef file's content that is base64 encoded</summary>
</parameter_type>

<change>
<command>GET_VTS</command>
<summary>Returned object extended with solution method</summary>
<description>
The element SOLUTION of the returned VT object has a new optional attribute METHOD
that describes the solution method in case the VT offers such a detail.
</description>
<version>20.04</version>
</change>

<change>
<command>GET_VTS</command>
<summary>command added</summary>
Expand Down
10 changes: 7 additions & 3 deletions ospd/ospd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2014-2018 Greenbone Networks GmbH
# Copyright (C) 2014-2019 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
Expand Down Expand Up @@ -255,6 +255,7 @@ def add_vt(
insight=None,
solution=None,
solution_t=None,
solution_m=None,
detection=None,
qod_t=None,
qod_v=None,
Expand Down Expand Up @@ -301,6 +302,8 @@ def add_vt(
vt["solution"] = solution
if solution_t is not None:
vt["solution_type"] = solution_t
if solution_m is not None:
vt["solution_method"] = solution_m

if detection is not None:
vt["detection"] = detection
Expand Down Expand Up @@ -1420,7 +1423,7 @@ def get_insight_vt_as_xml_str(

@staticmethod
def get_solution_vt_as_xml_str(
vt_id, solution, solution_type=None
vt_id, solution, solution_type=None, solution_method=None
): # pylint: disable=unused-argument
""" Create a string representation of the XML object from the
solution data object.
Expand Down Expand Up @@ -1538,7 +1541,8 @@ def get_vt_xml(self, vt_id):

if vt.get('solution'):
solution_xml_str = self.get_solution_vt_as_xml_str(
vt_id, vt.get('solution'), vt.get('solution_type')
vt_id, vt.get('solution'), vt.get('solution_type'),
vt.get('solution_method')
)
vt_xml.append(secET.fromstring(solution_xml_str))

Expand Down
6 changes: 4 additions & 2 deletions tests/test_scan_and_result.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2015-2018 Greenbone Networks GmbH
# Copyright (C) 2015-2019 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
Expand Down Expand Up @@ -136,7 +136,8 @@ def get_insight_vt_as_xml_str(vt_id, insight):
return response

@staticmethod
def get_solution_vt_as_xml_str(vt_id, solution, solution_type=None):
def get_solution_vt_as_xml_str(vt_id, solution, solution_type=None,
solution_method=None):
response = '<solution>Some solution</solution>'

return response
Expand Down Expand Up @@ -580,6 +581,7 @@ def test_get_vts_vts_with_solution(self):
custom="b",
solution="c",
solution_t="d",
solution_m="e",
)

response = secET.fromstring(
Expand Down

0 comments on commit 7a8e125

Please sign in to comment.