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

gmp.gvm_connection.GVMConnection.valid_xml()   B

Complexity

Conditions 7

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 7
nop 1
dl 0
loc 8
rs 8
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

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

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

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

Loading history...
2
# Description:
3
# GVM-Connection classes for communication with the GVM.
4
#
5
# Authors:
6
# Raphael Grewe <[email protected]>
7
#
8
# Copyright:
9
# Copyright (C) 2017 Greenbone Networks GmbH
10
#
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
15
#
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24
import logging
25
import socket
26
import ssl
27
import time
28
from io import StringIO
29
30
from lxml import etree
31
import paramiko
32
33
from gmp.gmp import _gmp
34
35
logger = logging.getLogger(__name__)
0 ignored issues
show
Coding Style Naming introduced by
The name logger does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

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

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

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

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

Loading history...
36
37
BUF_SIZE = 1024
38
39
40
class GMPError(Exception):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

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

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

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

Loading history...
41
    pass
42
43
44
class GVMConnection:
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
best-practice introduced by
Too many public methods (121/20)
Loading history...
45
    """Wrapper for GMP
46
47
    This class helps users to connect to their GVM via Secure Shell,
48
    UNIX-Socket or secured connection on port 9390.
49
50
    Variables:
51
        gmp_generator {object} -- Instance of the gmp generator.
52
        authenticated {bool} -- GMP-User authenticated.
53
    """
54
55
    def __init__(self):
56
        # GMP Message Creator
57
        self.gmp_generator = _gmp()
58
59
        # Is authenticated on gvm
60
        self.authenticated = False
61
62
        # initialize variables
63
        self.sock = None
64
        self.first_element = None
65
        self.parser = None
66
        self.cmd = None
67
68
    def valid_xml(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
69
        for action, obj in self.parser.read_events():
70
            if not self.first_element and action in 'start':
71
                self.first_element = obj.tag
72
73
            if self.first_element and action in 'end' and str(self.first_element) == str(obj.tag):
74
                return True
75
        return False
76
77
    def readAll(self):
0 ignored issues
show
Coding Style Naming introduced by
The name readAll does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
78
        # just a stub
79
        pass
80
81
    def sendAll(self, cmd):
0 ignored issues
show
Coding Style Naming introduced by
The name sendAll does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
82
        # just a stub
83
        pass
84
85
    def send(self, cmd):
86
        """Call the sendAll(string) method.
87
88
        Nothing more ;-)
89
90
        Arguments:
91
            cmd {string} -- XML-Source
92
        """
93
        try:
94
            self.sendAll(cmd)
95
            logger.debug(cmd)
96
        except paramiko.SSHException as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
97
            print(e)
98
        except OSError as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
99
            logger.info(e)
100
            raise
101
102
    def read(self):
103
        """Call the readAll() method of the chosen connection type.
104
105
        Try to read all from the open socket connection.
106
        Check for status attribute in xml code.
107
        If the program is in shell-mode, then it returns a lxml root element,
108
        otherwise the plain xml.
109
        If the response is either None or the length is zero,
110
        then the connection was terminated from the server.
111
112
        Returns:
113
            lxml.etree._Element or <string> -- Response from server.
114
        """
115
        response = self.readAll()
116
        logger.debug('read() {0} Bytes response: {1}'.format(
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
117
            len(response), response))
118
119
        if response is None or len(str(response)) == 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
120
            raise OSError('Connection was closed by remote server')
121
122
        if hasattr(self, 'raw_response') and self.raw_response is True: #pylint: disable=E1101
123
            return response
124
125
        self.checkCommandStatus(response)
126
127
        if hasattr(self, 'shell_mode') and self.shell_mode is True: #pylint: disable=E1101
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
128
            parser = etree.XMLParser(encoding='utf-8', recover=True)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLParser.

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

The member could have been renamed or removed.

Loading history...
129
130
            logger.info('Shell mode activated')
131
            f = StringIO(response)
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
132
            tree = etree.parse(f, parser)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named parse.

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

The member could have been renamed or removed.

Loading history...
133
            return tree.getroot()
134
        else:
135
            return response
136
137
    def close(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
138
        try:
139
            if self.sock is not None:
140
                self.sock.close()
141
        except OSError as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
142
            logger.debug('Connection closing error: {0}'.format(e))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
143
144
    def checkCommandStatus(self, xml):
0 ignored issues
show
Coding Style Naming introduced by
The name checkCommandStatus does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
145
        """Check gmp response
146
147
        Look into the gmp response and check for the status in the root element
148
149
        Arguments:
150
            xml {string} -- XML-Source
151
152
        Returns:
153
            bool -- True if valid, otherwise False
154
        """
155
156
        if xml is 0 or xml is None:
157
            raise GMPError('XML Command is empty')
158
159
        try:
160
            parser = etree.XMLParser(encoding='utf-8', recover=True)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XMLParser.

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

The member could have been renamed or removed.

Loading history...
161
            if etree.iselement(xml):
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named iselement.

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

The member could have been renamed or removed.

Loading history...
162
                root = etree.ElementTree(xml, parser=parser).getroot()
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named ElementTree.

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

The member could have been renamed or removed.

Loading history...
163
            else:
164
                root = etree.XML(xml, parser=parser)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named XML.

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

The member could have been renamed or removed.

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

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

The member could have been renamed or removed.

Loading history...
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
181
            logger.error('etree.XML(xml): ' + str(e))
182
            raise
183
184
    def argumentsToString(self, kwargs):
0 ignored issues
show
Coding Style Naming introduced by
The name argumentsToString does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
185
        """Convert arguments
186
187
        Converts dictionaries into gmp arguments string
188
189
        Arguments:
190
            kwargs {dict} -- Arguments
191
192
        Returns:
193
            string -- Arguments as string
194
        """
195
        msg = ''
196
        for key, value in kwargs.items():
197
            msg += str(key) + '=\'' + str(value) + '\' '
198
199
        return msg
200
201
    def ask_yes_or_no(self, text):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
202
        yes = set(['yes', 'y', 'ye', ''])
203
        no = set(['no', 'n'])
0 ignored issues
show
Coding Style Naming introduced by
The name no does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
204
205
        choice = input(text).lower()
206
        if choice in yes:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
207
            return True
208
        elif choice in no:
209
            return False
210
        else:
211
            return self.ask_yes_or_no(text)
212
213
    def authenticate(self, username, password, withCommand=''):
0 ignored issues
show
Coding Style Naming introduced by
The name withCommand does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
214
        """Authenticate on GVM.
215
216
        The generated authenticate command will be send to server.
217
        After that a response is read from socket.
218
219
        Keyword Arguments:
220
            username {str} -- Username
221
            password {str} -- Password
222
            withCommands {str} -- XML commands (default: {''})
223
224
        Returns:
225
            None or <string> -- Response from server.
226
        """
227
        cmd = self.gmp_generator.createAuthenticateCommand(
228
            username=username, password=password,
229
            withCommands=str(withCommand))
230
231
        self.send(cmd)
232
        return self.read()
233
234
    def create_agent(self, installer, signature, name, comment='', copy='',
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
best-practice introduced by
Too many arguments (8/5)
Loading history...
235
                     howto_install='', howto_use=''):
236
        cmd = self.gmp_generator.createAgentCommand(
237
            installer, signature, name, comment, copy, howto_install,
238
            howto_use)
239
        self.send(cmd)
240
        return self.read()
241
242
    def create_alert(self, name, condition, event, method, filter_id='',
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
best-practice introduced by
Too many arguments (8/5)
Loading history...
243
                     copy='', comment=''):
244
        cmd = self.gmp_generator.createAlertCommand(name, condition, event,
245
                                                    method, filter_id, copy,
246
                                                    comment)
247
        self.send(cmd)
248
        return self.read()
249
250
    def create_asset(self, name, asset_type, comment=''):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
251
        # TODO: Add the missing second method. Also the docs are not complete!
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
252
        cmd = self.gmp_generator.createAssetCommand(name, asset_type, comment)
253
        self.send(cmd)
254
        return self.read()
255
256
    def create_config(self, copy_id, name):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
257
        cmd = self.gmp_generator.createConfigCommand(copy_id, name)
258
        self.send(cmd)
259
        return self.read()
260
261
    def create_credential(self, name, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
262
        cmd = self.gmp_generator.createCredentialCommand(name, kwargs)
263
        self.send(cmd)
264
        return self.read()
265
266
    def create_filter(self, name, make_unique, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
267
        cmd = self.gmp_generator.createFilterCommand(name, make_unique, kwargs)
268
        self.send(cmd)
269
        return self.read()
270
271
    def create_group(self, name, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
272
        cmd = self.gmp_generator.createGroupCommand(name, kwargs)
273
        self.send(cmd)
274
        return self.read()
275
276
    # TODO: Create notes with comment returns bogus element. Research
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
277
    def create_note(self, text, nvt_oid, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
278
        cmd = self.gmp_generator.createNoteCommand(text, nvt_oid, kwargs)
279
        self.send(cmd)
280
        return self.read()
281
282
    def create_override(self, text, nvt_oid, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
283
        cmd = self.gmp_generator.createOverrideCommand(text, nvt_oid, kwargs)
284
        self.send(cmd)
285
        return self.read()
286
287
    def create_permission(self, name, subject_id, type, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

Loading history...
288
        cmd = self.gmp_generator.createPermissionCommand(name, subject_id,
289
                                                         type, kwargs)
290
        self.send(cmd)
291
        return self.read()
292
293
    def create_port_list(self, name, port_range, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
294
        cmd = self.gmp_generator.createPortListCommand(name, port_range,
295
                                                       kwargs)
296
        self.send(cmd)
297
        return self.read()
298
299
    def create_port_range(self, port_list_id, start, end, type, comment=''):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

Loading history...
best-practice introduced by
Too many arguments (6/5)
Loading history...
300
        cmd = self.gmp_generator.createPortRangeCommand(port_list_id, start,
301
                                                        end, type, comment)
302
        self.send(cmd)
303
        return self.read()
304
305
    def create_report(self, report_xml_string, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
306
        cmd = self.gmp_generator.createReportCommand(report_xml_string, kwargs)
307
        self.send(cmd)
308
        return self.read()
309
310
    def create_report_format(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
311
        # TODO: Seems to be a complex task. It is needed?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
312
        raise NotImplementedError
313
314
    def create_role(self, name, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
315
        cmd = self.gmp_generator.createRoleCommand(name, kwargs)
316
        self.send(cmd)
317
        return self.read()
318
319
    def create_scanner(self, name, host, port, type, ca_pub, credential_id,
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

Loading history...
best-practice introduced by
Too many arguments (7/5)
Loading history...
320
                       **kwargs):
321
        cmd = self.gmp_generator.createScannerCommand(name, host, port, type,
322
                                                      ca_pub, credential_id,
323
                                                      kwargs)
324
        self.send(cmd)
325
        return self.read()
326
327
    def create_schedule(self, name, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
328
        cmd = self.gmp_generator.createScheduleCommand(name, kwargs)
329
        self.send(cmd)
330
        return self.read()
331
332
    def create_tag(self, name, resource_id, resource_type, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
333
        cmd = self.gmp_generator.createTagCommand(name, resource_id,
334
                                                  resource_type, kwargs)
335
        self.send(cmd)
336
        return self.read()
337
338
    def create_target(self, name, make_unique, **kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

Loading history...
724
        cmd = self.gmp_generator.modifyScannerCommand(scanner_id, host, port,
725
                                                      type, kwargs)
726
        self.send(cmd)
727
        return self.read()
728
729
    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...
730
        cmd = self.gmp_generator.modifyScheduleCommand(schedule_id, kwargs)
731
        self.send(cmd)
732
        return self.read()
733
734
    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...
735
        cmd = '<modify_setting setting_id="{0}"><name>{1}</name>' \
736
              '<value>{2}</value></modify_setting>' \
737
              ''.format(setting_id, name, value)
738
        self.send(cmd)
739
        return self.read()
740
741
    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...
742
        cmd = self.gmp_generator.modifyTagCommand(tag_id, kwargs)
743
        self.send(cmd)
744
        return self.read()
745
746
    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...
747
        cmd = self.gmp_generator.modifyTargetCommand(target_id, kwargs)
748
        self.send(cmd)
749
        return self.read()
750
751
    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...
752
        cmd = self.gmp_generator.modifyTaskCommand(task_id, kwargs)
753
        self.send(cmd)
754
        return self.read()
755
756
    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...
757
        cmd = self.gmp_generator.modifyUserCommand(kwargs)
758
        self.send(cmd)
759
        return self.read()
760
761
    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...
762
        self.send('<move_task task_id="{0}" slave_id="{1}"/>'
763
                  .format(task_id, slave_id))
764
        return self.read()
765
766
    def restore(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

Loading history...
767
        self.send('<restore id="{0}"/>'.format(id))
768
        return self.read()
769
770
    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...
771
        self.send('<resume_task task_id="{0}"/>'.format(task_id))
772
        return self.read()
773
774
    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...
775
        # TODO: Is this required?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
776
        raise NotImplementedError
777
778
    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...
779
        self.send('<start_task task_id="{0}"/>'.format(task_id))
780
        return self.read()
781
782
    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...
783
        self.send('<stop_task task_id="{0}"/>'.format(task_id))
784
        return self.read()
785
786
    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...
787
        self.send('<sync_cert/>')
788
        return self.read()
789
790
    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...
791
        self.send('<sync_config/>')
792
        return self.read()
793
794
    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...
795
        self.send('<sync_feed/>')
796
        return self.read()
797
798
    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...
799
        self.send('<sync_scap/>')
800
        return self.read()
801
802
    def test_alert(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

Loading history...
803
        self.send('<test_alert alert_id="{0}"/>'.format(id))
804
        return self.read()
805
806
    def verify_agent(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

Loading history...
807
        self.send('<verify_agent agent_id="{0}"/>'.format(id))
808
        return self.read()
809
810
    def verify_report_format(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

Loading history...
811
        self.send('<verify_report_format report_format_id="{0}"/>'.format(id))
812
        return self.read()
813
814
    def verify_scanner(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

Loading history...
best-practice introduced by
Too many instance attributes (14/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
820
    """SSH Class to connect, read and write from GVM via SSH
821
822
    [description]
823
824
    Variables:
825
        sock {[type]} -- Channel from paramiko after successful connection
826
827
    """
828
829
    def __init__(self, **kwargs):
830
        super().__init__()
831
        self.hostname = kwargs.get('hostname', '127.0.0.1')
832
        self.port = kwargs.get('port', 22)
833
        self.raw_response = kwargs.get('raw_response', False)
834
        self.timeout = kwargs.get('timeout', 5)
835
        self.ssh_user = kwargs.get('ssh_user', 'gmp')
836
        self.ssh_password = kwargs.get('ssh_password', '')
837
        self.shell_mode = kwargs.get('shell_mode', False)
838
        self.sock = paramiko.SSHClient()
839
        # self.sock.load_system_host_keys()
840
        # self.sock.set_missing_host_key_policy(paramiko.WarningPolicy())
841
        self.sock.set_missing_host_key_policy(paramiko.AutoAddPolicy())
842
843
        try:
844
            self.sock.connect(
845
                hostname=self.hostname,
846
                username=self.ssh_user,
847
                password=self.ssh_password,
848
                timeout=self.timeout,
849
                port=int(self.port),
850
                allow_agent=False,
851
                look_for_keys=False)
852
            self.stdin, self.stdout, self.stderr = self.sock.exec_command("", get_pty=False)
853
854
        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...
855
                paramiko.AuthenticationException,
856
                paramiko.SSHException, OSError) as e:
857
            logger.debug('SSH Connection failed: ' + str(e))
858
            raise
859
860
    def readAll(self):
861
        self.first_element = None
862
        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...
863
864
        response = ''
865
866
        while True:
867
            data = self.stdout.channel.recv(BUF_SIZE)
868
            # Connection was closed by server
869
            if not data:
870
                break
871
872
            self.parser.feed(data)
873
874
            response += data.decode('utf-8')
875
876
            if self.valid_xml():
877
                break
878
        return response
879
880
    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...
881
        """ Receive the cmd string longer than max_len
882
        and send it in blocks not longer than max_len.
883
884
        Input:
885
           max_len  The max length of a block to be sent.
886
        """
887
        i_start = 0;
0 ignored issues
show
Coding Style introduced by
Unnecessary semicolon
Loading history...
888
        i_end = max_len
889
        sent_bytes = 0
890
        while sent_bytes < len(self.cmd):
891
            time.sleep(0.01)
892
            self.stdin.channel.send(self.cmd[i_start:i_end])
893
            i_start = i_end
894
            if i_end > len(self.cmd):
895
                i_end = len(self.cmd)
896
            else:
897
                i_end = i_end + max_len
898
            sent_bytes += (i_end - i_start)
899
900
        return sent_bytes
901
902
    def sendAll(self, cmd, max_len=4095):
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'sendAll' method
Loading history...
903
        logger.debug('SSH:send(): ' + cmd)
904
        self.cmd = str(cmd)
905
        if len(self.cmd) > max_len:
906
            sent_bytes = self.cmdSplitter(max_len)
907
            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...
908
        else:
909
            self.stdin.channel.send(self.cmd)
910
911
class TLSConnection(GVMConnection):
0 ignored issues
show
Bug introduced by
The method create_report_format which was declared abstract in the super-class GVMConnection
was not overridden.

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

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

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

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

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

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

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

Loading history...
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
947
    """UNIX-Socket class to connect, read, write from GVM
948
    via direct communicating UNIX-Socket
949
950
    [description]
951
952
    Variables:
953
        sock {socket.socket} -- Socket that holds the connection
954
        sockpath {string} -- Path to UNIX-Socket
955
    """
956
957
    def __init__(self, **kwargs):
958
        super().__init__()
959
        self.raw_response = kwargs.get('raw_response', False)
960
        self.sockpath = kwargs.get('sockpath',
961
                                   '/usr/local/var/run/gvmd.sock')
962
        self.shell_mode = kwargs.get('shell_mode', False)
963
        self.timeout = kwargs.get('timeout', 60)
964
        self.read_timeout = kwargs.get('read_timeout', 30)
965
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) #pylint: disable=E1101
966
        self.sock.settimeout(self.timeout)
967
        self.sock.connect(self.sockpath)
968
969
    def readAll(self):
970
        self.first_element = None
971
        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...
972
        response = ''
973
974
        read_timeout = self.read_timeout
975
        break_timeout = time.time() + read_timeout
976
        old_timeout = self.sock.gettimeout()
977
        self.sock.settimeout(5)
978
979
        while time.time() < break_timeout:
980
            data = b''
981
            try:
982
                data = self.sock.recv(BUF_SIZE)
983
            except (socket.timeout) as exception:
984
                logger.debug('Warning: No data recieve from server: {0}'.format(exception))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
985
            self.parser.feed(data)
986
            response += data.decode('utf-8')
987
            if len(data) < BUF_SIZE:
988
                if self.valid_xml():
989
                    break
990
991
        self.sock.settimeout(old_timeout)
992
        return response
993
994
    def sendAll(self, cmd):
995
        self.sock.send(cmd.encode())
996