Completed
Push — master ( 2c2772...506b64 )
by
unknown
12s
created

gmp.gvm_connection.SSHConnection.cmdSplitter()   A

Complexity

Conditions 3

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nop 2
dl 0
loc 21
rs 9.75
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 (120/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
    def send(self, cmd):
74
        """Call the sendAll(string) method.
75
76
        Nothing more ;-)
77
78
        Arguments:
79
            cmd {string} -- XML-Source
80
        """
81
        try:
82
            self.sendAll(cmd)
83
            logger.debug(cmd)
84
        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...
85
            print(e)
86
        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...
87
            logger.info(e)
88
            raise
89
90
    def read(self):
91
        """Call the readAll() method of the chosen connection type.
92
93
        Try to read all from the open socket connection.
94
        Check for status attribute in xml code.
95
        If the program is in shell-mode, then it returns a lxml root element,
96
        otherwise the plain xml.
97
        If the response is either None or the length is zero,
98
        then the connection was terminated from the server.
99
100
        Returns:
101
            lxml.etree._Element or <string> -- Response from server.
102
        """
103
        response = self.readAll()
104
        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...
105
            len(response), response))
106
107
        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...
108
            raise OSError('Connection was closed by remote server')
109
110
        if hasattr(self, 'raw_response') and self.raw_response is True: #pylint: disable=E1101
111
            return response
112
113
        self.checkCommandStatus(response)
114
115
        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...
116
            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...
117
118
            logger.info('Shell mode activated')
119
            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...
120
            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...
121
            return tree.getroot()
122
        else:
123
            return response
124
125
    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...
126
        try:
127
            if self.sock is not None:
128
                self.sock.close()
129
        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...
130
            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...
131
132
    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...
133
        """Check gmp response
134
135
        Look into the gmp response and check for the status in the root element
136
137
        Arguments:
138
            xml {string} -- XML-Source
139
140
        Returns:
141
            bool -- True if valid, otherwise False
142
        """
143
144
        if xml is 0 or xml is None:
145
            raise GMPError('XML Command is empty')
146
147
        try:
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
            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...
150
                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...
151
            else:
152
                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...
153
            status = root.attrib['status']
154
            status_text = root.attrib['status_text']
155
156
            if not self.authenticated:
157
                auth = root.find('authenticate_response')
158
                if auth is not None:
159
                    status = auth.attrib['status']
160
                    status_text = auth.attrib['status_text']
161
                    if status != '400':
162
                        self.authenticated = True
163
164
            if 'OK' not in status_text:
165
                logger.info('An error occurred on gvm: ' + status_text)
166
                raise GMPError(status_text)
167
168
        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...
169
            logger.error('etree.XML(xml): ' + str(e))
170
            raise
171
172
    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...
173
        """Convert arguments
174
175
        Converts dictionaries into gmp arguments string
176
177
        Arguments:
178
            kwargs {dict} -- Arguments
179
180
        Returns:
181
            string -- Arguments as string
182
        """
183
        msg = ''
184
        for key, value in kwargs.items():
185
            msg += str(key) + '=\'' + str(value) + '\' '
186
187
        return msg
188
189
    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...
190
        yes = set(['yes', 'y', 'ye', ''])
191
        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...
192
193
        choice = input(text).lower()
194
        if choice in yes:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
195
            return True
196
        elif choice in no:
197
            return False
198
        else:
199
            return self.ask_yes_or_no(text)
200
201
    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...
202
        """Authenticate on GVM.
203
204
        The generated authenticate command will be send to server.
205
        After that a response is read from socket.
206
207
        Keyword Arguments:
208
            username {str} -- Username
209
            password {str} -- Password
210
            withCommands {str} -- XML commands (default: {''})
211
212
        Returns:
213
            None or <string> -- Response from server.
214
        """
215
        cmd = self.gmp_generator.createAuthenticateCommand(
216
            username=username, password=password,
217
            withCommands=str(withCommand))
218
219
        self.send(cmd)
220
        return self.read()
221
222
    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...
223
                     howto_install='', howto_use=''):
224
        cmd = self.gmp_generator.createAgentCommand(
225
            installer, signature, name, comment, copy, howto_install,
226
            howto_use)
227
        self.send(cmd)
228
        return self.read()
229
230
    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...
231
                     copy='', comment=''):
232
        cmd = self.gmp_generator.createAlertCommand(name, condition, event,
233
                                                    method, filter_id, copy,
234
                                                    comment)
235
        self.send(cmd)
236
        return self.read()
237
238
    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...
239
        # 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...
240
        cmd = self.gmp_generator.createAssetCommand(name, asset_type, comment)
241
        self.send(cmd)
242
        return self.read()
243
244
    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...
245
        cmd = self.gmp_generator.createConfigCommand(copy_id, name)
246
        self.send(cmd)
247
        return self.read()
248
249
    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...
250
        cmd = self.gmp_generator.createCredentialCommand(name, kwargs)
251
        self.send(cmd)
252
        return self.read()
253
254
    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...
255
        cmd = self.gmp_generator.createFilterCommand(name, make_unique, kwargs)
256
        self.send(cmd)
257
        return self.read()
258
259
    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...
260
        cmd = self.gmp_generator.createGroupCommand(name, kwargs)
261
        self.send(cmd)
262
        return self.read()
263
264
    # 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...
265
    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...
266
        cmd = self.gmp_generator.createNoteCommand(text, nvt_oid, kwargs)
267
        self.send(cmd)
268
        return self.read()
269
270
    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...
271
        cmd = self.gmp_generator.createOverrideCommand(text, nvt_oid, kwargs)
272
        self.send(cmd)
273
        return self.read()
274
275
    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...
276
        cmd = self.gmp_generator.createPermissionCommand(name, subject_id,
277
                                                         type, kwargs)
278
        self.send(cmd)
279
        return self.read()
280
281
    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...
282
        cmd = self.gmp_generator.createPortListCommand(name, port_range,
283
                                                       kwargs)
284
        self.send(cmd)
285
        return self.read()
286
287
    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...
288
        cmd = self.gmp_generator.createPortRangeCommand(port_list_id, start,
289
                                                        end, type, comment)
290
        self.send(cmd)
291
        return self.read()
292
293
    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...
294
        cmd = self.gmp_generator.createReportCommand(report_xml_string, kwargs)
295
        self.send(cmd)
296
        return self.read()
297
298
    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...
299
        # 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...
300
        raise NotImplementedError
301
302
    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...
303
        cmd = self.gmp_generator.createRoleCommand(name, kwargs)
304
        self.send(cmd)
305
        return self.read()
306
307
    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...
308
                       **kwargs):
309
        cmd = self.gmp_generator.createScannerCommand(name, host, port, type,
310
                                                      ca_pub, credential_id,
311
                                                      kwargs)
312
        self.send(cmd)
313
        return self.read()
314
315
    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...
316
        cmd = self.gmp_generator.createScheduleCommand(name, kwargs)
317
        self.send(cmd)
318
        return self.read()
319
320
    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...
321
        cmd = self.gmp_generator.createTagCommand(name, resource_id,
322
                                                  resource_type, kwargs)
323
        self.send(cmd)
324
        return self.read()
325
326
    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...
327
        # TODO: Missing variables
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
328
        cmd = self.gmp_generator.createTargetCommand(name, make_unique, kwargs)
329
        self.send(cmd)
330
        return self.read()
331
332
    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...
333
        cmd = self.gmp_generator.createTaskCommand(
334
            name, config_id, target_id, scanner_id, alert_id, comment)
335
        self.send(cmd)
336
        return self.read()
337
338
    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...
339
                    ifaces_allow='0', role_ids=(), hosts=None, ifaces=None):
340
        cmd = self.gmp_generator.createUserCommand(
341
            name, password, copy, hosts_allow, ifaces_allow, role_ids,
342
            hosts, ifaces)
343
        self.send(cmd)
344
        return self.read()
345
346
    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...
347
        self.send('<delete_agent {0}/>'.format(self.argumentsToString(kwargs)))
348
        return self.read()
349
350
    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...
351
        # if self.ask_yes_or_no('Are you sure to delete this alert? '):
352
        self.send(
353
            '<delete_alert {0}/>'.format(self.argumentsToString(kwargs)))
354
        return self.read()
355
356
    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...
357
        # if self.ask_yes_or_no('Are you sure to delete this asset? '):
358
        self.send('<delete_asset asset_id="{0}" ultimate="{1}"/>'
359
                  .format(asset_id, ultimate))
360
        return self.read()
361
362
    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...
363
        # if self.ask_yes_or_no('Are you sure to delete this config? '):
364
        self.send('<delete_config config_id="{0}" ultimate="{1}"/>'
365
                  .format(config_id, ultimate))
366
        return self.read()
367
368
    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...
369
        # if self.ask_yes_or_no('Are you sure to delete this credential? '):
370
        self.send(
371
            '<delete_credential credential_id="{0}" ultimate="{1}"/>'.format
372
            (credential_id, ultimate))
373
        return self.read()
374
375
    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...
376
        # if self.ask_yes_or_no('Are you sure to delete this filter? '):
377
        self.send('<delete_filter filter_id="{0}" ultimate="{1}"/>'
378
                  .format(filter_id, ultimate))
379
        return self.read()
380
381
    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...
382
        # if self.ask_yes_or_no('Are you sure to delete this group? '):
383
        self.send('<delete_group group_id="{0}" ultimate="{1}"/>'
384
                  .format(group_id, ultimate))
385
        return self.read()
386
387
    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...
388
        # if self.ask_yes_or_no('Are you sure to delete this note? '):
389
        self.send('<delete_note note_id="{0}" ultimate="{1}"/>'
390
                  .format(note_id, ultimate))
391
        return self.read()
392
393
    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...
394
        # if self.ask_yes_or_no('Are you sure to delete this override? '):
395
        self.send('<delete_override override_id="{0}" ultimate="{1}"/>'
396
                  .format(override_id, ultimate))
397
        return self.read()
398
399
    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...
400
        # if self.ask_yes_or_no('Are you sure to delete this permission? '):
401
        self.send('<delete_permission permission_id="{0}" ultimate="{1}"/>'
402
                  .format(permission_id, ultimate))
403
        return self.read()
404
405
    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...
406
        # if self.ask_yes_or_no('Are you sure to delete this port_list? '):
407
        self.send('<delete_port_list port_list_id="{0}" ultimate="{1}"/>'
408
                  .format(port_list_id, ultimate))
409
        return self.read()
410
411
    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...
412
        # if self.ask_yes_or_no('Are you sure to delete this port_range? '):
413
        self.send('<delete_port_range port_range_id="{0}"/>'
414
                  .format(port_range_id))
415
        return self.read()
416
417
    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...
418
        # if self.ask_yes_or_no('Are you sure to delete this report? '):
419
        self.send('<delete_report report_id="{0}"/>'
420
                  .format(report_id))
421
        return self.read()
422
423
    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...
424
        # if self.ask_yes_or_no('Are you sure to delete this report_format? '):
425
        self.send('<delete_report_format report_format_id="{0}" \
426
                   ultimate="{1}"/>'.format(report_format_id, ultimate))
427
        return self.read()
428
429
    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...
430
        # if self.ask_yes_or_no('Are you sure to delete this role? '):
431
        self.send('<delete_role role_id="{0}" ultimate="{1}"/>'
432
                  .format(role_id, ultimate))
433
        return self.read()
434
435
    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...
436
        # if self.ask_yes_or_no('Are you sure to delete this scanner? '):
437
        self.send('<delete_scanner scanner_id="{0}" ultimate="{1}"/>'
438
                  .format(scanner_id, ultimate))
439
        return self.read()
440
441
    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...
442
        # if self.ask_yes_or_no('Are you sure to delete this schedule? '):
443
        self.send('<delete_schedule schedule_id="{0}" ultimate="{1}"/>'
444
                  .format(schedule_id, ultimate))
445
        return self.read()
446
447
    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...
448
        # if self.ask_yes_or_no('Are you sure to delete this tag? '):
449
        self.send('<delete_tag tag_id="{0}" ultimate="{1}"/>'
450
                  .format(tag_id, ultimate))
451
        return self.read()
452
453
    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...
454
        # if self.ask_yes_or_no('Are you sure to delete this target? '):
455
        self.send('<delete_target target_id="{0}" ultimate="{1}"/>'
456
                  .format(target_id, ultimate))
457
        return self.read()
458
459
    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...
460
        # if self.ask_yes_or_no('Are you sure to delete this task? '):
461
        self.send('<delete_task task_id="{0}" ultimate="{1}"/>'
462
                  .format(task_id, ultimate))
463
        return self.read()
464
465
    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...
466
        user_id = kwargs.get('user_id', '')
467
        if user_id:
468
            user_id = ' user_id="%s"' % user_id
469
470
        name = kwargs.get('name', '')
471
        if name:
472
            name = ' name="%s"' % name
473
474
        inheritor_id = kwargs.get('inheritor_id', '')
475
        if inheritor_id:
476
            inheritor_id = ' inheritor_id="%s"' % inheritor_id
477
478
        inheritor_name = kwargs.get('inheritor_name', '')
479
        if inheritor_name:
480
            inheritor_name = ' inheritor_name="%s"' % inheritor_name
481
482
        self.send('<delete_user{0}{1}{2}{3}/>'
483
                  .format(user_id, name, inheritor_id, inheritor_name))
484
        return self.read()
485
486
    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...
487
        self.send('<describe_auth/>')
488
        return self.read()
489
490
    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...
491
        self.send('<empty_trashcan/>')
492
        return self.read()
493
494
    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...
495
        self.send('<get_agents {0}/>'.format(self.argumentsToString(kwargs)))
496
        return self.read()
497
498
    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...
499
        self.send(
500
            '<get_aggregates {0}/>'.format(self.argumentsToString(kwargs)))
501
        return self.read()
502
503
    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...
504
        self.send('<get_alerts {0}/>'.format(self.argumentsToString(kwargs)))
505
        return self.read()
506
507
    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...
508
        self.send('<get_assets {0}/>'.format(self.argumentsToString(kwargs)))
509
        return self.read()
510
511
    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...
512
        self.send(
513
            '<get_credentials {0}/>'.format(self.argumentsToString(kwargs)))
514
        return self.read()
515
516
    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...
517
        self.send('<get_configs {0}/>'.format(self.argumentsToString(kwargs)))
518
        return self.read()
519
520
    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...
521
        self.send('<get_feeds {0}/>'.format(self.argumentsToString(kwargs)))
522
        return self.read()
523
524
    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...
525
        self.send('<get_filters {0}/>'.format(self.argumentsToString(kwargs)))
526
        return self.read()
527
528
    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...
529
        self.send('<get_groups {0}/>'.format(self.argumentsToString(kwargs)))
530
        return self.read()
531
532
    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...
533
        self.send('<get_info {0}/>'.format(self.argumentsToString(kwargs)))
534
        return self.read()
535
536
    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...
537
        self.send('<get_notes {0}/>'.format(self.argumentsToString(kwargs)))
538
        return self.read()
539
540
    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...
541
        self.send('<get_nvts {0}/>'.format(self.argumentsToString(kwargs)))
542
        return self.read()
543
544
    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...
545
        self.send(
546
            '<get_nvt_families {0}/>'.format(self.argumentsToString(kwargs)))
547
        return self.read()
548
549
    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...
550
        self.send(
551
            '<get_overrides {0}/>'.format(self.argumentsToString(kwargs)))
552
        return self.read()
553
554
    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...
555
        self.send(
556
            '<get_permissions {0}/>'.format(self.argumentsToString(kwargs)))
557
        return self.read()
558
559
    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...
560
        self.send(
561
            '<get_port_lists {0}/>'.format(self.argumentsToString(kwargs)))
562
        return self.read()
563
564
    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...
565
        self.send(
566
            '<get_preferences {0}/>'.format(self.argumentsToString(kwargs)))
567
        return self.read()
568
569
    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...
570
        self.send('<get_reports {0}/>'
571
                  .format(self.argumentsToString(kwargs)))
572
        return self.read()
573
574
    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...
575
        self.send(
576
            '<get_report_formats {0}/>'.format(self.argumentsToString(kwargs)))
577
        return self.read()
578
579
    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...
580
        self.send('<get_results {0}/>'.format(self.argumentsToString(kwargs)))
581
        return self.read()
582
583
    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...
584
        self.send('<get_roles {0}/>'.format(self.argumentsToString(kwargs)))
585
        return self.read()
586
587
    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...
588
        self.send('<get_scanners {0}/>'.format(self.argumentsToString(kwargs)))
589
        return self.read()
590
591
    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...
592
        self.send(
593
            '<get_schedules {0}/>'.format(self.argumentsToString(kwargs)))
594
        return self.read()
595
596
    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...
597
        self.send('<get_settings {0}/>'.format(self.argumentsToString(kwargs)))
598
        return self.read()
599
600
    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...
601
        self.send(
602
            '<get_system_reports {0}/>'.format(self.argumentsToString(kwargs)))
603
        return self.read()
604
605
    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...
606
        self.send('<get_tags {0}/>'.format(self.argumentsToString(kwargs)))
607
        return self.read()
608
609
    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...
610
        self.send('<get_targets {0}/>'.format(self.argumentsToString(kwargs)))
611
        return self.read()
612
613
    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...
614
        self.send('<get_tasks {0}/>'.format(self.argumentsToString(kwargs)))
615
        return self.read()
616
617
    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...
618
        self.send('<get_users {0}/>'.format(self.argumentsToString(kwargs)))
619
        return self.read()
620
621
    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...
622
        self.send('<get_version/>')
623
        return self.read()
624
625
    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...
626
        self.send('<help {0} />'.format(self.argumentsToString(kwargs)))
627
        return self.read()
628
629
    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...
630
        cmd = self.gmp_generator.modifyAgentCommand(agent_id, name, comment)
631
        self.send(cmd)
632
        return self.read()
633
634
    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...
635
        cmd = self.gmp_generator.modifyAlertCommand(alert_id, kwargs)
636
        self.send(cmd)
637
        return self.read()
638
639
    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...
640
        cmd = '<modify_asset asset_id="%s"><comment>%s</comment>' \
641
              '</modify_asset>' % (asset_id, comment)
642
        self.send(cmd)
643
        return self.read()
644
645
    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...
646
        cmd = self.gmp_generator.modifyAuthCommand(group_name,
647
                                                   auth_conf_settings)
648
        self.send(cmd)
649
        return self.read()
650
651
    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...
652
        cmd = self.gmp_generator.modifyConfigCommand(selection, kwargs)
653
        self.send(cmd)
654
        return self.read()
655
656
    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...
657
        cmd = self.gmp_generator.modifyCredentialCommand(credential_id, kwargs)
658
        self.send(cmd)
659
        return self.read()
660
661
    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...
662
        cmd = self.gmp_generator.modifyFilterCommand(filter_id, kwargs)
663
        self.send(cmd)
664
        return self.read()
665
666
    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...
667
        cmd = self.gmp_generator.modifyGroupCommand(group_id, kwargs)
668
        self.send(cmd)
669
        return self.read()
670
671
    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...
672
        cmd = self.gmp_generator.modifyNoteCommand(note_id, text, kwargs)
673
        self.send(cmd)
674
        return self.read()
675
676
    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...
677
        cmd = self.gmp_generator.modifyOverrideCommand(override_id, text,
678
                                                       kwargs)
679
        self.send(cmd)
680
        return self.read()
681
682
    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...
683
        cmd = self.gmp_generator.modifyPermissionCommand(permission_id, kwargs)
684
        self.send(cmd)
685
        return self.read()
686
687
    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...
688
        cmd = self.gmp_generator.modifyPortListCommand(port_list_id, kwargs)
689
        self.send(cmd)
690
        return self.read()
691
692
    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...
693
        cmd = '<modify_report report_id="{0}"><comment>{1}</comment>' \
694
              '</modify_report>'.format(report_id, comment)
695
        self.send(cmd)
696
        return self.read()
697
698
    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...
699
        cmd = self.gmp_generator.modifyReportFormatCommand(report_format_id,
700
                                                           kwargs)
701
        self.send(cmd)
702
        return self.read()
703
704
    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...
705
        cmd = self.gmp_generator.modifyRoleCommand(role_id, kwargs)
706
        self.send(cmd)
707
        return self.read()
708
709
    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...
710
        cmd = self.gmp_generator.modifyScannerCommand(scanner_id, host, port,
711
                                                      type, kwargs)
712
        self.send(cmd)
713
        return self.read()
714
715
    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...
716
        cmd = self.gmp_generator.modifyScheduleCommand(schedule_id, kwargs)
717
        self.send(cmd)
718
        return self.read()
719
720
    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...
721
        cmd = '<modify_setting setting_id="{0}"><name>{1}</name>' \
722
              '<value>{2}</value></modify_setting>' \
723
              ''.format(setting_id, name, value)
724
        self.send(cmd)
725
        return self.read()
726
727
    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...
728
        cmd = self.gmp_generator.modifyTagCommand(tag_id, kwargs)
729
        self.send(cmd)
730
        return self.read()
731
732
    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...
733
        cmd = self.gmp_generator.modifyTargetCommand(target_id, kwargs)
734
        self.send(cmd)
735
        return self.read()
736
737
    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...
738
        cmd = self.gmp_generator.modifyTaskCommand(task_id, kwargs)
739
        self.send(cmd)
740
        return self.read()
741
742
    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...
743
        cmd = self.gmp_generator.modifyUserCommand(kwargs)
744
        self.send(cmd)
745
        return self.read()
746
747
    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...
748
        self.send('<move_task task_id="{0}" slave_id="{1}"/>'
749
                  .format(task_id, slave_id))
750
        return self.read()
751
752
    def restore(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

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

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

Loading history...
753
        self.send('<restore id="{0}"/>'.format(id))
754
        return self.read()
755
756
    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...
757
        self.send('<resume_task task_id="{0}"/>'.format(task_id))
758
        return self.read()
759
760
    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...
761
        # TODO: Is this required?
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
762
        raise NotImplementedError
763
764
    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...
765
        self.send('<start_task task_id="{0}"/>'.format(task_id))
766
        return self.read()
767
768
    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...
769
        self.send('<stop_task task_id="{0}"/>'.format(task_id))
770
        return self.read()
771
772
    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...
773
        self.send('<sync_cert/>')
774
        return self.read()
775
776
    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...
777
        self.send('<sync_config/>')
778
        return self.read()
779
780
    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...
781
        self.send('<sync_feed/>')
782
        return self.read()
783
784
    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...
785
        self.send('<sync_scap/>')
786
        return self.read()
787
788
    def test_alert(self, id):
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading history...
801
        self.send('<verify_scanner scanner_id="{0}"/>'.format(id))
802
        return self.read()
803
804
805
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...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
best-practice introduced by
Too many instance attributes (14/7)
Loading history...
806
    """SSH Class to connect, read and write from GVM via SSH
807
808
    [description]
809
810
    Variables:
811
        sock {[type]} -- Channel from paramiko after successful connection
812
813
    """
814
815
    def __init__(self, **kwargs):
816
        super().__init__()
817
        self.hostname = kwargs.get('hostname', '127.0.0.1')
818
        self.port = kwargs.get('port', 22)
819
        self.raw_response = kwargs.get('raw_response', False)
820
        self.timeout = kwargs.get('timeout', 5)
821
        self.ssh_user = kwargs.get('ssh_user', 'gmp')
822
        self.ssh_password = kwargs.get('ssh_password', '')
823
        self.shell_mode = kwargs.get('shell_mode', False)
824
        self.sock = paramiko.SSHClient()
825
        # self.sock.load_system_host_keys()
826
        # self.sock.set_missing_host_key_policy(paramiko.WarningPolicy())
827
        self.sock.set_missing_host_key_policy(paramiko.AutoAddPolicy())
828
829
        try:
830
            self.sock.connect(
831
                hostname=self.hostname,
832
                username=self.ssh_user,
833
                password=self.ssh_password,
834
                timeout=self.timeout,
835
                port=int(self.port),
836
                allow_agent=False,
837
                look_for_keys=False)
838
            self.stdin, self.stdout, self.stderr = self.sock.exec_command("", get_pty=False)
839
840
        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...
841
                paramiko.AuthenticationException,
842
                paramiko.SSHException, OSError) as e:
843
            logger.debug('SSH Connection failed: ' + str(e))
844
            raise
845
846
    def readAll(self):
847
        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...
848
        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...
849
850
        response = b''
851
852
        while True:
853
            data = self.stdout.channel.recv(BUF_SIZE)
854
            # Connection was closed by server
855
            if not data:
856
                break
857
858
            self.parser.feed(data)
859
860
            response += data
861
862
            if self.valid_xml():
863
                break
864
        return response.decode('utf-8')
865
866
    def cmdSplitter(self, max_len):
0 ignored issues
show
Coding Style Naming introduced by
The name cmdSplitter does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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

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

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

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

Loading history...
867
        """ Receive the cmd string longer than max_len
868
        and send it in blocks not longer than max_len.
869
870
        Input:
871
           max_len  The max length of a block to be sent.
872
        """
873
        i_start = 0;
0 ignored issues
show
Coding Style introduced by
Unnecessary semicolon
Loading history...
874
        i_end = max_len
875
        sent_bytes = 0
876
        while sent_bytes < len(self.cmd):
877
            time.sleep(0.01)
878
            self.stdin.channel.send(self.cmd[i_start:i_end])
879
            i_start = i_end
880
            if i_end > len(self.cmd):
881
                i_end = len(self.cmd)
882
            else:
883
                i_end = i_end + max_len
884
            sent_bytes += (i_end - i_start)
885
886
        return sent_bytes
887
888
    def sendAll(self, cmd, max_len=4095):
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'sendAll' method
Loading history...
889
        logger.debug('SSH:send(): ' + cmd)
890
        self.cmd = str(cmd)
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...
891
        if len(self.cmd) > max_len:
892
            sent_bytes = self.cmdSplitter(max_len)
893
            logger.debug("SSH: {0} bytes sent.".format(sent_bytes))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
894
        else:
895
            self.stdin.channel.send(self.cmd)
896
897
    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...
898
        for action, obj in self.parser.read_events():
899
            if not self.first_element and action in 'start':
900
                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...
901
902
            if self.first_element and action in 'end' and str(self.first_element) == str(obj.tag):
903
                return True
904
        return False
905
906
907
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...
908
    """TLS class to connect, read and write from GVM via tls secured socket
909
910
    [description]
911
912
    Variables:
913
        sock {socket.socket} -- Socket that holds the connection
914
    """
915
916
    def __init__(self, **kwargs):
917
        super().__init__()
918
        self.hostname = kwargs.get('hostname', '127.0.0.1')
919
        self.port = kwargs.get('port', 9390)
920
        self.raw_response = kwargs.get('raw_response', False)
921
        self.timeout = kwargs.get('timeout', 60)
922
        self.shell_mode = kwargs.get('shell_mode', False)
923
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
924
        self.sock = context.wrap_socket(socket.socket(socket.AF_INET))
925
        self.sock.settimeout(self.timeout)
926
        self.sock.connect((self.hostname, int(self.port)))
927
928
    def sendAll(self, cmd):
929
        self.sock.send(cmd.encode())
930
931
    def readAll(self):
932
        response = ''
933
        while True:
934
            data = self.sock.read(BUF_SIZE)
935
936
            response += data.decode(errors='ignore')
937
            if len(data) < BUF_SIZE:
938
                break
939
        return response
940
941
942
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...
943
    """UNIX-Socket class to connect, read, write from GVM
944
    via direct communicating UNIX-Socket
945
946
    [description]
947
948
    Variables:
949
        sock {socket.socket} -- Socket that holds the connection
950
        sockpath {string} -- Path to UNIX-Socket
951
    """
952
953
    def __init__(self, **kwargs):
954
        super().__init__()
955
        self.raw_response = kwargs.get('raw_response', False)
956
        self.sockpath = kwargs.get('sockpath',
957
                                   '/usr/local/var/run/gvmd.sock')
958
        self.shell_mode = kwargs.get('shell_mode', False)
959
        self.timeout = kwargs.get('timeout', 60)
960
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) #pylint: disable=E1101
961
        self.sock.settimeout(self.timeout)
962
        self.sock.connect(self.sockpath)
963
964
    def readAll(self):
965
        response = ''
966
        while True:
967
            data = self.sock.recv(BUF_SIZE)
968
            # Todo: Why does the sleep helps here? Sometimes it will break
969
            # here because the message is missing some bytes at the end.
970
            # Same script and with tls or ssh, then it works flawless without
971
            # "sleep()"
972
            time.sleep(0.000001)
973
            response += data.decode()
974
            if len(data) < BUF_SIZE:
975
                break
976
977
        return response
978
979
    def sendAll(self, cmd):
980
        self.sock.send(cmd.encode())
981