Passed
Pull Request — master (#38)
by
unknown
01:30
created

DummyWrapper.get_custom_vt_as_xml_str()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
from __future__ import print_function
0 ignored issues
show
Coding Style Naming introduced by
The name testScanAndResult does not conform to the module naming conventions ((([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
4
import time
5
import unittest
6
import xml.etree.ElementTree as ET
7
import defusedxml.lxml as secET
8
from defusedxml.common import EntitiesForbidden
9
10
from ospd.ospd import OSPDaemon, OSPDError
11
12
class Result(object):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
13
    def __init__(self, type_, **kwargs):
14
        self.result_type = type_
15
        self.host = ''
16
        self.name = ''
17
        self.value = ''
18
        self.port = ''
19
        self.test_id = ''
20
        self.severity = ''
21
        self.qod = ''
22
        for name, value in kwargs.items():
23
            setattr(self, name, value)
24
25
26
class DummyWrapper(OSPDaemon):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
27
    def __init__(self, results, checkresult=True):
28
        OSPDaemon.__init__(self, 'cert', 'key', 'ca')
29
        self.checkresult = checkresult
30
        self.results = results
31
32
    def check(self):
33
        return self.checkresults
0 ignored issues
show
Bug introduced by
Instance of 'DummyWrapper' has no 'checkresults' member; maybe 'checkresult'?

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
34
35
    def get_custom_vt_as_xml_str(self, custom):
36
        return '<mytest>static test</mytest>'
37
38
    def get_params_vt_as_xml_str(self, vt_param):
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'get_params_vt_as_xml_str' method
Loading history...
Unused Code introduced by
The argument vt_param seems to be unused.
Loading history...
39
        return ('<vt_param id="abc" type="string">'
40
                '<name>ABC</name><description>Test ABC</description><default>yes</default>'
41
                '</vt_param>'
42
                '<vt_param id="def" type="string">'
43
                '<name>DEF</name><description>Test DEF</description><default>no</default>'
44
                '</vt_param>')
45
46
    def exec_scan(self, scan_id, target):
47
        time.sleep(0.01)
48
        for res in self.results:
49
            if res.result_type == 'log':
50
                self.add_scan_log(scan_id, res.host or target, res.name, res.value, res.port)
51
            if res.result_type == 'error':
52
                self.add_scan_error(scan_id, res.host or target, res.name, res.value, res.port)
53
            elif res.result_type == 'host-detail':
54
                self.add_scan_error(scan_id, res.host or target, res.name, res.value)
55
            elif res.result_type == 'alarm':
56
                self.add_scan_alarm(scan_id, res.host or target, res.name, res.value, res.port, res.test_id, res.severity, res.qod)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (131/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
57
            else:
58
                raise ValueError(res.result_type)
59
60
61
class FullTest(unittest.TestCase):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
62
    # TODO: There should be a lot more assert in there !
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
63
64
    def testGetDefaultScannerParams(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetDefaultScannerParams does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
65
        daemon = DummyWrapper([])
66
        response = secET.fromstring(daemon.handle_command('<get_scanner_details />'))
67
        # The status of the response must be success (i.e. 200)
68
        self.assertEqual(response.get('status'), '200')
69
        # The response root element must have the correct name
70
        self.assertEqual(response.tag, 'get_scanner_details_response')
71
        # The response must contain a 'scanner_params' element
72
        self.assertIsNotNone(response.find('scanner_params'))
73
74
    def testGetDefaultHelp(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetDefaultHelp does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
75
        daemon = DummyWrapper([])
76
        response = secET.fromstring(daemon.handle_command('<help />'))
77
        print(ET.tostring(response))
78
        response = secET.fromstring(daemon.handle_command('<help format="xml" />'))
79
        print(ET.tostring(response))
80
81
    def testGetDefaultScannerVersion(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetDefaultScannerVersion does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
82
        daemon = DummyWrapper([])
83
        response = secET.fromstring(daemon.handle_command('<get_version />'))
84
        print(ET.tostring(response))
85
86
    def testGetVTs_no_VT(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetVTs_no_VT does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
87
        daemon = DummyWrapper([])
88
        response = secET.fromstring(daemon.handle_command('<get_vts />'))
89
        print(ET.tostring(response))
90
91
    def testGetVTs_single_VT(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetVTs_single_VT does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
92
        daemon = DummyWrapper([])
93
        daemon.add_vt('1.2.3.4', 'A vulnerability test')
94
        response = secET.fromstring(daemon.handle_command('<get_vts />'))
95
        print(ET.tostring(response))
96
97
    def testGetVTs_multiple_VTs(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetVTs_multiple_VTs does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
98
        daemon = DummyWrapper([])
99
        daemon.add_vt('1.2.3.4', 'A vulnerability test')
100
        daemon.add_vt('some id', 'Another vulnerability test')
101
        daemon.add_vt('123456789', 'Yet another vulnerability test')
102
        response = secET.fromstring(daemon.handle_command('<get_vts />'))
103
        print(ET.tostring(response))
104
105
    def testGetVTs_multiple_VTs_with_custom(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetVTs_multiple_VTs_with_custom does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
106
        daemon = DummyWrapper([])
107
        daemon.add_vt('1.2.3.4', 'A vulnerability test')
108
        daemon.add_vt('some id', 'Another vulnerability test with custom info', {'depencency': '1.2.3.4'})
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
109
        daemon.add_vt('123456789', 'Yet another vulnerability test')
110
        response = secET.fromstring(daemon.handle_command('<get_vts />'))
111
        print(ET.tostring(response))
112
113
    def testGetVTs_VTs_with_params(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testGetVTs_VTs_with_params does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
114
        daemon = DummyWrapper([])
115
        daemon.add_vt('1.2.3.4', 'A vulnerability test', vt_params="a", custom="b")
116
        response = secET.fromstring(daemon.handle_command('<get_vts vt_id="1.2.3.4"></get_vts>'))
117
        print(ET.tostring(response))
118
        # The status of the response must be success (i.e. 200)
119
        self.assertEqual(response.get('status'), '200')
120
        # The response root element must have the correct name
121
        self.assertEqual(response.tag, 'get_vts_response')
122
        # The response must contain a 'scanner_params' element
123
        self.assertIsNotNone(response.find('vts'))
124
        vt_params = response[0][0].findall('vt_params')
125
        self.assertEqual(1, len(vt_params))
126
        custom = response[0][0].findall('custom')
127
        self.assertEqual(1, len(custom))
128
        params = response.findall('vts/vt/vt_params/vt_param')
129
        self.assertEqual(2, len(params))
130
131
    def testiScanWithError(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testiScanWithError does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
132
        daemon = DummyWrapper([
133
            Result('error', value='something went wrong'),
134
        ])
135
136
        response = secET.fromstring(daemon.handle_command('<start_scan target="localhost" ports="80, 443"><scanner_params /></start_scan>'))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (140/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
137
        print(ET.tostring(response))
138
        scan_id = response.findtext('id')
139
        finished = False
140
        while not finished:
141
            response = secET.fromstring(daemon.handle_command('<get_scans scan_id="%s" details="0"/>' % scan_id))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
142
            print(ET.tostring(response))
143
            scans = response.findall('scan')
144
            self.assertEqual(1, len(scans))
145
            scan = scans[0]
146
            if int(scan.get('progress')) != 100:
147
                self.assertEqual('0', scan.get('end_time'))
148
                time.sleep(.010)
149
            else:
150
                finished = True
151
        response = secET.fromstring(daemon.handle_command('<get_scans scan_id="%s"/>' % scan_id))
152
        print(ET.tostring(response))
153
        response = secET.fromstring(daemon.handle_command('<get_scans />'))
154
        print(ET.tostring(response))
155
        response = secET.fromstring(daemon.handle_command('<get_scans scan_id="%s" details="1"/>' % scan_id))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (109/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
156
        self.assertEqual(response.findtext('scan/results/result'), 'something went wrong')
157
        print(ET.tostring(response))
158
159
        response = secET.fromstring(daemon.handle_command('<delete_scan scan_id="%s" />' % scan_id))
160
        self.assertEqual(response.get('status'), '200')
161
        print(ET.tostring(response))
162
163
    def testStopScan(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testStopScan does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
164
        daemon = DummyWrapper([])
165
        response = secET.fromstring(
166
            daemon.handle_command('<start_scan ' +
167
                                  'target="localhost" ports="80, 443">' +
168
                                  '<scanner_params /></start_scan>'))
169
        print(ET.tostring(response))
170
        scan_id = response.findtext('id')
171
        time.sleep(0.01)
172
173
        response = daemon.stop_scan(scan_id)
174
        self.assertEqual(response, None)
175
176
        response = secET.fromstring(daemon.handle_command(
177
            '<stop_scan scan_id="%s" />' % scan_id))
178
        self.assertEqual(response.get('status'), '200')
179
        print(ET.tostring(response))
180
181
    def testScanWithVTs(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testScanWithVTs does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
182
        daemon = DummyWrapper([])
183
        cmd = secET.fromstring('<start_scan ' +
184
                               'target="localhost" ports="80, 443">' +
185
                               '<scanner_params /><vts /></start_scan>')
186
        print(ET.tostring(cmd))
187
        self.assertRaises(OSPDError, daemon.handle_start_scan_command, cmd)
188
189
        # With one VT, without params
190
        response = secET.fromstring(
191
            daemon.handle_command('<start_scan ' +
192
                                  'target="localhost" ports="80, 443">' +
193
                                  '<scanner_params /><vts><vt id="1.2.3.4" />' +
194
                                  '</vts></start_scan>'))
195
        print(ET.tostring(response))
196
        scan_id = response.findtext('id')
197
        time.sleep(0.01)
198
        self.assertEqual(daemon.get_scan_vts(scan_id), {'1.2.3.4': {}})
199
        self.assertNotEqual(daemon.get_scan_vts(scan_id), {'1.2.3.6': {}})
200
201
        # With out VTS
202
        response = secET.fromstring(
203
            daemon.handle_command('<start_scan ' +
204
                                  'target="localhost" ports="80, 443">' +
205
                                  '<scanner_params /></start_scan>'))
206
        print(ET.tostring(response))
207
        scan_id = response.findtext('id')
208
        time.sleep(0.01)
209
        self.assertEqual(daemon.get_scan_vts(scan_id), {})
210
211
    def testScanWithVTs_and_param(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testScanWithVTs_and_param does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
212
        daemon = DummyWrapper([])
213
214
        # Raise because no vt_param name attribute
215
        cmd = secET.fromstring('<start_scan ' +
216
                               'target="localhost" ports="80, 443">' +
217
                               '<scanner_params /><vts><vt id="1234">' +
218
                               '<vt_param type="entry">200</vt_param>' +
219
                               '</vt></vts></start_scan>')
220
        print(ET.tostring(cmd))
221
        self.assertRaises(OSPDError, daemon.handle_start_scan_command, cmd)
222
223
        # No error
224
        response = secET.fromstring(
225
            daemon.handle_command('<start_scan ' +
226
                                  'target="localhost" ports="80, 443">' +
227
                                  '<scanner_params /><vts><vt id="1234">' +
228
                                  '<vt_param name="ABC" type="entry">200' +
229
                                  '</vt_param></vt></vts></start_scan>'))
230
        print(ET.tostring(response))
231
        scan_id = response.findtext('id')
232
        time.sleep(0.01)
233
        self.assertEqual(daemon.get_scan_vts(scan_id),
234
                         {'1234': {'ABC': {'type': 'entry', 'value': '200'}}})
235
236
    def testBillonLaughs(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testBillonLaughs does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
237
        daemon = DummyWrapper([])
238
        lol = ('<?xml version="1.0"?>' +
239
               '<!DOCTYPE lolz [' +
240
               ' <!ENTITY lol "lol">' +
241
               ' <!ELEMENT lolz (#PCDATA)>' +
242
               ' <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">' +
243
               ' <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">' +
244
               ' <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">' +
245
               ' <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">' +
246
               ' <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">' +
247
               ' <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">' +
248
               ' <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">' +
249
               ' <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">' +
250
               ' <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">' +
251
               ']>')
252
        self.assertRaises(EntitiesForbidden, daemon.handle_command, lol)
253
254
    def testScanMultiTarget(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testScanMultiTarget does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
255
        daemon = DummyWrapper([])
256
        response = secET.fromstring(
257
            daemon.handle_command('<start_scan>' +
258
                                  '<scanner_params /><vts><vt id="1.2.3.4" />' +
259
                                  '</vts>' +
260
                                  '<targets><target>' +
261
                                  '<hosts>localhosts</hosts>' +
262
                                  '<ports>80,443</ports>' +
263
                                  '</target>' +
264
                                  '<target><hosts>192.168.0.0/24</hosts>' +
265
                                  '<ports>22</ports></target></targets>' +
266
                                  '</start_scan>'))
267
        print(ET.tostring(response))
268
        self.assertEqual(response.get('status'), '200')
269
270
    def testMultiTargetWithCredentials(self):
0 ignored issues
show
Coding Style Naming introduced by
The name testMultiTargetWithCredentials does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
271
        daemon = DummyWrapper([])
272
        response = secET.fromstring(
273
            daemon.handle_command('<start_scan>' +
274
                                  '<scanner_params /><vts><vt id="1.2.3.4" />' +
275
                                  '</vts>' +
276
                                  '<targets><target><hosts>localhosts</hosts>' +
277
                                  '<ports>80,443</ports></target><target>' +
278
                                  '<hosts>192.168.0.0/24</hosts><ports>22' +
279
                                  '</ports><credentials>' +
280
                                  '<credential type="up" service="ssh" port="22">' +
281
                                  '<username>scanuser</username>' +
282
                                  '<password>mypass</password>' +
283
                                  '</credential><credential type="up" service="smb">' +
284
                                  '<username>smbuser</username>' +
285
                                  '<password>mypass</password></credential>' +
286
                                  '</credentials>' +
287
                                  '</target></targets>' +
288
                                  '</start_scan>'))
289
        print(ET.tostring(response))
290
        self.assertEqual(response.get('status'), '200')
291
        cred_dict = {'ssh': {'type': 'up', 'password':
292
                    'mypass', 'port': '22', 'username':
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation in dict value.
Loading history...
293
                    'scanuser'}, 'smb': {'type': 'up',
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation in dict value.
Loading history...
294
                    'password': 'mypass', 'username': 'smbuser'}}
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation (add 21 spaces).
Loading history...
295
        scan_id = response.findtext('id')
296
        response = daemon.get_scan_credentials(scan_id, "192.168.0.0/24")
297
        self.assertEqual(response, cred_dict)
298