Passed
Pull Request — master (#71)
by Juan José
01:40
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...
coding-style introduced by
Too many lines in module (1008/1000)
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
DEFAULT_READ_TIMEOUT = 60 # in seconds
39
DEFAULT_TIMEOUT = 60 # in seconds
40
41
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...
42
    pass
43
44
45
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...
46
    """Wrapper for GMP
47
48
    This class helps users to connect to their GVM via Secure Shell,
49
    UNIX-Socket or secured connection on port 9390.
50
51
    Variables:
52
        gmp_generator {object} -- Instance of the gmp generator.
53
        authenticated {bool} -- GMP-User authenticated.
54
    """
55
56
    def __init__(self):
57
        # GMP Message Creator
58
        self.gmp_generator = _gmp()
59
60
        # Is authenticated on gvm
61
        self.authenticated = False
62
63
        # initialize variables
64
        self.sock = None
65
        self.first_element = None
66
        self.parser = None
67
        self.cmd = None
68
69
    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...
70
        for action, obj in self.parser.read_events():
71
            if not self.first_element and action in 'start':
72
                self.first_element = obj.tag
73
74
            if self.first_element and action in 'end' and str(self.first_element) == str(obj.tag):
75
                return True
76
        return False
77
78
    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...
79
        # just a stub
80
        pass
81
82
    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...
83
        # just a stub
84
        pass
85
86
    def send(self, cmd):
87
        """Call the sendAll(string) method.
88
89
        Nothing more ;-)
90
91
        Arguments:
92
            cmd {string} -- XML-Source
93
        """
94
        try:
95
            self.sendAll(cmd)
96
            logger.debug(cmd)
97
        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...
98
            print(e)
99
        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...
100
            logger.info(e)
101
            raise
102
103
    def read(self):
104
        """Call the readAll() method of the chosen connection type.
105
106
        Try to read all from the open socket connection.
107
        Check for status attribute in xml code.
108
        If the program is in shell-mode, then it returns a lxml root element,
109
        otherwise the plain xml.
110
        If the response is either None or the length is zero,
111
        then the connection was terminated from the server.
112
113
        Returns:
114
            lxml.etree._Element or <string> -- Response from server.
115
        """
116
        response = self.readAll()
117
        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...
118
            len(response), response))
119
120
        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...
121
            raise OSError('Connection was closed by remote server')
122
123
        if hasattr(self, 'raw_response') and self.raw_response is True: #pylint: disable=E1101
124
            return response
125
126
        self.checkCommandStatus(response)
127
128
        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...
129
            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...
130
131
            logger.info('Shell mode activated')
132
            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...
133
            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...
134
            return tree.getroot()
135
        else:
136
            return response
137
138
    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...
139
        try:
140
            if self.sock is not None:
141
                self.sock.close()
142
        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...
143
            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...
144
145
    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...
146
        """Check gmp response
147
148
        Look into the gmp response and check for the status in the root element
149
150
        Arguments:
151
            xml {string} -- XML-Source
152
153
        Returns:
154
            bool -- True if valid, otherwise False
155
        """
156
157
        if xml is 0 or xml is None:
158
            raise GMPError('XML Command is empty')
159
160
        try:
161
            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...
162
            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...
163
                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...
164
            else:
165
                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...
166
            status = root.attrib['status']
167
            status_text = root.attrib['status_text']
168
169
            if not self.authenticated:
170
                auth = root.find('authenticate_response')
171
                if auth is not None:
172
                    status = auth.attrib['status']
173
                    status_text = auth.attrib['status_text']
174
                    if status != '400':
175
                        self.authenticated = True
176
177
            if 'OK' not in status_text:
178
                logger.info('An error occurred on gvm: ' + status_text)
179
                raise GMPError(status_text)
180
181
        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...
182
            logger.error('etree.XML(xml): ' + str(e))
183
            raise
184
185
    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...
186
        """Convert arguments
187
188
        Converts dictionaries into gmp arguments string
189
190
        Arguments:
191
            kwargs {dict} -- Arguments
192
193
        Returns:
194
            string -- Arguments as string
195
        """
196
        msg = ''
197
        for key, value in kwargs.items():
198
            msg += str(key) + '=\'' + str(value) + '\' '
199
200
        return msg
201
202
    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...
203
        yes = set(['yes', 'y', 'ye', ''])
204
        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...
205
206
        choice = input(text).lower()
207
        if choice in yes:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
208
            return True
209
        elif choice in no:
210
            return False
211
        else:
212
            return self.ask_yes_or_no(text)
213
214
    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...
215
        """Authenticate on GVM.
216
217
        The generated authenticate command will be send to server.
218
        After that a response is read from socket.
219
220
        Keyword Arguments:
221
            username {str} -- Username
222
            password {str} -- Password
223
            withCommands {str} -- XML commands (default: {''})
224
225
        Returns:
226
            None or <string> -- Response from server.
227
        """
228
        cmd = self.gmp_generator.createAuthenticateCommand(
229
            username=username, password=password,
230
            withCommands=str(withCommand))
231
232
        self.send(cmd)
233
        return self.read()
234
235
    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...
236
                     howto_install='', howto_use=''):
237
        cmd = self.gmp_generator.createAgentCommand(
238
            installer, signature, name, comment, copy, howto_install,
239
            howto_use)
240
        self.send(cmd)
241
        return self.read()
242
243
    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...
244
                     copy='', comment=''):
245
        cmd = self.gmp_generator.createAlertCommand(name, condition, event,
246
                                                    method, filter_id, copy,
247
                                                    comment)
248
        self.send(cmd)
249
        return self.read()
250
251
    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...
252
        # 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...
253
        cmd = self.gmp_generator.createAssetCommand(name, asset_type, comment)
254
        self.send(cmd)
255
        return self.read()
256
257
    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...
258
        cmd = self.gmp_generator.createConfigCommand(copy_id, name)
259
        self.send(cmd)
260
        return self.read()
261
262
    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...
263
        cmd = self.gmp_generator.createCredentialCommand(name, kwargs)
264
        self.send(cmd)
265
        return self.read()
266
267
    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...
268
        cmd = self.gmp_generator.createFilterCommand(name, make_unique, kwargs)
269
        self.send(cmd)
270
        return self.read()
271
272
    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...
273
        cmd = self.gmp_generator.createGroupCommand(name, kwargs)
274
        self.send(cmd)
275
        return self.read()
276
277
    # 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...
278
    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...
279
        cmd = self.gmp_generator.createNoteCommand(text, nvt_oid, kwargs)
280
        self.send(cmd)
281
        return self.read()
282
283
    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...
284
        cmd = self.gmp_generator.createOverrideCommand(text, nvt_oid, kwargs)
285
        self.send(cmd)
286
        return self.read()
287
288
    def create_permission(self, name, subject_id, type, **kwargs):
0 ignored issues
show
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...
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...
289
        cmd = self.gmp_generator.createPermissionCommand(name, subject_id,
290
                                                         type, kwargs)
291
        self.send(cmd)
292
        return self.read()
293
294
    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...
295
        cmd = self.gmp_generator.createPortListCommand(name, port_range,
296
                                                       kwargs)
297
        self.send(cmd)
298
        return self.read()
299
300
    def create_port_range(self, port_list_id, start, end, type, comment=''):
0 ignored issues
show
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...
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 (6/5)
Loading history...
301
        cmd = self.gmp_generator.createPortRangeCommand(port_list_id, start,
302
                                                        end, type, comment)
303
        self.send(cmd)
304
        return self.read()
305
306
    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...
307
        cmd = self.gmp_generator.createReportCommand(report_xml_string, kwargs)
308
        self.send(cmd)
309
        return self.read()
310
311
    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...
312
        # 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...
313
        raise NotImplementedError
314
315
    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...
316
        cmd = self.gmp_generator.createRoleCommand(name, kwargs)
317
        self.send(cmd)
318
        return self.read()
319
320
    def create_scanner(self, name, host, port, type, ca_pub, credential_id,
0 ignored issues
show
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...
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...
321
                       **kwargs):
322
        cmd = self.gmp_generator.createScannerCommand(name, host, port, type,
323
                                                      ca_pub, credential_id,
324
                                                      kwargs)
325
        self.send(cmd)
326
        return self.read()
327
328
    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...
329
        cmd = self.gmp_generator.createScheduleCommand(name, kwargs)
330
        self.send(cmd)
331
        return self.read()
332
333
    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...
334
        cmd = self.gmp_generator.createTagCommand(name, resource_id,
335
                                                  resource_type, kwargs)
336
        self.send(cmd)
337
        return self.read()
338
339
    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...
340
        # TODO: Missing variables
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
341
        cmd = self.gmp_generator.createTargetCommand(name, make_unique, kwargs)
342
        self.send(cmd)
343
        return self.read()
344
345
    def create_task(self, name, config_id, target_id, scanner_id, alert_ids=None, 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...
346
        if alert_ids is None:
347
            alert_ids = []
348
        cmd = self.gmp_generator.createTaskCommand(
349
            name, config_id, target_id, scanner_id, alert_ids, comment)
350
        self.send(cmd)
351
        return self.read()
352
353
    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...
354
                    ifaces_allow='0', role_ids=(), hosts=None, ifaces=None):
355
        cmd = self.gmp_generator.createUserCommand(
356
            name, password, copy, hosts_allow, ifaces_allow, role_ids,
357
            hosts, ifaces)
358
        self.send(cmd)
359
        return self.read()
360
361
    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...
362
        self.send('<delete_agent {0}/>'.format(self.argumentsToString(kwargs)))
363
        return self.read()
364
365
    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...
366
        # if self.ask_yes_or_no('Are you sure to delete this alert? '):
367
        self.send(
368
            '<delete_alert {0}/>'.format(self.argumentsToString(kwargs)))
369
        return self.read()
370
371
    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...
372
        # if self.ask_yes_or_no('Are you sure to delete this asset? '):
373
        self.send('<delete_asset asset_id="{0}" ultimate="{1}"/>'
374
                  .format(asset_id, ultimate))
375
        return self.read()
376
377
    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...
378
        # if self.ask_yes_or_no('Are you sure to delete this config? '):
379
        self.send('<delete_config config_id="{0}" ultimate="{1}"/>'
380
                  .format(config_id, ultimate))
381
        return self.read()
382
383
    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...
384
        # if self.ask_yes_or_no('Are you sure to delete this credential? '):
385
        self.send(
386
            '<delete_credential credential_id="{0}" ultimate="{1}"/>'.format
387
            (credential_id, ultimate))
388
        return self.read()
389
390
    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...
391
        # if self.ask_yes_or_no('Are you sure to delete this filter? '):
392
        self.send('<delete_filter filter_id="{0}" ultimate="{1}"/>'
393
                  .format(filter_id, ultimate))
394
        return self.read()
395
396
    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...
397
        # if self.ask_yes_or_no('Are you sure to delete this group? '):
398
        self.send('<delete_group group_id="{0}" ultimate="{1}"/>'
399
                  .format(group_id, ultimate))
400
        return self.read()
401
402
    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...
403
        # if self.ask_yes_or_no('Are you sure to delete this note? '):
404
        self.send('<delete_note note_id="{0}" ultimate="{1}"/>'
405
                  .format(note_id, ultimate))
406
        return self.read()
407
408
    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...
409
        # if self.ask_yes_or_no('Are you sure to delete this override? '):
410
        self.send('<delete_override override_id="{0}" ultimate="{1}"/>'
411
                  .format(override_id, ultimate))
412
        return self.read()
413
414
    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...
415
        # if self.ask_yes_or_no('Are you sure to delete this permission? '):
416
        self.send('<delete_permission permission_id="{0}" ultimate="{1}"/>'
417
                  .format(permission_id, ultimate))
418
        return self.read()
419
420
    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...
421
        # if self.ask_yes_or_no('Are you sure to delete this port_list? '):
422
        self.send('<delete_port_list port_list_id="{0}" ultimate="{1}"/>'
423
                  .format(port_list_id, ultimate))
424
        return self.read()
425
426
    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...
427
        # if self.ask_yes_or_no('Are you sure to delete this port_range? '):
428
        self.send('<delete_port_range port_range_id="{0}"/>'
429
                  .format(port_range_id))
430
        return self.read()
431
432
    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...
433
        # if self.ask_yes_or_no('Are you sure to delete this report? '):
434
        self.send('<delete_report report_id="{0}"/>'
435
                  .format(report_id))
436
        return self.read()
437
438
    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...
439
        # if self.ask_yes_or_no('Are you sure to delete this report_format? '):
440
        self.send('<delete_report_format report_format_id="{0}" \
441
                   ultimate="{1}"/>'.format(report_format_id, ultimate))
442
        return self.read()
443
444
    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...
445
        # if self.ask_yes_or_no('Are you sure to delete this role? '):
446
        self.send('<delete_role role_id="{0}" ultimate="{1}"/>'
447
                  .format(role_id, ultimate))
448
        return self.read()
449
450
    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...
451
        # if self.ask_yes_or_no('Are you sure to delete this scanner? '):
452
        self.send('<delete_scanner scanner_id="{0}" ultimate="{1}"/>'
453
                  .format(scanner_id, ultimate))
454
        return self.read()
455
456
    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...
457
        # if self.ask_yes_or_no('Are you sure to delete this schedule? '):
458
        self.send('<delete_schedule schedule_id="{0}" ultimate="{1}"/>'
459
                  .format(schedule_id, ultimate))
460
        return self.read()
461
462
    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...
463
        # if self.ask_yes_or_no('Are you sure to delete this tag? '):
464
        self.send('<delete_tag tag_id="{0}" ultimate="{1}"/>'
465
                  .format(tag_id, ultimate))
466
        return self.read()
467
468
    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...
469
        # if self.ask_yes_or_no('Are you sure to delete this target? '):
470
        self.send('<delete_target target_id="{0}" ultimate="{1}"/>'
471
                  .format(target_id, ultimate))
472
        return self.read()
473
474
    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...
475
        # if self.ask_yes_or_no('Are you sure to delete this task? '):
476
        self.send('<delete_task task_id="{0}" ultimate="{1}"/>'
477
                  .format(task_id, ultimate))
478
        return self.read()
479
480
    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...
481
        user_id = kwargs.get('user_id', '')
482
        if user_id:
483
            user_id = ' user_id="%s"' % user_id
484
485
        name = kwargs.get('name', '')
486
        if name:
487
            name = ' name="%s"' % name
488
489
        inheritor_id = kwargs.get('inheritor_id', '')
490
        if inheritor_id:
491
            inheritor_id = ' inheritor_id="%s"' % inheritor_id
492
493
        inheritor_name = kwargs.get('inheritor_name', '')
494
        if inheritor_name:
495
            inheritor_name = ' inheritor_name="%s"' % inheritor_name
496
497
        self.send('<delete_user{0}{1}{2}{3}/>'
498
                  .format(user_id, name, inheritor_id, inheritor_name))
499
        return self.read()
500
501
    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...
502
        self.send('<describe_auth/>')
503
        return self.read()
504
505
    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...
506
        self.send('<empty_trashcan/>')
507
        return self.read()
508
509
    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...
510
        self.send('<get_agents {0}/>'.format(self.argumentsToString(kwargs)))
511
        return self.read()
512
513
    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...
514
        self.send(
515
            '<get_aggregates {0}/>'.format(self.argumentsToString(kwargs)))
516
        return self.read()
517
518
    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...
519
        self.send('<get_alerts {0}/>'.format(self.argumentsToString(kwargs)))
520
        return self.read()
521
522
    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...
523
        self.send('<get_assets {0}/>'.format(self.argumentsToString(kwargs)))
524
        return self.read()
525
526
    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...
527
        self.send(
528
            '<get_credentials {0}/>'.format(self.argumentsToString(kwargs)))
529
        return self.read()
530
531
    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...
532
        self.send('<get_configs {0}/>'.format(self.argumentsToString(kwargs)))
533
        return self.read()
534
535
    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...
536
        self.send('<get_feeds {0}/>'.format(self.argumentsToString(kwargs)))
537
        return self.read()
538
539
    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...
540
        self.send('<get_filters {0}/>'.format(self.argumentsToString(kwargs)))
541
        return self.read()
542
543
    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...
544
        self.send('<get_groups {0}/>'.format(self.argumentsToString(kwargs)))
545
        return self.read()
546
547
    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...
548
        self.send('<get_info {0}/>'.format(self.argumentsToString(kwargs)))
549
        return self.read()
550
551
    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...
552
        self.send('<get_notes {0}/>'.format(self.argumentsToString(kwargs)))
553
        return self.read()
554
555
    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...
556
        self.send('<get_nvts {0}/>'.format(self.argumentsToString(kwargs)))
557
        return self.read()
558
559
    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...
560
        self.send(
561
            '<get_nvt_families {0}/>'.format(self.argumentsToString(kwargs)))
562
        return self.read()
563
564
    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...
565
        self.send(
566
            '<get_overrides {0}/>'.format(self.argumentsToString(kwargs)))
567
        return self.read()
568
569
    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...
570
        self.send(
571
            '<get_permissions {0}/>'.format(self.argumentsToString(kwargs)))
572
        return self.read()
573
574
    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...
575
        self.send(
576
            '<get_port_lists {0}/>'.format(self.argumentsToString(kwargs)))
577
        return self.read()
578
579
    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...
580
        self.send(
581
            '<get_preferences {0}/>'.format(self.argumentsToString(kwargs)))
582
        return self.read()
583
584
    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...
585
        self.send('<get_reports {0}/>'
586
                  .format(self.argumentsToString(kwargs)))
587
        return self.read()
588
589
    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...
590
        self.send(
591
            '<get_report_formats {0}/>'.format(self.argumentsToString(kwargs)))
592
        return self.read()
593
594
    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...
595
        self.send('<get_results {0}/>'.format(self.argumentsToString(kwargs)))
596
        return self.read()
597
598
    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...
599
        self.send('<get_roles {0}/>'.format(self.argumentsToString(kwargs)))
600
        return self.read()
601
602
    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...
603
        self.send('<get_scanners {0}/>'.format(self.argumentsToString(kwargs)))
604
        return self.read()
605
606
    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...
607
        self.send(
608
            '<get_schedules {0}/>'.format(self.argumentsToString(kwargs)))
609
        return self.read()
610
611
    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...
612
        self.send('<get_settings {0}/>'.format(self.argumentsToString(kwargs)))
613
        return self.read()
614
615
    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...
616
        self.send(
617
            '<get_system_reports {0}/>'.format(self.argumentsToString(kwargs)))
618
        return self.read()
619
620
    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...
621
        self.send('<get_tags {0}/>'.format(self.argumentsToString(kwargs)))
622
        return self.read()
623
624
    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...
625
        self.send('<get_targets {0}/>'.format(self.argumentsToString(kwargs)))
626
        return self.read()
627
628
    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...
629
        self.send('<get_tasks {0}/>'.format(self.argumentsToString(kwargs)))
630
        return self.read()
631
632
    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...
633
        self.send('<get_users {0}/>'.format(self.argumentsToString(kwargs)))
634
        return self.read()
635
636
    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...
637
        self.send('<get_version/>')
638
        return self.read()
639
640
    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...
641
        self.send('<help {0} />'.format(self.argumentsToString(kwargs)))
642
        return self.read()
643
644
    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...
645
        cmd = self.gmp_generator.modifyAgentCommand(agent_id, name, comment)
646
        self.send(cmd)
647
        return self.read()
648
649
    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...
650
        cmd = self.gmp_generator.modifyAlertCommand(alert_id, kwargs)
651
        self.send(cmd)
652
        return self.read()
653
654
    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...
655
        cmd = '<modify_asset asset_id="%s"><comment>%s</comment>' \
656
              '</modify_asset>' % (asset_id, comment)
657
        self.send(cmd)
658
        return self.read()
659
660
    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...
661
        cmd = self.gmp_generator.modifyAuthCommand(group_name,
662
                                                   auth_conf_settings)
663
        self.send(cmd)
664
        return self.read()
665
666
    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...
667
        cmd = self.gmp_generator.modifyConfigCommand(selection, kwargs)
668
        self.send(cmd)
669
        return self.read()
670
671
    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...
672
        cmd = self.gmp_generator.modifyCredentialCommand(credential_id, kwargs)
673
        self.send(cmd)
674
        return self.read()
675
676
    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...
677
        cmd = self.gmp_generator.modifyFilterCommand(filter_id, kwargs)
678
        self.send(cmd)
679
        return self.read()
680
681
    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...
682
        cmd = self.gmp_generator.modifyGroupCommand(group_id, kwargs)
683
        self.send(cmd)
684
        return self.read()
685
686
    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...
687
        cmd = self.gmp_generator.modifyNoteCommand(note_id, text, kwargs)
688
        self.send(cmd)
689
        return self.read()
690
691
    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...
692
        cmd = self.gmp_generator.modifyOverrideCommand(override_id, text,
693
                                                       kwargs)
694
        self.send(cmd)
695
        return self.read()
696
697
    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...
698
        cmd = self.gmp_generator.modifyPermissionCommand(permission_id, kwargs)
699
        self.send(cmd)
700
        return self.read()
701
702
    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...
703
        cmd = self.gmp_generator.modifyPortListCommand(port_list_id, kwargs)
704
        self.send(cmd)
705
        return self.read()
706
707
    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...
708
        cmd = '<modify_report report_id="{0}"><comment>{1}</comment>' \
709
              '</modify_report>'.format(report_id, comment)
710
        self.send(cmd)
711
        return self.read()
712
713
    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...
714
        cmd = self.gmp_generator.modifyReportFormatCommand(report_format_id,
715
                                                           kwargs)
716
        self.send(cmd)
717
        return self.read()
718
719
    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...
720
        cmd = self.gmp_generator.modifyRoleCommand(role_id, kwargs)
721
        self.send(cmd)
722
        return self.read()
723
724
    def modify_scanner(self, scanner_id, host, port, type, **kwargs):
0 ignored issues
show
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...
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...
725
        cmd = self.gmp_generator.modifyScannerCommand(scanner_id, host, port,
726
                                                      type, kwargs)
727
        self.send(cmd)
728
        return self.read()
729
730
    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...
731
        cmd = self.gmp_generator.modifyScheduleCommand(schedule_id, kwargs)
732
        self.send(cmd)
733
        return self.read()
734
735
    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...
736
        cmd = '<modify_setting setting_id="{0}"><name>{1}</name>' \
737
              '<value>{2}</value></modify_setting>' \
738
              ''.format(setting_id, name, value)
739
        self.send(cmd)
740
        return self.read()
741
742
    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...
743
        cmd = self.gmp_generator.modifyTagCommand(tag_id, kwargs)
744
        self.send(cmd)
745
        return self.read()
746
747
    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...
748
        cmd = self.gmp_generator.modifyTargetCommand(target_id, kwargs)
749
        self.send(cmd)
750
        return self.read()
751
752
    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...
753
        cmd = self.gmp_generator.modifyTaskCommand(task_id, kwargs)
754
        self.send(cmd)
755
        return self.read()
756
757
    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...
758
        cmd = self.gmp_generator.modifyUserCommand(kwargs)
759
        self.send(cmd)
760
        return self.read()
761
762
    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...
763
        self.send('<move_task task_id="{0}" slave_id="{1}"/>'
764
                  .format(task_id, slave_id))
765
        return self.read()
766
767
    def restore(self, id):
0 ignored issues
show
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...
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...
768
        self.send('<restore id="{0}"/>'.format(id))
769
        return self.read()
770
771
    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...
772
        self.send('<resume_task task_id="{0}"/>'.format(task_id))
773
        return self.read()
774
775
    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...
776
        # TODO: Is this required?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
777
        raise NotImplementedError
778
779
    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...
780
        self.send('<start_task task_id="{0}"/>'.format(task_id))
781
        return self.read()
782
783
    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...
784
        self.send('<stop_task task_id="{0}"/>'.format(task_id))
785
        return self.read()
786
787
    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...
788
        self.send('<sync_cert/>')
789
        return self.read()
790
791
    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...
792
        self.send('<sync_config/>')
793
        return self.read()
794
795
    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...
796
        self.send('<sync_feed/>')
797
        return self.read()
798
799
    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...
800
        self.send('<sync_scap/>')
801
        return self.read()
802
803
    def test_alert(self, id):
0 ignored issues
show
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...
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...
804
        self.send('<test_alert alert_id="{0}"/>'.format(id))
805
        return self.read()
806
807
    def verify_agent(self, id):
0 ignored issues
show
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...
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...
808
        self.send('<verify_agent agent_id="{0}"/>'.format(id))
809
        return self.read()
810
811
    def verify_report_format(self, id):
0 ignored issues
show
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...
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...
812
        self.send('<verify_report_format report_format_id="{0}"/>'.format(id))
813
        return self.read()
814
815
    def verify_scanner(self, id):
0 ignored issues
show
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...
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...
816
        self.send('<verify_scanner scanner_id="{0}"/>'.format(id))
817
        return self.read()
818
819
820
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...
821
    """SSH Class to connect, read and write from GVM via SSH
822
823
    [description]
824
825
    Variables:
826
        sock {[type]} -- Channel from paramiko after successful connection
827
828
    """
829
830
    def __init__(self, **kwargs):
831
        super().__init__()
832
        self.hostname = kwargs.get('hostname', '127.0.0.1')
833
        self.port = kwargs.get('port', 22)
834
        self.raw_response = kwargs.get('raw_response', False)
835
        self.timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
836
        self.ssh_user = kwargs.get('ssh_user', 'gmp')
837
        self.ssh_password = kwargs.get('ssh_password', '')
838
        self.shell_mode = kwargs.get('shell_mode', False)
839
        self.sock = paramiko.SSHClient()
840
        # self.sock.load_system_host_keys()
841
        # self.sock.set_missing_host_key_policy(paramiko.WarningPolicy())
842
        self.sock.set_missing_host_key_policy(paramiko.AutoAddPolicy())
843
844
        try:
845
            self.sock.connect(
846
                hostname=self.hostname,
847
                username=self.ssh_user,
848
                password=self.ssh_password,
849
                timeout=self.timeout,
850
                port=int(self.port),
851
                allow_agent=False,
852
                look_for_keys=False)
853
            self.stdin, self.stdout, self.stderr = self.sock.exec_command("", get_pty=False)
854
855
        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...
856
                paramiko.AuthenticationException,
857
                paramiko.SSHException, OSError) as e:
858
            logger.debug('SSH Connection failed: ' + str(e))
859
            raise
860
861
    def readAll(self):
862
        self.first_element = None
863
        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...
864
865
        response = ''
866
867
        while True:
868
            data = self.stdout.channel.recv(BUF_SIZE)
869
            # Connection was closed by server
870
            if not data:
871
                break
872
873
            self.parser.feed(data)
874
875
            response += data.decode('utf-8')
876
877
            if self.valid_xml():
878
                break
879
        return response
880
881
    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...
882
        """ Receive the cmd string longer than max_len
883
        and send it in blocks not longer than max_len.
884
885
        Input:
886
           max_len  The max length of a block to be sent.
887
        """
888
        i_start = 0;
0 ignored issues
show
Coding Style introduced by
Unnecessary semicolon
Loading history...
889
        i_end = max_len
890
        sent_bytes = 0
891
        while sent_bytes < len(self.cmd):
892
            time.sleep(0.01)
893
            self.stdin.channel.send(self.cmd[i_start:i_end])
894
            i_start = i_end
895
            if i_end > len(self.cmd):
896
                i_end = len(self.cmd)
897
            else:
898
                i_end = i_end + max_len
899
            sent_bytes += (i_end - i_start)
900
901
        return sent_bytes
902
903
    def sendAll(self, cmd, max_len=4095):
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'sendAll' method
Loading history...
904
        logger.debug('SSH:send(): ' + cmd)
905
        self.cmd = str(cmd)
906
        if len(self.cmd) > max_len:
907
            sent_bytes = self.cmdSplitter(max_len)
908
            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...
909
        else:
910
            self.stdin.channel.send(self.cmd)
911
912
class TLSConnection(GVMConnection):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/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...
913
    """TLS class to connect, read and write from GVM via tls secured socket
914
915
    [description]
916
917
    Variables:
918
        sock {socket.socket} -- Socket that holds the connection
919
    """
920
921
    def __init__(self, **kwargs):
922
        super().__init__()
923
        self.hostname = kwargs.get('hostname', '127.0.0.1')
924
        self.port = kwargs.get('port', 9390)
925
        self.raw_response = kwargs.get('raw_response', False)
926
        self.timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
927
        self.shell_mode = kwargs.get('shell_mode', False)
928
        self.cert = kwargs.get('certfile', None)
929
        self.cacert = kwargs.get('cafile', None)
930
        self.key = kwargs.get('keyfile', None)
931
        if self.cert and self.cacert and self.key:
932
            context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
933
                                                 cafile=self.cacert)
934
            context.check_hostname = False
935
            context.load_cert_chain(certfile=self.cert, keyfile=self.key)
936
            new_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
937
            self.sock = context.wrap_socket(new_socket, server_side=False)
938
        else:
939
            context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
940
            self.sock = context.wrap_socket(socket.socket(socket.AF_INET))
941
        self.sock.settimeout(self.timeout)
942
        self.sock.connect((self.hostname, int(self.port)))
943
944
    def sendAll(self, cmd):
945
        self.sock.send(cmd.encode())
946
947
    def readAll(self):
948
        response = ''
949
        while True:
950
            data = self.sock.read(BUF_SIZE)
951
952
            response += data.decode(errors='ignore')
953
            if len(data) < BUF_SIZE:
954
                break
955
        return response
956
957
958
class UnixSocketConnection(GVMConnection):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (8/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...
959
    """UNIX-Socket class to connect, read, write from GVM
960
    via direct communicating UNIX-Socket
961
962
    [description]
963
964
    Variables:
965
        sock {socket.socket} -- Socket that holds the connection
966
        sockpath {string} -- Path to UNIX-Socket
967
    """
968
969
    def __init__(self, **kwargs):
970
        super().__init__()
971
        self.raw_response = kwargs.get('raw_response', False)
972
        self.sockpath = kwargs.get('sockpath',
973
                                   '/usr/local/var/run/gvmd.sock')
974
        self.shell_mode = kwargs.get('shell_mode', False)
975
        self.timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
976
        self.read_timeout = kwargs.get('read_timeout', DEFAULT_READ_TIMEOUT)
977
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) #pylint: disable=E1101
978
        self.sock.settimeout(self.timeout)
979
        self.sock.connect(self.sockpath)
980
981
    def readAll(self):
982
        self.first_element = None
983
        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...
984
        response = ''
985
986
        read_timeout = self.read_timeout
987
        break_timeout = time.time() + read_timeout
988
        old_timeout = self.sock.gettimeout()
989
        self.sock.settimeout(5)  # in seconds
990
991
        while time.time() < break_timeout:
992
            data = b''
993
            try:
994
                data = self.sock.recv(BUF_SIZE)
995
            except (socket.timeout) as exception:
996
                logger.debug('Warning: No data recieved from server: {0}'.format(exception))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
997
                continue
998
            self.parser.feed(data)
999
            response += data.decode('utf-8')
1000
            if len(data) < BUF_SIZE:
1001
                if self.valid_xml():
1002
                    break
1003
1004
        self.sock.settimeout(old_timeout)
1005
        return response
1006
1007
    def sendAll(self, cmd):
1008
        self.sock.send(cmd.encode())
1009