Passed
Pull Request — master (#71)
by Juan José
01:32
created

gmp.gvm_connection.GVMConnection.valid_xml()   B

Complexity

Conditions 7

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 7
nop 1
dl 0
loc 8
rs 8
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
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
# Description:
3
# GVM-Connection classes for communication with the GVM.
4
#
5
# Authors:
6
# Raphael Grewe <[email protected]>
7
#
8
# Copyright:
9
# Copyright (C) 2017 Greenbone Networks GmbH
10
#
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
15
#
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24
import logging
25
import socket
26
import ssl
27
import time
28
from io import StringIO
29
30
from lxml import etree
31
import paramiko
32
33
from gmp.gmp import _gmp
34
35
logger = logging.getLogger(__name__)
0 ignored issues
show
Coding Style Naming introduced by
The name logger does not conform to the constant naming conventions ((([A-Z_][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...
36
37
BUF_SIZE = 1024
38
39
40
class GMPError(Exception):
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...
41
    pass
42
43
44
class GVMConnection:
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
best-practice introduced by
Too many public methods (121/20)
Loading history...
45
    """Wrapper for GMP
46
47
    This class helps users to connect to their GVM via Secure Shell,
48
    UNIX-Socket or secured connection on port 9390.
49
50
    Variables:
51
        gmp_generator {object} -- Instance of the gmp generator.
52
        authenticated {bool} -- GMP-User authenticated.
53
    """
54
55
    def __init__(self):
56
        # GMP Message Creator
57
        self.gmp_generator = _gmp()
58
59
        # Is authenticated on gvm
60
        self.authenticated = False
61
62
        # initialize variables
63
        self.sock = None
64
        self.first_element = None
65
        self.parser = None
66
        self.cmd = None
67
68
    def valid_xml(self):
0 ignored issues
show
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...
69
        for action, obj in self.parser.read_events():
70
            if not self.first_element and action in 'start':
71
                self.first_element = obj.tag
72
73
            if self.first_element and action in 'end' and str(self.first_element) == str(obj.tag):
74
                return True
75
        return False
76
77
    def readAll(self):
0 ignored issues
show
Coding Style Naming introduced by
The name readAll 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...
78
        # just a stub
79
        pass
80
81
    def sendAll(self, cmd):
0 ignored issues
show
Coding Style Naming introduced by
The name sendAll 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...
82
        # just a stub
83
        pass
84
85
    def send(self, cmd):
86
        """Call the sendAll(string) method.
87
88
        Nothing more ;-)
89
90
        Arguments:
91
            cmd {string} -- XML-Source
92
        """
93
        try:
94
            self.sendAll(cmd)
95
            logger.debug(cmd)
96
        except paramiko.SSHException as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable 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...
97
            print(e)
98
        except OSError as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable 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...
99
            logger.info(e)
100
            raise
101
102
    def read(self):
103
        """Call the readAll() method of the chosen connection type.
104
105
        Try to read all from the open socket connection.
106
        Check for status attribute in xml code.
107
        If the program is in shell-mode, then it returns a lxml root element,
108
        otherwise the plain xml.
109
        If the response is either None or the length is zero,
110
        then the connection was terminated from the server.
111
112
        Returns:
113
            lxml.etree._Element or <string> -- Response from server.
114
        """
115
        response = self.readAll()
116
        logger.debug('read() {0} Bytes response: {1}'.format(
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
117
            len(response), response))
118
119
        if response is None or len(str(response)) == 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
120
            raise OSError('Connection was closed by remote server')
121
122
        if hasattr(self, 'raw_response') and self.raw_response is True: #pylint: disable=E1101
123
            return response
124
125
        self.checkCommandStatus(response)
126
127
        if hasattr(self, 'shell_mode') and self.shell_mode is True: #pylint: disable=E1101
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
128
            parser = etree.XMLParser(encoding='utf-8', recover=True)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLParser.

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...
129
130
            logger.info('Shell mode activated')
131
            f = StringIO(response)
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable 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...
132
            tree = etree.parse(f, parser)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named parse.

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...
133
            return tree.getroot()
134
        else:
135
            return response
136
137
    def close(self):
0 ignored issues
show
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...
138
        try:
139
            if self.sock is not None:
140
                self.sock.close()
141
        except OSError as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable 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...
142
            logger.debug('Connection closing error: {0}'.format(e))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
143
144
    def checkCommandStatus(self, xml):
0 ignored issues
show
Coding Style Naming introduced by
The name checkCommandStatus 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...
145
        """Check gmp response
146
147
        Look into the gmp response and check for the status in the root element
148
149
        Arguments:
150
            xml {string} -- XML-Source
151
152
        Returns:
153
            bool -- True if valid, otherwise False
154
        """
155
156
        if xml is 0 or xml is None:
157
            raise GMPError('XML Command is empty')
158
159
        try:
160
            parser = etree.XMLParser(encoding='utf-8', recover=True)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLParser.

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...
161
            if etree.iselement(xml):
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named iselement.

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...
162
                root = etree.ElementTree(xml, parser=parser).getroot()
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named ElementTree.

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...
163
            else:
164
                root = etree.XML(xml, parser=parser)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XML.

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...
165
            status = root.attrib['status']
166
            status_text = root.attrib['status_text']
167
168
            if not self.authenticated:
169
                auth = root.find('authenticate_response')
170
                if auth is not None:
171
                    status = auth.attrib['status']
172
                    status_text = auth.attrib['status_text']
173
                    if status != '400':
174
                        self.authenticated = True
175
176
            if 'OK' not in status_text:
177
                logger.info('An error occurred on gvm: ' + status_text)
178
                raise GMPError(status_text)
179
180
        except etree.Error as e:
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named Error.

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...
Coding Style Naming introduced by
The name e does not conform to the variable 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...
181
            logger.error('etree.XML(xml): ' + str(e))
182
            raise
183
184
    def argumentsToString(self, kwargs):
0 ignored issues
show
Coding Style Naming introduced by
The name argumentsToString 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 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...
185
        """Convert arguments
186
187
        Converts dictionaries into gmp arguments string
188
189
        Arguments:
190
            kwargs {dict} -- Arguments
191
192
        Returns:
193
            string -- Arguments as string
194
        """
195
        msg = ''
196
        for key, value in kwargs.items():
197
            msg += str(key) + '=\'' + str(value) + '\' '
198
199
        return msg
200
201
    def ask_yes_or_no(self, text):
0 ignored issues
show
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...
202
        yes = set(['yes', 'y', 'ye', ''])
203
        no = set(['no', 'n'])
0 ignored issues
show
Coding Style Naming introduced by
The name no does not conform to the variable 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...
204
205
        choice = input(text).lower()
206
        if choice in yes:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
207
            return True
208
        elif choice in no:
209
            return False
210
        else:
211
            return self.ask_yes_or_no(text)
212
213
    def authenticate(self, username, password, withCommand=''):
0 ignored issues
show
Coding Style Naming introduced by
The name withCommand does not conform to the argument 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...
214
        """Authenticate on GVM.
215
216
        The generated authenticate command will be send to server.
217
        After that a response is read from socket.
218
219
        Keyword Arguments:
220
            username {str} -- Username
221
            password {str} -- Password
222
            withCommands {str} -- XML commands (default: {''})
223
224
        Returns:
225
            None or <string> -- Response from server.
226
        """
227
        cmd = self.gmp_generator.createAuthenticateCommand(
228
            username=username, password=password,
229
            withCommands=str(withCommand))
230
231
        self.send(cmd)
232
        return self.read()
233
234
    def create_agent(self, installer, signature, name, comment='', copy='',
0 ignored issues
show
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...
best-practice introduced by
Too many arguments (8/5)
Loading history...
235
                     howto_install='', howto_use=''):
236
        cmd = self.gmp_generator.createAgentCommand(
237
            installer, signature, name, comment, copy, howto_install,
238
            howto_use)
239
        self.send(cmd)
240
        return self.read()
241
242
    def create_alert(self, name, condition, event, method, filter_id='',
0 ignored issues
show
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...
best-practice introduced by
Too many arguments (8/5)
Loading history...
243
                     copy='', comment=''):
244
        cmd = self.gmp_generator.createAlertCommand(name, condition, event,
245
                                                    method, filter_id, copy,
246
                                                    comment)
247
        self.send(cmd)
248
        return self.read()
249
250
    def create_asset(self, name, asset_type, comment=''):
0 ignored issues
show
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...
251
        # TODO: Add the missing second method. Also the docs are not complete!
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
252
        cmd = self.gmp_generator.createAssetCommand(name, asset_type, comment)
253
        self.send(cmd)
254
        return self.read()
255
256
    def create_config(self, copy_id, name):
0 ignored issues
show
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...
257
        cmd = self.gmp_generator.createConfigCommand(copy_id, name)
258
        self.send(cmd)
259
        return self.read()
260
261
    def create_credential(self, name, **kwargs):
0 ignored issues
show
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...
262
        cmd = self.gmp_generator.createCredentialCommand(name, kwargs)
263
        self.send(cmd)
264
        return self.read()
265
266
    def create_filter(self, name, make_unique, **kwargs):
0 ignored issues
show
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...
267
        cmd = self.gmp_generator.createFilterCommand(name, make_unique, kwargs)
268
        self.send(cmd)
269
        return self.read()
270
271
    def create_group(self, name, **kwargs):
0 ignored issues
show
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...
272
        cmd = self.gmp_generator.createGroupCommand(name, kwargs)
273
        self.send(cmd)
274
        return self.read()
275
276
    # TODO: Create notes with comment returns bogus element. Research
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
277
    def create_note(self, text, nvt_oid, **kwargs):
0 ignored issues
show
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...
278
        cmd = self.gmp_generator.createNoteCommand(text, nvt_oid, kwargs)
279
        self.send(cmd)
280
        return self.read()
281
282
    def create_override(self, text, nvt_oid, **kwargs):
0 ignored issues
show
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...
283
        cmd = self.gmp_generator.createOverrideCommand(text, nvt_oid, kwargs)
284
        self.send(cmd)
285
        return self.read()
286
287
    def create_permission(self, name, subject_id, type, **kwargs):
0 ignored issues
show
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...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
288
        cmd = self.gmp_generator.createPermissionCommand(name, subject_id,
289
                                                         type, kwargs)
290
        self.send(cmd)
291
        return self.read()
292
293
    def create_port_list(self, name, port_range, **kwargs):
0 ignored issues
show
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...
294
        cmd = self.gmp_generator.createPortListCommand(name, port_range,
295
                                                       kwargs)
296
        self.send(cmd)
297
        return self.read()
298
299
    def create_port_range(self, port_list_id, start, end, type, comment=''):
0 ignored issues
show
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...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
best-practice introduced by
Too many arguments (6/5)
Loading history...
300
        cmd = self.gmp_generator.createPortRangeCommand(port_list_id, start,
301
                                                        end, type, comment)
302
        self.send(cmd)
303
        return self.read()
304
305
    def create_report(self, report_xml_string, **kwargs):
0 ignored issues
show
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...
306
        cmd = self.gmp_generator.createReportCommand(report_xml_string, kwargs)
307
        self.send(cmd)
308
        return self.read()
309
310
    def create_report_format(self):
0 ignored issues
show
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...
311
        # TODO: Seems to be a complex task. It is needed?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
312
        raise NotImplementedError
313
314
    def create_role(self, name, **kwargs):
0 ignored issues
show
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...
315
        cmd = self.gmp_generator.createRoleCommand(name, kwargs)
316
        self.send(cmd)
317
        return self.read()
318
319
    def create_scanner(self, name, host, port, type, ca_pub, credential_id,
0 ignored issues
show
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...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
best-practice introduced by
Too many arguments (7/5)
Loading history...
320
                       **kwargs):
321
        cmd = self.gmp_generator.createScannerCommand(name, host, port, type,
322
                                                      ca_pub, credential_id,
323
                                                      kwargs)
324
        self.send(cmd)
325
        return self.read()
326
327
    def create_schedule(self, name, **kwargs):
0 ignored issues
show
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...
328
        cmd = self.gmp_generator.createScheduleCommand(name, kwargs)
329
        self.send(cmd)
330
        return self.read()
331
332
    def create_tag(self, name, resource_id, resource_type, **kwargs):
0 ignored issues
show
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...
333
        cmd = self.gmp_generator.createTagCommand(name, resource_id,
334
                                                  resource_type, kwargs)
335
        self.send(cmd)
336
        return self.read()
337
338
    def create_target(self, name, make_unique, **kwargs):
0 ignored issues
show
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...
339
        # TODO: Missing variables
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
340
        cmd = self.gmp_generator.createTargetCommand(name, make_unique, kwargs)
341
        self.send(cmd)
342
        return self.read()
343
344
    def create_task(self, name, config_id, target_id, scanner_id, alert_id='', comment=''):
0 ignored issues
show
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...
best-practice introduced by
Too many arguments (7/5)
Loading history...
345
        cmd = self.gmp_generator.createTaskCommand(
346
            name, config_id, target_id, scanner_id, alert_id, comment)
347
        self.send(cmd)
348
        return self.read()
349
350
    def create_user(self, name, password, copy='', hosts_allow='0',
0 ignored issues
show
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...
best-practice introduced by
Too many arguments (9/5)
Loading history...
351
                    ifaces_allow='0', role_ids=(), hosts=None, ifaces=None):
352
        cmd = self.gmp_generator.createUserCommand(
353
            name, password, copy, hosts_allow, ifaces_allow, role_ids,
354
            hosts, ifaces)
355
        self.send(cmd)
356
        return self.read()
357
358
    def delete_agent(self, **kwargs):
0 ignored issues
show
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...
359
        self.send('<delete_agent {0}/>'.format(self.argumentsToString(kwargs)))
360
        return self.read()
361
362
    def delete_alert(self, **kwargs):
0 ignored issues
show
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...
363
        # if self.ask_yes_or_no('Are you sure to delete this alert? '):
364
        self.send(
365
            '<delete_alert {0}/>'.format(self.argumentsToString(kwargs)))
366
        return self.read()
367
368
    def delete_asset(self, asset_id, ultimate=0):
0 ignored issues
show
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...
369
        # if self.ask_yes_or_no('Are you sure to delete this asset? '):
370
        self.send('<delete_asset asset_id="{0}" ultimate="{1}"/>'
371
                  .format(asset_id, ultimate))
372
        return self.read()
373
374
    def delete_config(self, config_id, ultimate=0):
0 ignored issues
show
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...
375
        # if self.ask_yes_or_no('Are you sure to delete this config? '):
376
        self.send('<delete_config config_id="{0}" ultimate="{1}"/>'
377
                  .format(config_id, ultimate))
378
        return self.read()
379
380
    def delete_credential(self, credential_id, ultimate=0):
0 ignored issues
show
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...
381
        # if self.ask_yes_or_no('Are you sure to delete this credential? '):
382
        self.send(
383
            '<delete_credential credential_id="{0}" ultimate="{1}"/>'.format
384
            (credential_id, ultimate))
385
        return self.read()
386
387
    def delete_filter(self, filter_id, ultimate=0):
0 ignored issues
show
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...
388
        # if self.ask_yes_or_no('Are you sure to delete this filter? '):
389
        self.send('<delete_filter filter_id="{0}" ultimate="{1}"/>'
390
                  .format(filter_id, ultimate))
391
        return self.read()
392
393
    def delete_group(self, group_id, ultimate=0):
0 ignored issues
show
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...
394
        # if self.ask_yes_or_no('Are you sure to delete this group? '):
395
        self.send('<delete_group group_id="{0}" ultimate="{1}"/>'
396
                  .format(group_id, ultimate))
397
        return self.read()
398
399
    def delete_note(self, note_id, ultimate=0):
0 ignored issues
show
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...
400
        # if self.ask_yes_or_no('Are you sure to delete this note? '):
401
        self.send('<delete_note note_id="{0}" ultimate="{1}"/>'
402
                  .format(note_id, ultimate))
403
        return self.read()
404
405
    def delete_override(self, override_id, ultimate=0):
0 ignored issues
show
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...
406
        # if self.ask_yes_or_no('Are you sure to delete this override? '):
407
        self.send('<delete_override override_id="{0}" ultimate="{1}"/>'
408
                  .format(override_id, ultimate))
409
        return self.read()
410
411
    def delete_permission(self, permission_id, ultimate=0):
0 ignored issues
show
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...
412
        # if self.ask_yes_or_no('Are you sure to delete this permission? '):
413
        self.send('<delete_permission permission_id="{0}" ultimate="{1}"/>'
414
                  .format(permission_id, ultimate))
415
        return self.read()
416
417
    def delete_port_list(self, port_list_id, ultimate=0):
0 ignored issues
show
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...
418
        # if self.ask_yes_or_no('Are you sure to delete this port_list? '):
419
        self.send('<delete_port_list port_list_id="{0}" ultimate="{1}"/>'
420
                  .format(port_list_id, ultimate))
421
        return self.read()
422
423
    def delete_port_range(self, port_range_id):
0 ignored issues
show
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...
424
        # if self.ask_yes_or_no('Are you sure to delete this port_range? '):
425
        self.send('<delete_port_range port_range_id="{0}"/>'
426
                  .format(port_range_id))
427
        return self.read()
428
429
    def delete_report(self, report_id):
0 ignored issues
show
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...
430
        # if self.ask_yes_or_no('Are you sure to delete this report? '):
431
        self.send('<delete_report report_id="{0}"/>'
432
                  .format(report_id))
433
        return self.read()
434
435
    def delete_report_format(self, report_format_id, ultimate=0):
0 ignored issues
show
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...
436
        # if self.ask_yes_or_no('Are you sure to delete this report_format? '):
437
        self.send('<delete_report_format report_format_id="{0}" \
438
                   ultimate="{1}"/>'.format(report_format_id, ultimate))
439
        return self.read()
440
441
    def delete_role(self, role_id, ultimate=0):
0 ignored issues
show
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...
442
        # if self.ask_yes_or_no('Are you sure to delete this role? '):
443
        self.send('<delete_role role_id="{0}" ultimate="{1}"/>'
444
                  .format(role_id, ultimate))
445
        return self.read()
446
447
    def delete_scanner(self, scanner_id, ultimate=0):
0 ignored issues
show
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...
448
        # if self.ask_yes_or_no('Are you sure to delete this scanner? '):
449
        self.send('<delete_scanner scanner_id="{0}" ultimate="{1}"/>'
450
                  .format(scanner_id, ultimate))
451
        return self.read()
452
453
    def delete_schedule(self, schedule_id, ultimate=0):
0 ignored issues
show
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...
454
        # if self.ask_yes_or_no('Are you sure to delete this schedule? '):
455
        self.send('<delete_schedule schedule_id="{0}" ultimate="{1}"/>'
456
                  .format(schedule_id, ultimate))
457
        return self.read()
458
459
    def delete_tag(self, tag_id, ultimate=0):
0 ignored issues
show
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...
460
        # if self.ask_yes_or_no('Are you sure to delete this tag? '):
461
        self.send('<delete_tag tag_id="{0}" ultimate="{1}"/>'
462
                  .format(tag_id, ultimate))
463
        return self.read()
464
465
    def delete_target(self, target_id, ultimate=0):
0 ignored issues
show
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...
466
        # if self.ask_yes_or_no('Are you sure to delete this target? '):
467
        self.send('<delete_target target_id="{0}" ultimate="{1}"/>'
468
                  .format(target_id, ultimate))
469
        return self.read()
470
471
    def delete_task(self, task_id, ultimate=0):
0 ignored issues
show
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...
472
        # if self.ask_yes_or_no('Are you sure to delete this task? '):
473
        self.send('<delete_task task_id="{0}" ultimate="{1}"/>'
474
                  .format(task_id, ultimate))
475
        return self.read()
476
477
    def delete_user(self, **kwargs):
0 ignored issues
show
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...
478
        user_id = kwargs.get('user_id', '')
479
        if user_id:
480
            user_id = ' user_id="%s"' % user_id
481
482
        name = kwargs.get('name', '')
483
        if name:
484
            name = ' name="%s"' % name
485
486
        inheritor_id = kwargs.get('inheritor_id', '')
487
        if inheritor_id:
488
            inheritor_id = ' inheritor_id="%s"' % inheritor_id
489
490
        inheritor_name = kwargs.get('inheritor_name', '')
491
        if inheritor_name:
492
            inheritor_name = ' inheritor_name="%s"' % inheritor_name
493
494
        self.send('<delete_user{0}{1}{2}{3}/>'
495
                  .format(user_id, name, inheritor_id, inheritor_name))
496
        return self.read()
497
498
    def describe_auth(self):
0 ignored issues
show
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...
499
        self.send('<describe_auth/>')
500
        return self.read()
501
502
    def empty_trashcan(self):
0 ignored issues
show
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...
503
        self.send('<empty_trashcan/>')
504
        return self.read()
505
506
    def get_agents(self, **kwargs):
0 ignored issues
show
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...
507
        self.send('<get_agents {0}/>'.format(self.argumentsToString(kwargs)))
508
        return self.read()
509
510
    def get_aggregates(self, **kwargs):
0 ignored issues
show
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...
511
        self.send(
512
            '<get_aggregates {0}/>'.format(self.argumentsToString(kwargs)))
513
        return self.read()
514
515
    def get_alerts(self, **kwargs):
0 ignored issues
show
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...
516
        self.send('<get_alerts {0}/>'.format(self.argumentsToString(kwargs)))
517
        return self.read()
518
519
    def get_assets(self, **kwargs):
0 ignored issues
show
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...
520
        self.send('<get_assets {0}/>'.format(self.argumentsToString(kwargs)))
521
        return self.read()
522
523
    def get_credentials(self, **kwargs):
0 ignored issues
show
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...
524
        self.send(
525
            '<get_credentials {0}/>'.format(self.argumentsToString(kwargs)))
526
        return self.read()
527
528
    def get_configs(self, **kwargs):
0 ignored issues
show
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...
529
        self.send('<get_configs {0}/>'.format(self.argumentsToString(kwargs)))
530
        return self.read()
531
532
    def get_feeds(self, **kwargs):
0 ignored issues
show
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...
533
        self.send('<get_feeds {0}/>'.format(self.argumentsToString(kwargs)))
534
        return self.read()
535
536
    def get_filters(self, **kwargs):
0 ignored issues
show
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...
537
        self.send('<get_filters {0}/>'.format(self.argumentsToString(kwargs)))
538
        return self.read()
539
540
    def get_groups(self, **kwargs):
0 ignored issues
show
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...
541
        self.send('<get_groups {0}/>'.format(self.argumentsToString(kwargs)))
542
        return self.read()
543
544
    def get_info(self, **kwargs):
0 ignored issues
show
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...
545
        self.send('<get_info {0}/>'.format(self.argumentsToString(kwargs)))
546
        return self.read()
547
548
    def get_notes(self, **kwargs):
0 ignored issues
show
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...
549
        self.send('<get_notes {0}/>'.format(self.argumentsToString(kwargs)))
550
        return self.read()
551
552
    def get_nvts(self, **kwargs):
0 ignored issues
show
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...
553
        self.send('<get_nvts {0}/>'.format(self.argumentsToString(kwargs)))
554
        return self.read()
555
556
    def get_nvt_families(self, **kwargs):
0 ignored issues
show
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...
557
        self.send(
558
            '<get_nvt_families {0}/>'.format(self.argumentsToString(kwargs)))
559
        return self.read()
560
561
    def get_overrides(self, **kwargs):
0 ignored issues
show
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...
562
        self.send(
563
            '<get_overrides {0}/>'.format(self.argumentsToString(kwargs)))
564
        return self.read()
565
566
    def get_permissions(self, **kwargs):
0 ignored issues
show
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...
567
        self.send(
568
            '<get_permissions {0}/>'.format(self.argumentsToString(kwargs)))
569
        return self.read()
570
571
    def get_port_lists(self, **kwargs):
0 ignored issues
show
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...
572
        self.send(
573
            '<get_port_lists {0}/>'.format(self.argumentsToString(kwargs)))
574
        return self.read()
575
576
    def get_preferences(self, **kwargs):
0 ignored issues
show
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...
577
        self.send(
578
            '<get_preferences {0}/>'.format(self.argumentsToString(kwargs)))
579
        return self.read()
580
581
    def get_reports(self, **kwargs):
0 ignored issues
show
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...
582
        self.send('<get_reports {0}/>'
583
                  .format(self.argumentsToString(kwargs)))
584
        return self.read()
585
586
    def get_report_formats(self, **kwargs):
0 ignored issues
show
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...
587
        self.send(
588
            '<get_report_formats {0}/>'.format(self.argumentsToString(kwargs)))
589
        return self.read()
590
591
    def get_results(self, **kwargs):
0 ignored issues
show
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...
592
        self.send('<get_results {0}/>'.format(self.argumentsToString(kwargs)))
593
        return self.read()
594
595
    def get_roles(self, **kwargs):
0 ignored issues
show
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...
596
        self.send('<get_roles {0}/>'.format(self.argumentsToString(kwargs)))
597
        return self.read()
598
599
    def get_scanners(self, **kwargs):
0 ignored issues
show
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...
600
        self.send('<get_scanners {0}/>'.format(self.argumentsToString(kwargs)))
601
        return self.read()
602
603
    def get_schedules(self, **kwargs):
0 ignored issues
show
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...
604
        self.send(
605
            '<get_schedules {0}/>'.format(self.argumentsToString(kwargs)))
606
        return self.read()
607
608
    def get_settings(self, **kwargs):
0 ignored issues
show
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...
609
        self.send('<get_settings {0}/>'.format(self.argumentsToString(kwargs)))
610
        return self.read()
611
612
    def get_system_reports(self, **kwargs):
0 ignored issues
show
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...
613
        self.send(
614
            '<get_system_reports {0}/>'.format(self.argumentsToString(kwargs)))
615
        return self.read()
616
617
    def get_tags(self, **kwargs):
0 ignored issues
show
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...
618
        self.send('<get_tags {0}/>'.format(self.argumentsToString(kwargs)))
619
        return self.read()
620
621
    def get_targets(self, **kwargs):
0 ignored issues
show
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...
622
        self.send('<get_targets {0}/>'.format(self.argumentsToString(kwargs)))
623
        return self.read()
624
625
    def get_tasks(self, **kwargs):
0 ignored issues
show
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...
626
        self.send('<get_tasks {0}/>'.format(self.argumentsToString(kwargs)))
627
        return self.read()
628
629
    def get_users(self, **kwargs):
0 ignored issues
show
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...
630
        self.send('<get_users {0}/>'.format(self.argumentsToString(kwargs)))
631
        return self.read()
632
633
    def get_version(self):
0 ignored issues
show
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...
634
        self.send('<get_version/>')
635
        return self.read()
636
637
    def help(self, **kwargs):
0 ignored issues
show
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...
638
        self.send('<help {0} />'.format(self.argumentsToString(kwargs)))
639
        return self.read()
640
641
    def modify_agent(self, agent_id, name='', comment=''):
0 ignored issues
show
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...
642
        cmd = self.gmp_generator.modifyAgentCommand(agent_id, name, comment)
643
        self.send(cmd)
644
        return self.read()
645
646
    def modify_alert(self, alert_id, **kwargs):
0 ignored issues
show
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...
647
        cmd = self.gmp_generator.modifyAlertCommand(alert_id, kwargs)
648
        self.send(cmd)
649
        return self.read()
650
651
    def modify_asset(self, asset_id, comment):
0 ignored issues
show
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...
652
        cmd = '<modify_asset asset_id="%s"><comment>%s</comment>' \
653
              '</modify_asset>' % (asset_id, comment)
654
        self.send(cmd)
655
        return self.read()
656
657
    def modify_auth(self, group_name, auth_conf_settings):
0 ignored issues
show
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...
658
        cmd = self.gmp_generator.modifyAuthCommand(group_name,
659
                                                   auth_conf_settings)
660
        self.send(cmd)
661
        return self.read()
662
663
    def modify_config(self, selection, **kwargs):
0 ignored issues
show
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...
664
        cmd = self.gmp_generator.modifyConfigCommand(selection, kwargs)
665
        self.send(cmd)
666
        return self.read()
667
668
    def modify_credential(self, credential_id, **kwargs):
0 ignored issues
show
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...
669
        cmd = self.gmp_generator.modifyCredentialCommand(credential_id, kwargs)
670
        self.send(cmd)
671
        return self.read()
672
673
    def modify_filter(self, filter_id, **kwargs):
0 ignored issues
show
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...
674
        cmd = self.gmp_generator.modifyFilterCommand(filter_id, kwargs)
675
        self.send(cmd)
676
        return self.read()
677
678
    def modify_group(self, group_id, **kwargs):
0 ignored issues
show
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...
679
        cmd = self.gmp_generator.modifyGroupCommand(group_id, kwargs)
680
        self.send(cmd)
681
        return self.read()
682
683
    def modify_note(self, note_id, text, **kwargs):
0 ignored issues
show
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...
684
        cmd = self.gmp_generator.modifyNoteCommand(note_id, text, kwargs)
685
        self.send(cmd)
686
        return self.read()
687
688
    def modify_override(self, override_id, text, **kwargs):
0 ignored issues
show
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...
689
        cmd = self.gmp_generator.modifyOverrideCommand(override_id, text,
690
                                                       kwargs)
691
        self.send(cmd)
692
        return self.read()
693
694
    def modify_permission(self, permission_id, **kwargs):
0 ignored issues
show
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...
695
        cmd = self.gmp_generator.modifyPermissionCommand(permission_id, kwargs)
696
        self.send(cmd)
697
        return self.read()
698
699
    def modify_port_list(self, port_list_id, **kwargs):
0 ignored issues
show
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...
700
        cmd = self.gmp_generator.modifyPortListCommand(port_list_id, kwargs)
701
        self.send(cmd)
702
        return self.read()
703
704
    def modify_report(self, report_id, comment):
0 ignored issues
show
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...
705
        cmd = '<modify_report report_id="{0}"><comment>{1}</comment>' \
706
              '</modify_report>'.format(report_id, comment)
707
        self.send(cmd)
708
        return self.read()
709
710
    def modify_report_format(self, report_format_id, **kwargs):
0 ignored issues
show
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...
711
        cmd = self.gmp_generator.modifyReportFormatCommand(report_format_id,
712
                                                           kwargs)
713
        self.send(cmd)
714
        return self.read()
715
716
    def modify_role(self, role_id, **kwargs):
0 ignored issues
show
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...
717
        cmd = self.gmp_generator.modifyRoleCommand(role_id, kwargs)
718
        self.send(cmd)
719
        return self.read()
720
721
    def modify_scanner(self, scanner_id, host, port, type, **kwargs):
0 ignored issues
show
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...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
722
        cmd = self.gmp_generator.modifyScannerCommand(scanner_id, host, port,
723
                                                      type, kwargs)
724
        self.send(cmd)
725
        return self.read()
726
727
    def modify_schedule(self, schedule_id, **kwargs):
0 ignored issues
show
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...
728
        cmd = self.gmp_generator.modifyScheduleCommand(schedule_id, kwargs)
729
        self.send(cmd)
730
        return self.read()
731
732
    def modify_setting(self, setting_id, name, value):
0 ignored issues
show
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...
733
        cmd = '<modify_setting setting_id="{0}"><name>{1}</name>' \
734
              '<value>{2}</value></modify_setting>' \
735
              ''.format(setting_id, name, value)
736
        self.send(cmd)
737
        return self.read()
738
739
    def modify_tag(self, tag_id, **kwargs):
0 ignored issues
show
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...
740
        cmd = self.gmp_generator.modifyTagCommand(tag_id, kwargs)
741
        self.send(cmd)
742
        return self.read()
743
744
    def modify_target(self, target_id, **kwargs):
0 ignored issues
show
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...
745
        cmd = self.gmp_generator.modifyTargetCommand(target_id, kwargs)
746
        self.send(cmd)
747
        return self.read()
748
749
    def modify_task(self, task_id, **kwargs):
0 ignored issues
show
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...
750
        cmd = self.gmp_generator.modifyTaskCommand(task_id, kwargs)
751
        self.send(cmd)
752
        return self.read()
753
754
    def modify_user(self, **kwargs):
0 ignored issues
show
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...
755
        cmd = self.gmp_generator.modifyUserCommand(kwargs)
756
        self.send(cmd)
757
        return self.read()
758
759
    def move_task(self, task_id, slave_id):
0 ignored issues
show
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...
760
        self.send('<move_task task_id="{0}" slave_id="{1}"/>'
761
                  .format(task_id, slave_id))
762
        return self.read()
763
764
    def restore(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument 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...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
765
        self.send('<restore id="{0}"/>'.format(id))
766
        return self.read()
767
768
    def resume_task(self, task_id):
0 ignored issues
show
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...
769
        self.send('<resume_task task_id="{0}"/>'.format(task_id))
770
        return self.read()
771
772
    def run_wizard(self):
0 ignored issues
show
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...
773
        # TODO: Is this required?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
774
        raise NotImplementedError
775
776
    def start_task(self, task_id):
0 ignored issues
show
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...
777
        self.send('<start_task task_id="{0}"/>'.format(task_id))
778
        return self.read()
779
780
    def stop_task(self, task_id):
0 ignored issues
show
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...
781
        self.send('<stop_task task_id="{0}"/>'.format(task_id))
782
        return self.read()
783
784
    def sync_cert(self):
0 ignored issues
show
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...
785
        self.send('<sync_cert/>')
786
        return self.read()
787
788
    def sync_config(self):
0 ignored issues
show
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...
789
        self.send('<sync_config/>')
790
        return self.read()
791
792
    def sync_feed(self):
0 ignored issues
show
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...
793
        self.send('<sync_feed/>')
794
        return self.read()
795
796
    def sync_scap(self):
0 ignored issues
show
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...
797
        self.send('<sync_scap/>')
798
        return self.read()
799
800
    def test_alert(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument 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...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
801
        self.send('<test_alert alert_id="{0}"/>'.format(id))
802
        return self.read()
803
804
    def verify_agent(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument 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...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
805
        self.send('<verify_agent agent_id="{0}"/>'.format(id))
806
        return self.read()
807
808
    def verify_report_format(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument 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...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
809
        self.send('<verify_report_format report_format_id="{0}"/>'.format(id))
810
        return self.read()
811
812
    def verify_scanner(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument 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...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
813
        self.send('<verify_scanner scanner_id="{0}"/>'.format(id))
814
        return self.read()
815
816
817
class SSHConnection(GVMConnection):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (14/7)
Loading history...
Bug introduced by
The method create_report_format which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method run_wizard which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
818
    """SSH Class to connect, read and write from GVM via SSH
819
820
    [description]
821
822
    Variables:
823
        sock {[type]} -- Channel from paramiko after successful connection
824
825
    """
826
827
    def __init__(self, **kwargs):
828
        super().__init__()
829
        self.hostname = kwargs.get('hostname', '127.0.0.1')
830
        self.port = kwargs.get('port', 22)
831
        self.raw_response = kwargs.get('raw_response', False)
832
        self.timeout = kwargs.get('timeout', 5)
833
        self.ssh_user = kwargs.get('ssh_user', 'gmp')
834
        self.ssh_password = kwargs.get('ssh_password', '')
835
        self.shell_mode = kwargs.get('shell_mode', False)
836
        self.sock = paramiko.SSHClient()
837
        # self.sock.load_system_host_keys()
838
        # self.sock.set_missing_host_key_policy(paramiko.WarningPolicy())
839
        self.sock.set_missing_host_key_policy(paramiko.AutoAddPolicy())
840
841
        try:
842
            self.sock.connect(
843
                hostname=self.hostname,
844
                username=self.ssh_user,
845
                password=self.ssh_password,
846
                timeout=self.timeout,
847
                port=int(self.port),
848
                allow_agent=False,
849
                look_for_keys=False)
850
            self.stdin, self.stdout, self.stderr = self.sock.exec_command("", get_pty=False)
851
852
        except (paramiko.BadHostKeyException,
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable 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...
853
                paramiko.AuthenticationException,
854
                paramiko.SSHException, OSError) as e:
855
            logger.debug('SSH Connection failed: ' + str(e))
856
            raise
857
858
    def readAll(self):
859
        self.first_element = None
860
        self.parser = etree.XMLPullParser(('start', 'end'))
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLPullParser.

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...
861
862
        response = ''
863
864
        while True:
865
            data = self.stdout.channel.recv(BUF_SIZE)
866
            # Connection was closed by server
867
            if not data:
868
                break
869
870
            self.parser.feed(data)
871
872
            response += data.decode('utf-8')
873
874
            if self.valid_xml():
875
                break
876
        return response
877
878
    def cmdSplitter(self, max_len):
0 ignored issues
show
Coding Style Naming introduced by
The name cmdSplitter 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...
879
        """ Receive the cmd string longer than max_len
880
        and send it in blocks not longer than max_len.
881
882
        Input:
883
           max_len  The max length of a block to be sent.
884
        """
885
        i_start = 0;
0 ignored issues
show
Coding Style introduced by
Unnecessary semicolon
Loading history...
886
        i_end = max_len
887
        sent_bytes = 0
888
        while sent_bytes < len(self.cmd):
889
            time.sleep(0.01)
890
            self.stdin.channel.send(self.cmd[i_start:i_end])
891
            i_start = i_end
892
            if i_end > len(self.cmd):
893
                i_end = len(self.cmd)
894
            else:
895
                i_end = i_end + max_len
896
            sent_bytes += (i_end - i_start)
897
898
        return sent_bytes
899
900
    def sendAll(self, cmd, max_len=4095):
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'sendAll' method
Loading history...
901
        logger.debug('SSH:send(): ' + cmd)
902
        self.cmd = str(cmd)
903
        if len(self.cmd) > max_len:
904
            sent_bytes = self.cmdSplitter(max_len)
905
            logger.debug("SSH: {0} bytes sent.".format(sent_bytes))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
906
        else:
907
            self.stdin.channel.send(self.cmd)
908
909
class TLSConnection(GVMConnection):
0 ignored issues
show
Bug introduced by
The method create_report_format which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method run_wizard which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
910
    """TLS class to connect, read and write from GVM via tls secured socket
911
912
    [description]
913
914
    Variables:
915
        sock {socket.socket} -- Socket that holds the connection
916
    """
917
918
    def __init__(self, **kwargs):
919
        super().__init__()
920
        self.hostname = kwargs.get('hostname', '127.0.0.1')
921
        self.port = kwargs.get('port', 9390)
922
        self.raw_response = kwargs.get('raw_response', False)
923
        self.timeout = kwargs.get('timeout', 60)
924
        self.shell_mode = kwargs.get('shell_mode', False)
925
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
926
        self.sock = context.wrap_socket(socket.socket(socket.AF_INET))
927
        self.sock.settimeout(self.timeout)
928
        self.sock.connect((self.hostname, int(self.port)))
929
930
    def sendAll(self, cmd):
931
        self.sock.send(cmd.encode())
932
933
    def readAll(self):
934
        response = ''
935
        while True:
936
            data = self.sock.read(BUF_SIZE)
937
938
            response += data.decode(errors='ignore')
939
            if len(data) < BUF_SIZE:
940
                break
941
        return response
942
943
944
class UnixSocketConnection(GVMConnection):
0 ignored issues
show
Bug introduced by
The method create_report_format which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Bug introduced by
The method run_wizard which was declared abstract in the super-class GVMConnection
was not overridden.

Methods which raise NotImplementedError should be overridden in concrete child classes.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
945
    """UNIX-Socket class to connect, read, write from GVM
946
    via direct communicating UNIX-Socket
947
948
    [description]
949
950
    Variables:
951
        sock {socket.socket} -- Socket that holds the connection
952
        sockpath {string} -- Path to UNIX-Socket
953
    """
954
955
    def __init__(self, **kwargs):
956
        super().__init__()
957
        self.raw_response = kwargs.get('raw_response', False)
958
        self.sockpath = kwargs.get('sockpath',
959
                                   '/usr/local/var/run/gvmd.sock')
960
        self.shell_mode = kwargs.get('shell_mode', False)
961
        self.timeout = kwargs.get('timeout', 60)
962
        self.read_timeout = kwargs.get('read_timeout', 30)
963
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) #pylint: disable=E1101
964
        self.sock.settimeout(self.timeout)
965
        self.sock.connect(self.sockpath)
966
967
    def readAll(self):
968
        self.first_element = None
969
        self.parser = etree.XMLPullParser(('start', 'end'))
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLPullParser.

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...
970
        response = ''
971
972
        read_timeout = self.read_timeout
973
        break_timeout = time.time() + read_timeout
974
        old_timeout = self.sock.gettimeout()
975
        self.sock.settimeout(5)
976
977
        while time.time() < break_timeout:
978
            data = b''
979
            try:
980
                data = self.sock.recv(BUF_SIZE)
981
            except (socket.timeout) as exception:
982
                logger.debug('Warning: No data recieve from server: {0}'.format(exception))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
983
            self.parser.feed(data)
984
            response += data.decode('utf-8')
985
            if len(data) < BUF_SIZE:
986
                if self.valid_xml():
987
                    break
988
989
        self.sock.settimeout(old_timeout)
990
        return response
991
992
    def sendAll(self, cmd):
993
        self.sock.send(cmd.encode())
994