Passed
Pull Request — master (#55)
by
unknown
01:26
created

gmp.gvm_connection.GVMConnection.cmdSplitter()   A

Complexity

Conditions 3

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nop 2
dl 0
loc 27
rs 9.65
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
65
    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...
66
        # just a stub
67
        pass
68
69
    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...
70
        # just a stub
71
        pass
72
73
    @staticmethod
74
    def cmdSplitter(cmd, 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...
75
        """ Receive the cmd string longer than max_len
76
        and insert a new line each max_len.
77
        As cmd is an XML formatted string, it inserts the new line
78
        after the last '>' before to count max_len characters.
79
80
        Input:
81
           cmd      The string where the new lines will be inserted.
82
           max_len  Insert a new line before to count max_len chars again.
83
        Output:
84
           cmd      The cmd string with the inserted new lines.
85
        """
86
        i_start = 0;
0 ignored issues
show
Coding Style introduced by
Unnecessary semicolon
Loading history...
87
        i_end = max_len
88
        last = 0
89
        char_add = 0
90
        while last != -1:
91
            last = cmd.rfind('>', i_start, i_end)
92
            if last == -1:
93
                break
94
            cmd = cmd[:last + 1] + '\n' + cmd[last + 1:]
95
            char_add += 1
96
            i_start = last + 1
97
            i_end = last + max_len
98
99
        return cmd
100
101
    def send(self, cmd):
102
        """Call the sendAll(string) method.
103
104
        Nothing more ;-)
105
106
        Arguments:
107
            cmd {string} -- XML-Source
108
        """
109
        try:
110
            max_len = 4095
111
            if len(cmd) > max_len:
112
                cmd = self.cmdSplitter(cmd, max_len)
113
114
            self.sendAll(cmd)
115
            logger.debug(cmd)
116
        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...
117
            print(e)
118
        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...
119
            logger.info(e)
120
            raise
121
122
    def read(self):
123
        """Call the readAll() method of the chosen connection type.
124
125
        Try to read all from the open socket connection.
126
        Check for status attribute in xml code.
127
        If the program is in shell-mode, then it returns a lxml root element,
128
        otherwise the plain xml.
129
        If the response is either None or the length is zero,
130
        then the connection was terminated from the server.
131
132
        Returns:
133
            lxml.etree._Element or <string> -- Response from server.
134
        """
135
        response = self.readAll()
136
        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...
137
            len(response), response))
138
139
        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...
140
            raise OSError('Connection was closed by remote server')
141
142
        if hasattr(self, 'raw_response') and self.raw_response is True: #pylint: disable=E1101
143
            return response
144
145
        self.checkCommandStatus(response)
146
147
        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...
148
            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...
149
150
            logger.info('Shell mode activated')
151
            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...
152
            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...
153
            return tree.getroot()
154
        else:
155
            return response
156
157
    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...
158
        try:
159
            if self.sock is not None:
160
                self.sock.close()
161
        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...
162
            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...
163
164
    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...
165
        """Check gmp response
166
167
        Look into the gmp response and check for the status in the root element
168
169
        Arguments:
170
            xml {string} -- XML-Source
171
172
        Returns:
173
            bool -- True if valid, otherwise False
174
        """
175
176
        if xml is 0 or xml is None:
177
            raise GMPError('XML Command is empty')
178
179
        try:
180
            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...
181
            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...
182
                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...
183
            else:
184
                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...
185
            status = root.attrib['status']
186
            status_text = root.attrib['status_text']
187
188
            if not self.authenticated:
189
                auth = root.find('authenticate_response')
190
                if auth is not None:
191
                    status = auth.attrib['status']
192
                    status_text = auth.attrib['status_text']
193
                    if status != '400':
194
                        self.authenticated = True
195
196
            if 'OK' not in status_text:
197
                logger.info('An error occurred on gvm: ' + status_text)
198
                raise GMPError(status_text)
199
200
        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...
201
            logger.error('etree.XML(xml): ' + str(e))
202
            raise
203
204
    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...
205
        """Convert arguments
206
207
        Converts dictionaries into gmp arguments string
208
209
        Arguments:
210
            kwargs {dict} -- Arguments
211
212
        Returns:
213
            string -- Arguments as string
214
        """
215
        msg = ''
216
        for key, value in kwargs.items():
217
            msg += str(key) + '=\'' + str(value) + '\' '
218
219
        return msg
220
221
    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...
222
        yes = set(['yes', 'y', 'ye', ''])
223
        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...
224
225
        choice = input(text).lower()
226
        if choice in yes:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
227
            return True
228
        elif choice in no:
229
            return False
230
        else:
231
            return self.ask_yes_or_no(text)
232
233
    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...
234
        """Authenticate on GVM.
235
236
        The generated authenticate command will be send to server.
237
        After that a response is read from socket.
238
239
        Keyword Arguments:
240
            username {str} -- Username
241
            password {str} -- Password
242
            withCommands {str} -- XML commands (default: {''})
243
244
        Returns:
245
            None or <string> -- Response from server.
246
        """
247
        cmd = self.gmp_generator.createAuthenticateCommand(
248
            username=username, password=password,
249
            withCommands=str(withCommand))
250
251
        self.send(cmd)
252
        return self.read()
253
254
    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...
255
                     howto_install='', howto_use=''):
256
        cmd = self.gmp_generator.createAgentCommand(
257
            installer, signature, name, comment, copy, howto_install,
258
            howto_use)
259
        self.send(cmd)
260
        return self.read()
261
262
    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...
263
                     copy='', comment=''):
264
        cmd = self.gmp_generator.createAlertCommand(name, condition, event,
265
                                                    method, filter_id, copy,
266
                                                    comment)
267
        self.send(cmd)
268
        return self.read()
269
270
    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...
271
        # 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...
272
        cmd = self.gmp_generator.createAssetCommand(name, asset_type, comment)
273
        self.send(cmd)
274
        return self.read()
275
276
    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...
277
        cmd = self.gmp_generator.createConfigCommand(copy_id, name)
278
        self.send(cmd)
279
        return self.read()
280
281
    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...
282
        cmd = self.gmp_generator.createCredentialCommand(name, kwargs)
283
        self.send(cmd)
284
        return self.read()
285
286
    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...
287
        cmd = self.gmp_generator.createFilterCommand(name, make_unique, kwargs)
288
        self.send(cmd)
289
        return self.read()
290
291
    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...
292
        cmd = self.gmp_generator.createGroupCommand(name, kwargs)
293
        self.send(cmd)
294
        return self.read()
295
296
    # 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...
297
    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...
298
        cmd = self.gmp_generator.createNoteCommand(text, nvt_oid, kwargs)
299
        self.send(cmd)
300
        return self.read()
301
302
    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...
303
        cmd = self.gmp_generator.createOverrideCommand(text, nvt_oid, kwargs)
304
        self.send(cmd)
305
        return self.read()
306
307
    def create_permission(self, name, subject_id, type, **kwargs):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

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

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

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

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

Loading history...
308
        cmd = self.gmp_generator.createPermissionCommand(name, subject_id,
309
                                                         type, kwargs)
310
        self.send(cmd)
311
        return self.read()
312
313
    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...
314
        cmd = self.gmp_generator.createPortListCommand(name, port_range,
315
                                                       kwargs)
316
        self.send(cmd)
317
        return self.read()
318
319
    def create_port_range(self, port_list_id, start, end, type, comment=''):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

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

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

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

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

Loading history...
best-practice introduced by
Too many arguments (6/5)
Loading history...
320
        cmd = self.gmp_generator.createPortRangeCommand(port_list_id, start,
321
                                                        end, type, comment)
322
        self.send(cmd)
323
        return self.read()
324
325
    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...
326
        cmd = self.gmp_generator.createReportCommand(report_xml_string, kwargs)
327
        self.send(cmd)
328
        return self.read()
329
330
    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...
331
        # 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...
332
        raise NotImplementedError
333
334
    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...
335
        cmd = self.gmp_generator.createRoleCommand(name, kwargs)
336
        self.send(cmd)
337
        return self.read()
338
339
    def create_scanner(self, name, host, port, type, ca_pub, credential_id,
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in type.

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

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

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

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

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

Loading history...
best-practice introduced by
Too many arguments (7/5)
Loading history...
340
                       **kwargs):
341
        cmd = self.gmp_generator.createScannerCommand(name, host, port, type,
342
                                                      ca_pub, credential_id,
343
                                                      kwargs)
344
        self.send(cmd)
345
        return self.read()
346
347
    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...
348
        cmd = self.gmp_generator.createScheduleCommand(name, kwargs)
349
        self.send(cmd)
350
        return self.read()
351
352
    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...
353
        cmd = self.gmp_generator.createTagCommand(name, resource_id,
354
                                                  resource_type, kwargs)
355
        self.send(cmd)
356
        return self.read()
357
358
    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...
359
        # TODO: Missing variables
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
360
        cmd = self.gmp_generator.createTargetCommand(name, make_unique, kwargs)
361
        self.send(cmd)
362
        return self.read()
363
364
    def create_task(self, name, config_id, target_id, scanner_id, alert_id='', comment=''):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

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

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

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

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

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

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

Loading history...
742
        cmd = self.gmp_generator.modifyScannerCommand(scanner_id, host, port,
743
                                                      type, kwargs)
744
        self.send(cmd)
745
        return self.read()
746
747
    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...
748
        cmd = self.gmp_generator.modifyScheduleCommand(schedule_id, kwargs)
749
        self.send(cmd)
750
        return self.read()
751
752
    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...
753
        cmd = '<modify_setting setting_id="{0}"><name>{1}</name>' \
754
              '<value>{2}</value></modify_setting>' \
755
              ''.format(setting_id, name, value)
756
        self.send(cmd)
757
        return self.read()
758
759
    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...
760
        cmd = self.gmp_generator.modifyTagCommand(tag_id, kwargs)
761
        self.send(cmd)
762
        return self.read()
763
764
    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...
765
        cmd = self.gmp_generator.modifyTargetCommand(target_id, kwargs)
766
        self.send(cmd)
767
        return self.read()
768
769
    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...
770
        cmd = self.gmp_generator.modifyTaskCommand(task_id, kwargs)
771
        self.send(cmd)
772
        return self.read()
773
774
    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...
775
        cmd = self.gmp_generator.modifyUserCommand(kwargs)
776
        self.send(cmd)
777
        return self.read()
778
779
    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...
780
        self.send('<move_task task_id="{0}" slave_id="{1}"/>'
781
                  .format(task_id, slave_id))
782
        return self.read()
783
784
    def restore(self, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

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

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

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

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

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

Loading history...
785
        self.send('<restore id="{0}"/>'.format(id))
786
        return self.read()
787
788
    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...
789
        self.send('<resume_task task_id="{0}"/>'.format(task_id))
790
        return self.read()
791
792
    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...
793
        # TODO: Is this required?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
794
        raise NotImplementedError
795
796
    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...
797
        self.send('<start_task task_id="{0}"/>'.format(task_id))
798
        return self.read()
799
800
    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...
801
        self.send('<stop_task task_id="{0}"/>'.format(task_id))
802
        return self.read()
803
804
    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...
805
        self.send('<sync_cert/>')
806
        return self.read()
807
808
    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...
809
        self.send('<sync_config/>')
810
        return self.read()
811
812
    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...
813
        self.send('<sync_feed/>')
814
        return self.read()
815
816
    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...
817
        self.send('<sync_scap/>')
818
        return self.read()
819
820
    def test_alert(self, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

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

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

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

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

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

Loading history...
821
        self.send('<test_alert alert_id="{0}"/>'.format(id))
822
        return self.read()
823
824
    def verify_agent(self, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

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

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

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

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

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

Loading history...
825
        self.send('<verify_agent agent_id="{0}"/>'.format(id))
826
        return self.read()
827
828
    def verify_report_format(self, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

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

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

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

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

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

Loading history...
829
        self.send('<verify_report_format report_format_id="{0}"/>'.format(id))
830
        return self.read()
831
832
    def verify_scanner(self, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

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

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

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

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

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

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

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

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

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

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

Loading history...
833
        self.send('<verify_scanner scanner_id="{0}"/>'.format(id))
834
        return self.read()
835
836
837
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 (12/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
838
    """SSH Class to connect, read and write from GVM via SSH
839
840
    [description]
841
842
    Variables:
843
        sock {[type]} -- Channel from paramiko after successful connection
844
845
    """
846
847
    def __init__(self, **kwargs):
848
        super().__init__()
849
        self.hostname = kwargs.get('hostname', '127.0.0.1')
850
        self.port = kwargs.get('port', 22)
851
        self.raw_response = kwargs.get('raw_response', False)
852
        self.timeout = kwargs.get('timeout', 5)
853
        self.ssh_user = kwargs.get('ssh_user', 'gmp')
854
        self.ssh_password = kwargs.get('ssh_password', '')
855
        self.shell_mode = kwargs.get('shell_mode', False)
856
        self.sock = paramiko.SSHClient()
857
        # self.sock.load_system_host_keys()
858
        # self.sock.set_missing_host_key_policy(paramiko.WarningPolicy())
859
        self.sock.set_missing_host_key_policy(paramiko.AutoAddPolicy())
860
861
        try:
862
            self.sock.connect(
863
                hostname=self.hostname,
864
                username=self.ssh_user,
865
                password=self.ssh_password,
866
                timeout=self.timeout,
867
                port=int(self.port),
868
                allow_agent=False,
869
                look_for_keys=False)
870
            self.channel = self.sock.invoke_shell()
871
872
        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...
873
                paramiko.AuthenticationException,
874
                paramiko.SSHException, OSError) as e:
875
            logger.debug('SSH Connection failed: ' + str(e))
876
            raise
877
878
    def readAll(self):
879
        self.first_element = None
0 ignored issues
show
Coding Style introduced by
The attribute first_element was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
880
        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...
Coding Style introduced by
The attribute parser was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
881
        read_bytes = 0
882
        garbage_bytes = len(self.cmd) +1
883
        # Remove command string from result
884
        while not read_bytes == garbage_bytes:
0 ignored issues
show
Unused Code introduced by
Consider changing "not read_bytes == garbage_bytes" to "read_bytes != garbage_bytes"
Loading history...
885
            read_bytes += len(self.channel.recv(garbage_bytes-read_bytes))
886
887
        response = b''
888
889
        while True:
890
            data = self.channel.recv(BUF_SIZE)
891
892
            # Connection was closed by server
893
            if not data:
894
                break
895
896
            self.parser.feed(data)
897
898
            response += data
899
900
            if self.valid_xml():
901
                break
902
903
        return response.decode('utf-8')
904
905
    def sendAll(self, cmd):
906
        logger.debug('SSH:send(): ' + cmd)
907
        self.cmd = str(cmd) + '\n'
0 ignored issues
show
Coding Style introduced by
The attribute cmd was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
908
        self.channel.sendall(self.cmd)
909
910
    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...
911
        for action, obj in self.parser.read_events():
912
            if not self.first_element and action in 'start':
913
                self.first_element = obj.tag
0 ignored issues
show
Coding Style introduced by
The attribute first_element was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
914
915
            if self.first_element and action in 'end' and str(self.first_element) == str(obj.tag):
916
                return True
917
        return False
918
919
920
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...
921
    """TLS class to connect, read and write from GVM via tls secured socket
922
923
    [description]
924
925
    Variables:
926
        sock {socket.socket} -- Socket that holds the connection
927
    """
928
929
    def __init__(self, **kwargs):
930
        super().__init__()
931
        self.hostname = kwargs.get('hostname', '127.0.0.1')
932
        self.port = kwargs.get('port', 9390)
933
        self.raw_response = kwargs.get('raw_response', False)
934
        self.timeout = kwargs.get('timeout', 60)
935
        self.shell_mode = kwargs.get('shell_mode', False)
936
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
937
        self.sock = context.wrap_socket(socket.socket(socket.AF_INET))
938
        self.sock.settimeout(self.timeout)
939
        self.sock.connect((self.hostname, int(self.port)))
940
941
    def sendAll(self, cmd):
942
        self.sock.send(cmd.encode())
943
944
    def readAll(self):
945
        response = ''
946
        while True:
947
            data = self.sock.read(BUF_SIZE)
948
949
            response += data.decode(errors='ignore')
950
            if len(data) < BUF_SIZE:
951
                break
952
        return response
953
954
955
class UnixSocketConnection(GVMConnection):
0 ignored issues
show
Bug introduced by
The method create_report_format which was declared abstract in the super-class GVMConnection
was not overridden.

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

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

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

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
956
    """UNIX-Socket class to connect, read, write from GVM
957
    via direct communicating UNIX-Socket
958
959
    [description]
960
961
    Variables:
962
        sock {socket.socket} -- Socket that holds the connection
963
        sockpath {string} -- Path to UNIX-Socket
964
    """
965
966
    def __init__(self, **kwargs):
967
        super().__init__()
968
        self.raw_response = kwargs.get('raw_response', False)
969
        self.sockpath = kwargs.get('sockpath',
970
                                   '/usr/local/var/run/gvmd.sock')
971
        self.shell_mode = kwargs.get('shell_mode', False)
972
        self.timeout = kwargs.get('timeout', 60)
973
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) #pylint: disable=E1101
974
        self.sock.settimeout(self.timeout)
975
        self.sock.connect(self.sockpath)
976
977
    def readAll(self):
978
        response = ''
979
        while True:
980
            data = self.sock.recv(BUF_SIZE)
981
            # Todo: Why does the sleep helps here? Sometimes it will break
982
            # here because the message is missing some bytes at the end.
983
            # Same script and with tls or ssh, then it works flawless without
984
            # "sleep()"
985
            time.sleep(0.000001)
986
            response += data.decode()
987
            if len(data) < BUF_SIZE:
988
                break
989
990
        return response
991
992
    def sendAll(self, cmd):
993
        self.sock.send(cmd.encode())
994