Passed
Pull Request — master (#121)
by Juan José
01:57
created

gmp.xml._GmpCommandFactory.create_user_command()   B

Complexity

Conditions 7

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 18
nop 9
dl 0
loc 25
rs 8
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

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

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

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

Loading history...
coding-style introduced by
Too many lines in module (1897/1000)
Loading history...
2
# Copyright (C) 2018 Greenbone Networks GmbH
3
#
4
# SPDX-License-Identifier: GPL-3.0-or-later
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
import defusedxml.lxml as secET
20
21
from lxml import etree
22
23
FILTER_NAMES = [
24
    'Agent',
25
    'Alert',
26
    'Asset',
27
    'Config',
28
    'Credential',
29
    'Filter',
30
    'Group',
31
    'Note',
32
    'Override',
33
    'Permission',
34
    'Port List',
35
    'Report',
36
    'Report Format',
37
    'Result',
38
    'Role',
39
    'Schedule',
40
    'SecInfo',
41
    'Tag',
42
    'Target',
43
    'Task',
44
    'User',
45
]
46
47
class XmlCommandElement:
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...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
48
49
    def __init__(self, element):
50
        self._element = element
51
52
    def add_element(self, name, text=None, attrs=None):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
53
        node = etree.SubElement(self._element, name, attrib=attrs)
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named SubElement.

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...
54
        node.text = text
55
        return XmlCommandElement(node)
56
57
    def set_attribute(self, 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...
58
        self._element.set(name, value)
59
60
    def set_attributes(self, attrs):
61
        """Set several attributes at once.
62
63
        Arguments:
64
            attrs (dict): Attributes to be set on the element
65
        """
66
        for key, value in attrs.items():
67
            self._element.set(key, value)
68
69
    def append_xml_str(self, xml_text):
70
        """Append a xml element in string format."""
71
        node = secET.fromstring(xml_text)
72
        self._element.append(node)
73
74
    def to_string(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...
75
        return etree.tostring(self._element).decode('utf-8')
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named tostring.

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...
76
77
    def __str__(self):
78
        return self.to_string()
79
80
81
class XmlCommand(XmlCommandElement):
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...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
82
83
    def __init__(self, name):
84
        super().__init__(etree.Element(name))
0 ignored issues
show
Bug introduced by
The Module lxml.etree does not seem to have a member named Element.

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...
85
86
87
class _GmpCommandFactory:
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 (94/20)
Loading history...
88
89
    """Factory to create gmp - Greenbone Manangement Protocol - commands
90
    """
91
92
    def create_agent_command(self, installer, signature, 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...
best-practice introduced by
Too many arguments (8/5)
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...
93
                             copy='', howto_install='', howto_use=''):
94
95
        cmd = XmlCommand('create_agent')
96
        cmd.add_element('installer', installer)
97
        cmd.add_element('signature', signature)
98
        cmd.add_element('name', name)
99
100
        if comment:
101
            cmd.add_element('comment', comment)
102
103
        if copy:
104
            cmd.add_element('copy', copy)
105
106
        if howto_install:
107
            cmd.add_element('howto_install', howto_install)
108
109
        if howto_use:
110
            cmd.add_element('howto_use', howto_use)
111
112
        return cmd.to_string()
113
114
    def create_alert_command(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...
Comprehensibility introduced by
This function exceeds the maximum number of variables (16/15).
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...
115
                             copy='', comment=''):
116
117
        cmd = XmlCommand('create_alert')
118
        cmd.add_element('name', name)
119
120
        if len(condition) > 1:
121
            conditions = cmd.add_element('condition', condition[0])
122
            for value, key in condition[1].items():
123
                _data = conditions.add_element('data', value)
124
                _data.add_element('name', key)
125
126
        elif condition[0] == "Always":
127
            conditions = cmd.add_element('condition', condition[0])
128
129
        if len(event) > 1:
130
            events = cmd.add_element('event', event[0])
131
            for value, key in event[1].items():
132
                _data = events.add_element('data', value)
133
                _data.add_element('name', key)
134
135
        if len(method) > 1:
136
            methods = cmd.add_element('method', method[0])
137
            for value, key in method[1].items():
138
                _data = methods.add_element('data', value)
139
                _data.add_element('name', key)
140
141
        if filter_id:
142
            cmd.add_element('filter', attrs={'id': filter_id})
143
144
        if copy:
145
            cmd.add_element('copy', copy)
146
147
        if comment:
148
            cmd.add_element('comment', comment)
149
150
        return cmd.to_string()
151
152
    def create_asset_command(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...
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...
153
        if asset_type not in ('host', 'os'):
154
            raise ValueError('create_asset requires asset_type to be either '
155
                             'host or os')
156
        cmd = XmlCommand('create_asset')
157
        asset = cmd.add_element('asset')
158
        asset.add_element('type', asset_type)
159
        asset.add_element('name', name)
160
161
        if comment:
162
            asset.add_element('comment', comment)
163
164
        return cmd.to_string()
165
166
    def create_authenticate_command(self, username, password):
0 ignored issues
show
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...
167
        """Generates string for authentification on gvmd
168
169
        Creates the gmp authentication xml string.
170
        Inserts the username and password into it.
171
172
        Keyword Arguments:
173
            username {str} -- Username for GVM User
174
            password {str} -- Password for GVM User
175
        """
176
        cmd = XmlCommand('authenticate')
177
178
        credentials = cmd.add_element('credentials')
179
        credentials.add_element('username', username)
180
        credentials.add_element('password', password)
181
182
        return cmd.to_string()
183
184
    def create_config_command(self, copy_id, name):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

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

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

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
185
        """Generates xml string for create config on gvmd."""
186
        cmd = XmlCommand('create_config')
187
        cmd.add_element('copy', copy_id)
188
        cmd.add_element('name', name)
189
190
        return cmd.to_string()
191
192 View Code Duplication
    def create_credential_command(self, name, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (22/15).
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...
193
        """Generates xml string for create credential on gvmd."""
194
        cmd = XmlCommand('create_credential')
195
        cmd.add_element('name', name)
196
197
        comment = kwargs.get('comment', '')
198
        if comment:
199
            cmd.add_element('comment', comment)
200
201
        copy = kwargs.get('copy', '')
202
        if copy:
203
            cmd.add_element('copy', copy)
204
205
        allow_insecure = kwargs.get('allow_insecure', '')
206
        if allow_insecure:
207
            cmd.add_element('allow_insecure', allow_insecure)
208
209
        certificate = kwargs.get('certificate', '')
210
        if certificate:
211
            cmd.add_element('certificate', certificate)
212
213
        key = kwargs.get('key', '')
214
        if key:
215
            phrase = key['phrase']
216
            private = key['private']
217
            if not phrase:
218
                raise ValueError('create_credential requires a phrase element')
219
            if not private:
220
                raise ValueError('create_credential requires a '
221
                                 'private element')
222
223
            _xmlkey = cmd.add_element('key')
224
            _xmlkey.add_element('phrase', phrase)
225
            _xmlkey.add_element('private', private)
226
227
        login = kwargs.get('login', '')
228
        if login:
229
            cmd.add_element('login', login)
230
231
        password = kwargs.get('password', '')
232
        if password:
233
            cmd.add_element('password', password)
234
235
        auth_algorithm = kwargs.get('auth_algorithm', '')
236
        if auth_algorithm:
237
            if auth_algorithm not in ('md5', 'sha1'):
238
                raise ValueError('create_credential requires auth_algorithm '
239
                                 'to be either md5 or sha1')
240
            cmd.add_element('auth_algorithm', auth_algorithm)
241
242
        community = kwargs.get('community', '')
243
        if community:
244
            cmd.add_element('community', community)
245
246
        privacy = kwargs.get('privacy', '')
247
        if privacy:
248
            algorithm = privacy.algorithm
249
            if algorithm not in ('aes', 'des'):
250
                raise ValueError('create_credential requires algorithm '
251
                                 'to be either aes or des')
252
            p_password = privacy.password
253
            _xmlprivacy = cmd.add_element('privacy')
254
            _xmlprivacy.add_element('algorithm', algorithm)
255
            _xmlprivacy.add_element('password', p_password)
256
257
        cred_type = kwargs.get('type', '')
258
        if cred_type:
259
            if cred_type not in ('cc', 'snmp', 'up', 'usk'):
260
                raise ValueError('create_credential requires type '
261
                                 'to be either cc, snmp, up or usk')
262
            cmd.add_element('type', cred_type)
263
264
        return cmd.to_string()
265
266
    def create_filter_command(self, name, make_unique, kwargs):
0 ignored issues
show
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...
267
        """Generates xml string for create filter on gvmd."""
268
269
        cmd = XmlCommand('create_filter')
270
        _xmlname = cmd.add_element('name', name)
271
        if make_unique:
272
            _xmlname.add_element('make_unique', '1')
273
        else:
274
            _xmlname.add_element('make_unique', '0')
275
276
        comment = kwargs.get('comment', '')
277
        if comment:
278
            cmd.add_element('comment', comment)
279
280
        copy = kwargs.get('copy', '')
281
        if copy:
282
            cmd.add_element('copy', copy)
283
284
        term = kwargs.get('term', '')
285
        if term:
286
            cmd.add_element('term', term)
287
288
        filter_type = kwargs.get('type', '')
289
        if filter_type:
290
            if filter_type not in FILTER_NAMES:
291
                raise ValueError('create_filter requires type '
292
                                 'to be either cc, snmp, up or usk')
293
            cmd.add_element('type', filter_type)
294
295
        return cmd.to_string()
296
297
    def create_group_command(self, name, kwargs):
0 ignored issues
show
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...
298
        """Generates xml string for create group on gvmd."""
299
300
        cmd = XmlCommand('create_group')
301
        cmd.add_element('name', name)
302
303
        comment = kwargs.get('comment', '')
304
        if comment:
305
            cmd.add_element('comment', comment)
306
307
        copy = kwargs.get('copy', '')
308
        if copy:
309
            cmd.add_element('copy', copy)
310
311
        special = kwargs.get('special', '')
312
        if special:
313
            _xmlspecial = cmd.add_element('specials')
314
            _xmlspecial.add_element('full')
315
316
        users = kwargs.get('users', '')
317
        if users:
318
            cmd.add_element('users', users)
319
320
        return cmd.to_string()
321
322
    def create_note_command(self, text, nvt_oid, kwargs):
0 ignored issues
show
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...
323
        """Generates xml string for create note on gvmd."""
324
325
        cmd = XmlCommand('create_note')
326
        cmd.add_element('text', text)
327
        cmd.add_element('nvt', attrs={"oid": nvt_oid})
328
329
        active = kwargs.get('active', '')
330
        if active:
331
            cmd.add_element('active', active)
332
333
        comment = kwargs.get('comment', '')
334
        if comment:
335
            cmd.add_element('comment', comment)
336
337
        copy = kwargs.get('copy', '')
338
        if copy:
339
            cmd.add_element('copy', copy)
340
341
        hosts = kwargs.get('hosts', '')
342
        if hosts:
343
            cmd.add_element('hosts', hosts)
344
345
        port = kwargs.get('port', '')
346
        if port:
347
            cmd.add_element('port', port)
348
349
        result_id = kwargs.get('result_id', '')
350
        if result_id:
351
            cmd.add_element('result', attrs={'id': result_id})
352
353
        severity = kwargs.get('severity', '')
354
        if severity:
355
            cmd.add_element('severity', severity)
356
357
        task_id = kwargs.get('task_id', '')
358
        if task_id:
359
            cmd.add_element('task', attrs={'id': task_id})
360
361
        threat = kwargs.get('threat', '')
362
        if threat:
363
            cmd.add_element('threat', threat)
364
365
        return cmd.to_string()
366
367
    def create_override_command(self, text, nvt_oid, kwargs):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
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...
368
        """Generates xml string for create override on gvmd."""
369
370
        cmd = XmlCommand('create_override')
371
        cmd.add_element('text', text)
372
        cmd.add_element('nvt', attrs={'oid': nvt_oid})
373
374
        active = kwargs.get('active', '')
375
        if active:
376
            cmd.add_element('active', active)
377
378
        comment = kwargs.get('comment', '')
379
        if comment:
380
            cmd.add_element('comment', comment)
381
382
        copy = kwargs.get('copy', '')
383
        if copy:
384
            cmd.add_element('copy', copy)
385
386
        hosts = kwargs.get('hosts', '')
387
        if hosts:
388
            cmd.add_element('hosts', hosts)
389
390
        port = kwargs.get('port', '')
391
        if port:
392
            cmd.add_element('port', port)
393
394
        result_id = kwargs.get('result_id', '')
395
        if result_id:
396
            cmd.add_element('result', attrs={'id': result_id})
397
398
        severity = kwargs.get('severity', '')
399
        if severity:
400
            cmd.add_element('severity', severity)
401
402
        new_severity = kwargs.get('new_severity', '')
403
        if new_severity:
404
            cmd.add_element('new_severity', new_severity)
405
406
        task_id = kwargs.get('task_id', '')
407
        if task_id:
408
            cmd.add_element('task', attrs={'id': task_id})
409
410
        threat = kwargs.get('threat', '')
411
        if threat:
412
            cmd.add_element('threat', threat)
413
414
        new_threat = kwargs.get('new_threat', '')
415
        if new_threat:
416
            cmd.add_element('new_threat', new_threat)
417
418
        return cmd.to_string()
419
420
    def create_permission_command(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...
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...
421
        # pretty(gmp.create_permission('get_version',
422
        # 'cc9cac5e-39a3-11e4-abae-406186ea4fc5', 'role'))
423
        # libs.gvm_connection.GMPError: Error in NAME
424
        # TODO: Research why!!
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
425
426
        if not name:
427
            raise ValueError('create_permission requires a name element')
428
        if not subject_id:
429
            raise ValueError('create_permission requires a subject_id element')
430
        if type not in ('user', 'group', 'role'):
431
            raise ValueError('create_permission requires type '
432
                             'to be either user, group or role')
433
434
        cmd = XmlCommand('create_permission')
435
        cmd.add_element('name', name)
436
        _xmlsubject = cmd.add_element('subject', attrs={'id': subject_id})
437
        _xmlsubject.add_element('type', type)
438
439
        comment = kwargs.get('comment', '')
440
        if comment:
441
            cmd.add_element('comment', comment)
442
443
        copy = kwargs.get('copy', '')
444
        if copy:
445
            cmd.add_element('copy', copy)
446
447
        resource = kwargs.get('resource', '')
448
        if resource:
449
            resource_id = resource.id
450
            resource_type = resource.type
451
            _xmlresource = cmd.add_element('resource',
452
                                           attrs={'id': resource_id})
453
            _xmlresource.add_element('type', resource_type)
454
455
        return cmd.to_string()
456
457
    def create_port_list_command(self, name, port_range, kwargs):
0 ignored issues
show
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...
458
        """Generates xml string for create port list on gvmd."""
459
        if not name:
460
            raise ValueError('create_port_list requires a name element')
461
        if not port_range:
462
            raise ValueError('create_port_list requires a port_range element')
463
464
        cmd = XmlCommand('create_port_list')
465
        cmd.add_element('name', name)
466
        cmd.add_element('port_range', port_range)
467
468
        comment = kwargs.get('comment', '')
469
        if comment:
470
            cmd.add_element('comment', comment)
471
472
        copy = kwargs.get('copy', '')
473
        if copy:
474
            cmd.add_element('copy', copy)
475
476
        return cmd.to_string()
477
478
    def create_port_range_command(self, port_list_id, start, end, type,
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...
best-practice introduced by
Too many arguments (6/5)
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...
479
                                  comment=''):
480
        """Generates xml string for create port range on gvmd."""
481
482
        if not port_list_id:
483
            raise ValueError('create_port_range requires '
484
                             'a port_list_id element')
485
        if not type:
486
            raise ValueError('create_port_range requires a type element')
487
488
        cmd = XmlCommand('create_port_range')
489
        cmd.add_element('port_list', attrs={'id': port_list_id})
490
        cmd.add_element('start', start)
491
        cmd.add_element('end', end)
492
        cmd.add_element('type', type)
493
494
        if comment:
495
            cmd.add_element('comment', comment)
496
497
        return cmd.to_string()
498
499
    def create_report_command(self, report_xml_string, kwargs):
0 ignored issues
show
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...
500
        """Generates xml string for create report on gvmd."""
501
502
        if not report_xml_string:
503
            raise ValueError('create_report requires a report')
504
505
        task_id = kwargs.get('task_id', '')
506
        task_name = kwargs.get('task_name', '')
507
508
        cmd = XmlCommand('create_report')
509
        comment = kwargs.get('comment', '')
510
        if task_id:
511
            cmd.add_element('task', attrs={'id': task_id})
512
        elif task_name:
513
            _xmltask = cmd.add_element('task')
514
            _xmltask.add_element('name', task_name)
515
            if comment:
516
                _xmltask.add_element('comment', comment)
517
        else:
518
            raise ValueError('create_report requires an id or name for a task')
519
520
        in_assets = kwargs.get('in_assets', '')
521
        if in_assets:
522
            cmd.add_element('in_assets', in_assets)
523
524
        cmd.append_xml_str(report_xml_string)
525
526
        return cmd.to_string()
527
528
    def create_role_command(self, name, kwargs):
0 ignored issues
show
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...
529
        """Generates xml string for create role on gvmd."""
530
531
        if not name:
532
            raise ValueError('create_role requires a name element')
533
534
        cmd = XmlCommand('create_role')
535
        cmd.add_element('name', name)
536
537
        comment = kwargs.get('comment', '')
538
        if comment:
539
            cmd.add_element('comment', comment)
540
541
        copy = kwargs.get('copy', '')
542
        if copy:
543
            cmd.add_element('copy', copy)
544
545
        users = kwargs.get('users', '')
546
        if users:
547
            cmd.add_element('users', users)
548
549
        return cmd.to_string()
550
551
    def create_scanner_command(self, name, host, port, type, ca_pub,
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...
best-practice introduced by
Too many arguments (8/5)
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...
552
                               credential_id, kwargs):
553
        """Generates xml string for create scanner on gvmd."""
554
        if not name:
555
            raise ValueError('create_scanner requires a name element')
556
        if not host:
557
            raise ValueError('create_scanner requires a host element')
558
        if not port:
559
            raise ValueError('create_scanner requires a port element')
560
        if not type:
561
            raise ValueError('create_scanner requires a type element')
562
        if not ca_pub:
563
            raise ValueError('create_scanner requires a ca_pub element')
564
        if not credential_id:
565
            raise ValueError('create_scanner requires a credential_id element')
566
567
        cmd = XmlCommand('create_scanner')
568
        cmd.add_element('name', name)
569
        cmd.add_element('host', host)
570
        cmd.add_element('port', port)
571
        cmd.add_element('type', type)
572
        cmd.add_element('ca_pub', ca_pub)
573
        cmd.add_element('credential', attrs={'id': str(credential_id)})
574
575
        comment = kwargs.get('comment', '')
576
        if comment:
577
            cmd.add_element('comment', comment)
578
579
        copy = kwargs.get('copy', '')
580
        if copy:
581
            cmd.add_element('copy', copy)
582
583
        return cmd.to_string()
584
585 View Code Duplication
    def create_schedule_command(self, name, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (19/15).
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...
586
        """Generates xml string for create schedule on gvmd."""
587
        if not name:
588
            raise ValueError('create_schedule requires a name element')
589
590
        cmd = XmlCommand('create_schedule')
591
        cmd.add_element('name', name)
592
593
        comment = kwargs.get('comment', '')
594
        if comment:
595
            cmd.add_element('comment', comment)
596
597
        copy = kwargs.get('copy', '')
598
        if copy:
599
            cmd.add_element('copy', copy)
600
601
        first_time = kwargs.get('first_time', '')
602
        if first_time:
603
            first_time_minute = first_time['minute']
604
            first_time_hour = first_time['hour']
605
            first_time_day_of_month = first_time['day_of_month']
606
            first_time_month = first_time['month']
607
            first_time_year = first_time['year']
608
609
            _xmlftime = cmd.add_element('first_time')
610
            _xmlftime.add_element('minute', first_time_minute)
611
            _xmlftime.add_element('hour', str(first_time_hour))
612
            _xmlftime.add_element('day_of_month', str(first_time_day_of_month))
613
            _xmlftime.add_element('month', str(first_time_month))
614
            _xmlftime.add_element('year', str(first_time_year))
615
616
        duration = kwargs.get('duration', '')
617
        if len(duration) > 1:
618
            _xmlduration = cmd.add_element('duration', str(duration[0]))
619
            _xmlduration.add_element('unit', str(duration[1]))
620
621
        period = kwargs.get('period', '')
622
        if len(period) > 1:
623
            _xmlperiod = cmd.add_element('period', str(period[0]))
624
            _xmlperiod.add_element('unit', str(period[1]))
625
626
        timezone = kwargs.get('timezone', '')
627
        if timezone:
628
            cmd.add_element('timezone', str(timezone))
629
630
        return cmd.to_string()
631
632
    def create_tag_command(self, name, resource_id, resource_type, kwargs):
0 ignored issues
show
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...
633
        """Generates xml string for create tag on gvmd."""
634
635
        cmd = XmlCommand('create_tag')
636
        cmd.add_element('name', name)
637
        _xmlresource = cmd.add_element('resource',
638
                                       attrs={'id': str(resource_id)})
639
        _xmlresource.add_element('type', resource_type)
640
641
        comment = kwargs.get('comment', '')
642
        if comment:
643
            cmd.add_element('comment', comment)
644
645
        copy = kwargs.get('copy', '')
646
        if copy:
647
            cmd.add_element('copy', copy)
648
649
        value = kwargs.get('value', '')
650
        if value:
651
            cmd.add_element('value', value)
652
653
        active = kwargs.get('active', '')
654
        if active:
655
            cmd.add_element('active', active)
656
657
        return cmd.to_string()
658
659
    def create_target_command(self, name, make_unique, kwargs):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
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...
660
        """Generates xml string for create target on gvmd."""
661
        if not name:
662
            raise ValueError('create_target requires a name element')
663
664
        cmd = XmlCommand('create_target')
665
        _xmlname = cmd.add_element('name', name)
666
        if make_unique:
667
            _xmlname.add_element('make_unique', '1')
668
        else:
669
            _xmlname.add_element('make_unique', '0')
670
671
        if 'asset_hosts' in kwargs:
672
            hosts = kwargs.get('asset_hosts')
673
            filter = hosts['filter']
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in filter.

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

Loading history...
674
            cmd.add_element('asset_hosts', attrs={'filter': str(filter)})
675
        elif 'hosts' in kwargs:
676
            hosts = kwargs.get('hosts')
677
            cmd.add_element('hosts', hosts)
678
        else:
679
            raise ValueError('create_target requires either a hosts or '
680
                             'an asset_hosts element')
681
682
        if 'comment' in kwargs:
683
            cmd.add_element('comment', kwargs.get('comment'))
684
685
        if 'copy' in kwargs:
686
            # NOTE: It seems that hosts/asset_hosts is silently ignored by the
687
            # server when copy is supplied. But for specification conformance
688
            # we raise the ValueError above and consider copy optional.
689
            cmd.add_element('copy', kwargs.get('copy'))
690
691
        if 'exclude_hosts' in kwargs:
692
            cmd.add_element('exclude_hosts', kwargs.get('exclude_hosts'))
693
694
        if 'ssh_credential' in kwargs:
695
            ssh_credential = kwargs.get('ssh_credential')
696
            if 'id' in ssh_credential:
697
                _xmlssh = cmd.add_element('ssh_credential', '',
698
                                          attrs={'id': ssh_credential['id']})
699
                if 'port' in ssh_credential:
700
                    _xmlssh.add_element('port', ssh_credential['port'])
701
            else:
702
                raise ValueError('ssh_credential requires an id attribute')
703
704
        if 'smb_credential' in kwargs:
705
            smb_credential = kwargs.get('smb_credential')
706
            if 'id' in smb_credential:
707
                cmd.add_element('smb_credential',
708
                                attrs={'id': smb_credential['id']})
709
            else:
710
                raise ValueError('smb_credential requires an id attribute')
711
712
        if 'esxi_credential' in kwargs:
713
            esxi_credential = kwargs.get('esxi_credential')
714
            if 'id' in esxi_credential:
715
                cmd.add_element('esxi_credential',
716
                                attrs={'id': esxi_credential['id']})
717
            else:
718
                raise ValueError('esxi_credential requires an id attribute')
719
720
        if 'snmp_credential' in kwargs:
721
            snmp_credential = kwargs.get('snmp_credential')
722
            if 'id' in snmp_credential:
723
                cmd.add_element('snmp_credential',
724
                                attrs={'id': snmp_credential['id']})
725
            else:
726
                raise ValueError('snmp_credential requires an id attribute')
727
728
        if 'alive_tests' in kwargs:
729
            # NOTE: As the alive_tests are referenced by their name and some
730
            # names contain ampersand ('&') characters it should be considered
731
            # replacing any characters special to XML in the variable with
732
            # their corresponding entities.
733
            cmd.add_element('alive_tests', kwargs.get('alive_tests'))
734
735
        if 'reverse_lookup_only' in kwargs:
736
            reverse_lookup_only = kwargs.get('reverse_lookup_only')
737
            if reverse_lookup_only:
738
                cmd.add_element('reverse_lookup_only', '1')
739
            else:
740
                cmd.add_element('reverse_lookup_only', '0')
741
742
        if 'reverse_lookup_unify' in kwargs:
743
            reverse_lookup_unify = kwargs.get('reverse_lookup_unify')
744
            if reverse_lookup_unify:
745
                cmd.add_element('reverse_lookup_unify', '1')
746
            else:
747
                cmd.add_element('reverse_lookup_unify', '0')
748
749
        if 'port_range' in kwargs:
750
            cmd.add_element('port_range', kwargs.get('port_range'))
751
752
        if 'port_list' in kwargs:
753
            port_list = kwargs.get('port_list')
754
            if 'id' in port_list:
755
                cmd.add_element('port_list',
756
                                attrs={'id': str(port_list['id'])})
757
            else:
758
                raise ValueError('port_list requires an id attribute')
759
760
        return cmd.to_string()
761
762
    def create_task_command(self, name, config_id, target_id, scanner_id,
0 ignored issues
show
best-practice introduced by
Too many arguments (7/5)
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...
763
                            alert_ids=None, comment=''):
764
        """Generates xml string for create task on gvmd."""
765
766
        if alert_ids is None:
767
            alert_ids = []
768
        cmd = XmlCommand('create_task')
769
        cmd.add_element('name', name)
770
        cmd.add_element('comment', comment)
771
        cmd.add_element('config', attrs={'id': config_id})
772
        cmd.add_element('target', attrs={'id': target_id})
773
        cmd.add_element('scanner', attrs={'id': scanner_id})
774
775
        #if given the alert_id is wrapped and integrated suitably as xml
776
        if len(alert_ids) > 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
777
            if isinstance(alert_ids, str):
778
                #if a single id is given as a string wrap it into a list
779
                alert_ids = [alert_ids]
780
            if isinstance(alert_ids, list):
781
                #parse all given alert id's
782
                for alert in alert_ids:
783
                    cmd.add_element('alert', attrs={'id': str(alert)})
784
785
        return cmd.to_string()
786
787
    def create_user_command(self, name, password, copy='', hosts_allow='0',
0 ignored issues
show
best-practice introduced by
Too many arguments (9/5)
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...
788
                            ifaces_allow='0', role_ids=(), hosts=None,
789
                            ifaces=None):
790
        """Generates xml string for create user on gvmd."""
791
        cmd = XmlCommand('create_user')
792
        cmd.add_element('name', name)
793
794
        if copy:
795
            cmd.add_element('copy', copy)
796
797
        if password:
798
            cmd.add_element('password', password)
799
800
        if hosts is not None:
801
            cmd.add_element('hosts', hosts, attrs={'allow': str(hosts_allow)})
802
803
        if ifaces is not None:
804
            cmd.add_element('ifaces', ifaces,
805
                            attrs={'allow': str(ifaces_allow)})
806
807
        if len(role_ids) > 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
808
            for role in role_ids:
809
                cmd.add_element('role', attrs={'allow': str(role)})
810
811
        return cmd.to_string()
812
813
    def modify_agent_command(self, agent_id, name='', comment=''):
0 ignored issues
show
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...
814
        """Generates xml string for modify agent on gvmd."""
815
        if not agent_id:
816
            raise ValueError('modify_agent requires an agent_id element')
817
818
        cmd = XmlCommand('modify_agent')
819
        cmd.set_attribute('agent_id', str(agent_id))
820
        if name:
821
            cmd.add_element('name', name)
822
        if comment:
823
            cmd.add_element('comment', comment)
824
825
        return cmd.to_string()
826
827
    def modify_alert_command(self, alert_id, kwargs):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
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...
828
        """Generates xml string for modify alert on gvmd."""
829
830
        if not alert_id:
831
            raise ValueError('modify_alert requires an agent_id element')
832
833
        cmd = XmlCommand('modify_alert')
834
        cmd.set_attribute('alert_id', str(alert_id))
835
836
        name = kwargs.get('name', '')
837
        if name:
838
            cmd.add_element('name', name)
839
840
        comment = kwargs.get('comment', '')
841
        if comment:
842
            cmd.add_element('comment', comment)
843
844
        filter_id = kwargs.get('filter_id', '')
845
        if filter_id:
846
            cmd.add_element('filter', attrs={'id': filter_id})
847
848
        event = kwargs.get('event', '')
849
        if len(event) > 1:
850
            _xmlevent = cmd.add_element('event', event[0])
851
            for value, key in event[1].items():
852
                _xmldata = _xmlevent.add_element('data', value)
853
                _xmldata.add_element('name', key)
854
855
        condition = kwargs.get('condition', '')
856
        if len(condition) > 1:
857
            _xmlcond = cmd.add_element('condition', condition[0])
858
            for value, key in condition[1].items():
859
                _xmldata = _xmlcond.add_element('data', value)
860
                _xmldata.add_element('name', key)
861
862
        method = kwargs.get('method', '')
863
        if len(method) > 1:
864
            _xmlmethod = cmd.add_element('method', method[0])
865
            for value, key in method[1].items():
866
                _xmldata = _xmlmethod.add_element('data', value)
867
                _xmldata.add_element('name', key)
868
869
        return cmd.to_string()
870
871
    def modify_auth_command(self, group_name, auth_conf_settings):
0 ignored issues
show
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...
872
        """Generates xml string for modify auth on gvmd."""
873
        if not group_name:
874
            raise ValueError('modify_auth requires a group element '
875
                             'with a name attribute')
876
        if not auth_conf_settings:
877
            raise ValueError('modify_auth requires '
878
                             'an auth_conf_settings element')
879
        cmd = XmlCommand('modify_auth')
880
        _xmlgroup = cmd.add_element('group', attrs={'name': str(group_name)})
881
882
        for key, value in auth_conf_settings.items():
883
            _xmlauthconf = _xmlgroup.add_element('auth_conf_setting')
884
            _xmlauthconf.add_element('key', key)
885
            _xmlauthconf.add_element('value', value)
886
887
        return cmd.to_string()
888
889
    def modify_config_command(self, selection, kwargs):
0 ignored issues
show
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...
890
        """Generates xml string for modify config on gvmd."""
891
        if selection not in ('nvt_pref', 'sca_pref',
892
                             'family_selection', 'nvt_selection'):
893
            raise ValueError('selection must be one of nvt_pref, sca_pref, '
894
                             'family_selection or nvt_selection')
895
        config_id = kwargs.get('config_id')
896
897
        cmd = XmlCommand('modify_config')
898
        cmd.set_attribute('config_id', str(config_id))
899
900
        if selection in 'nvt_pref':
901
            nvt_oid = kwargs.get('nvt_oid')
902
            name = kwargs.get('name')
903
            value = kwargs.get('value')
904
            _xmlpref = cmd.add_element('preference')
905
            _xmlpref.add_element('nvt', attrs={'oid': nvt_oid})
906
            _xmlpref.add_element('name', name)
907
            _xmlpref.add_element('value', value)
908
909
        elif selection in 'nvt_selection':
910
            nvt_oid = kwargs.get('nvt_oid')
911
            family = kwargs.get('family')
912
            _xmlnvtsel = cmd.add_element('nvt_selection')
913
            _xmlnvtsel.add_element('family', family)
914
915
            if isinstance(nvt_oid, list):
916
                for nvt in nvt_oid:
917
                    _xmlnvtsel.add_element('nvt', attrs={'oid': nvt})
918
            else:
919
                _xmlnvtsel.add_element('nvt', attrs={'oid': nvt_oid})
920
921
        elif selection in 'family_selection':
922
            family = kwargs.get('family')
923
            _xmlfamsel = cmd.add_element('family_selection')
924
            _xmlfamsel.add_element('growing', '1')
925
            _xmlfamily = _xmlfamsel.add_element('family')
926
            _xmlfamily.add_element('name', family)
927
            _xmlfamily.add_element('all', '1')
928
            _xmlfamily.add_element('growing', '1')
929
        else:
930
            raise NotImplementedError
931
932
        return cmd.to_string()
933
934 View Code Duplication
    def modify_credential_command(self, credential_id, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (22/15).
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...
935
        """Generates xml string for modify credential on gvmd."""
936
        if not credential_id:
937
            raise ValueError('modify_credential requires '
938
                             'a credential_id attribute')
939
940
        cmd = XmlCommand('modify_credential')
941
        cmd.set_attribute('credential_id', credential_id)
942
943
        comment = kwargs.get('comment', '')
944
        if comment:
945
            cmd.add_element('comment', comment)
946
947
        name = kwargs.get('name', '')
948
        if name:
949
            cmd.add_element('name', name)
950
951
        allow_insecure = kwargs.get('allow_insecure', '')
952
        if allow_insecure:
953
            cmd.add_element('allow_insecure', allow_insecure)
954
955
        certificate = kwargs.get('certificate', '')
956
        if certificate:
957
            cmd.add_element('certificate', certificate)
958
959
        key = kwargs.get('key', '')
960
        if key:
961
            phrase = key['phrase']
962
            private = key['private']
963
            if not phrase:
964
                raise ValueError('modify_credential requires a phrase element')
965
            if not private:
966
                raise ValueError('modify_credential requires '
967
                                 'a private element')
968
            _xmlkey = cmd.add_element('key')
969
            _xmlkey.add_element('phrase', phrase)
970
            _xmlkey.add_element('private', private)
971
972
        login = kwargs.get('login', '')
973
        if login:
974
            cmd.add_element('login', login)
975
976
        password = kwargs.get('password', '')
977
        if password:
978
            cmd.add_element('password', password)
979
980
        auth_algorithm = kwargs.get('auth_algorithm', '')
981
        if auth_algorithm:
982
            if auth_algorithm not in ('md5', 'sha1'):
983
                raise ValueError('modify_credential requires auth_algorithm '
984
                                 'to be either md5 or sha1')
985
            cmd.add_element('auth_algorithm', auth_algorithm)
986
987
        community = kwargs.get('community', '')
988
        if community:
989
            cmd.add_element('community', community)
990
991
        privacy = kwargs.get('privacy', '')
992
        if privacy:
993
            algorithm = privacy.algorithm
994
            if algorithm not in ('aes', 'des'):
995
                raise ValueError('modify_credential requires algorithm '
996
                                 'to be either aes or des')
997
            p_password = privacy.password
998
            _xmlprivacy = cmd.add_element('privacy')
999
            _xmlprivacy.add_element('algorithm', algorithm)
1000
            _xmlprivacy.add_element('password', p_password)
1001
1002
        cred_type = kwargs.get('type', '')
1003
        if cred_type:
1004
            if cred_type not in ('cc', 'snmp', 'up', 'usk'):
1005
                raise ValueError('modify_credential requires type '
1006
                                 'to be either cc, snmp, up or usk')
1007
            cmd.add_element('type', cred_type)
1008
1009
        return cmd.to_string()
1010
1011
    def modify_filter_command(self, filter_id, kwargs):
0 ignored issues
show
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...
1012
        """Generates xml string for modify filter on gvmd."""
1013
        if not filter_id:
1014
            raise ValueError('modify_filter requires a filter_id attribute')
1015
1016
        cmd = XmlCommand('modify_filter')
1017
        cmd.set_attribute('filter_id', filter_id)
1018
1019
        comment = kwargs.get('comment', '')
1020
        if comment:
1021
            cmd.add_element('comment', comment)
1022
1023
        name = kwargs.get('name', '')
1024
        if name:
1025
            cmd.add_element('name', name)
1026
1027
        copy = kwargs.get('copy', '')
1028
        if copy:
1029
            cmd.add_element('copy', copy)
1030
1031
        term = kwargs.get('term', '')
1032
        if term:
1033
            cmd.add_element('term', term)
1034
1035
        filter_type = kwargs.get('type', '')
1036
        if filter_type:
1037
            if filter_type not in ('cc', 'snmp', 'up', 'usk'):
1038
                raise ValueError('modify_filter requires type '
1039
                                 'to be either cc, snmp, up or usk')
1040
            cmd.add_element('type', filter_type)
1041
1042
        return cmd.to_string()
1043
1044 View Code Duplication
    def modify_group_command(self, group_id, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
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...
1045
        """Generates xml string for modify group on gvmd."""
1046
        if not group_id:
1047
            raise ValueError('modify_group requires a group_id attribute')
1048
1049
        cmd = XmlCommand('modify_group')
1050
        cmd.set_attribute('group_id', group_id)
1051
1052
        comment = kwargs.get('comment', '')
1053
        if comment:
1054
            cmd.add_element('comment', comment)
1055
1056
        name = kwargs.get('name', '')
1057
        if name:
1058
            cmd.add_element('name', name)
1059
1060
        users = kwargs.get('users', '')
1061
        if users:
1062
            cmd.add_element('users', users)
1063
1064
        return cmd.to_string()
1065
1066
    def modify_note_command(self, note_id, text, kwargs):
0 ignored issues
show
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...
1067
        """Generates xml string for modify note on gvmd."""
1068
        if not note_id:
1069
            raise ValueError('modify_note requires a note_id attribute')
1070
        if not text:
1071
            raise ValueError('modify_note requires a text element')
1072
1073
        cmd = XmlCommand('modify_note')
1074
        cmd.set_attribute('note_id', note_id)
1075
        cmd.add_element('text', text)
1076
1077
        active = kwargs.get('active', '')
1078
        if active:
1079
            cmd.add_element('active', active)
1080
1081
        hosts = kwargs.get('hosts', '')
1082
        if hosts:
1083
            cmd.add_element('hosts', hosts)
1084
1085
        port = kwargs.get('port', '')
1086
        if port:
1087
            cmd.add_element('port', port)
1088
1089
        result_id = kwargs.get('result_id', '')
1090
        if result_id:
1091
            cmd.add_element('result', attrs={'id': result_id})
1092
1093
        severity = kwargs.get('severity', '')
1094
        if severity:
1095
            cmd.add_element('severity', severity)
1096
1097
        task_id = kwargs.get('task_id', '')
1098
        if task_id:
1099
            cmd.add_element('task', attrs={'id': task_id})
1100
1101
        threat = kwargs.get('threat', '')
1102
        if threat:
1103
            cmd.add_element('threat', threat)
1104
1105
        return cmd.to_string()
1106
1107
    def modify_override_command(self, override_id, text, kwargs):
0 ignored issues
show
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...
1108
        """Generates xml string for modify override on gvmd."""
1109
        cmd = XmlCommand('modify_override')
1110
        cmd.set_attribute('override_id', override_id)
1111
        cmd.add_element('text', text)
1112
1113
        active = kwargs.get('active', '')
1114
        if active:
1115
            cmd.add_element('active', active)
1116
1117
        hosts = kwargs.get('hosts', '')
1118
        if hosts:
1119
            cmd.add_element('hosts', hosts)
1120
1121
        port = kwargs.get('port', '')
1122
        if port:
1123
            cmd.add_element('port', port)
1124
1125
        result_id = kwargs.get('result_id', '')
1126
        if result_id:
1127
            cmd.add_element('result', attrs={'id': result_id})
1128
1129
        severity = kwargs.get('severity', '')
1130
        if severity:
1131
            cmd.add_element('severity', severity)
1132
1133
        new_severity = kwargs.get('new_severity', '')
1134
        if new_severity:
1135
            cmd.add_element('new_severity', new_severity)
1136
1137
        task_id = kwargs.get('task_id', '')
1138
        if task_id:
1139
            cmd.add_element('task', attrs={'id': task_id})
1140
1141
        threat = kwargs.get('threat', '')
1142
        if threat:
1143
            cmd.add_element('threat', threat)
1144
1145
        new_threat = kwargs.get('new_threat', '')
1146
        if new_threat:
1147
            cmd.add_element('new_threat', new_threat)
1148
1149
        return cmd.to_string()
1150
1151
    def modify_permission_command(self, permission_id, kwargs):
0 ignored issues
show
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...
1152
        """Generates xml string for modify permission on gvmd."""
1153
        if not permission_id:
1154
            raise ValueError('modify_permission requires '
1155
                             'a permission_id element')
1156
1157
        cmd = XmlCommand('modify_permission')
1158
        cmd.set_attribute('permission_id', permission_id)
1159
1160
        comment = kwargs.get('comment', '')
1161
        if comment:
1162
            cmd.add_element('comment', comment)
1163
1164
        name = kwargs.get('name', '')
1165
        if name:
1166
            cmd.add_element('name', name)
1167
1168
        resource = kwargs.get('resource', '')
1169
        if resource:
1170
            resource_id = resource['id']
1171
            resource_type = resource['type']
1172
            _xmlresource = cmd.add_element('resource',
1173
                                           attrs={'id': resource_id})
1174
            _xmlresource.add_element('type', resource_type)
1175
1176
        subject = kwargs.get('subject', '')
1177
        if subject:
1178
            subject_id = subject['id']
1179
            subject_type = subject['type']
1180
            _xmlsubject = cmd.add_element('subject', attrs={'id': subject_id})
1181
            _xmlsubject.add_element('type', subject_type)
1182
1183
        return cmd.to_string()
1184
1185
    def modify_port_list_command(self, port_list_id, kwargs):
0 ignored issues
show
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...
1186
        """Generates xml string for modify port list on gvmd."""
1187
        if not port_list_id:
1188
            raise ValueError('modify_port_list requires '
1189
                             'a port_list_id attribute')
1190
        cmd = XmlCommand('modify_port_list')
1191
        cmd.set_attribute('port_list_id', port_list_id)
1192
1193
        comment = kwargs.get('comment', '')
1194
        if comment:
1195
            cmd.add_element('comment', comment)
1196
1197
        name = kwargs.get('name', '')
1198
        if name:
1199
            cmd.add_element('name', name)
1200
1201
        return cmd.to_string()
1202
1203
    def modify_report_format_command(self, report_format_id, kwargs):
0 ignored issues
show
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...
1204
        """Generates xml string for modify report format on gvmd."""
1205
        if len(kwargs) < 1:
1206
            raise Exception('modify_report_format: Missing parameter')
1207
1208
        cmd = XmlCommand('modify_report_format')
1209
        cmd.set_attribute('report_format_id', report_format_id)
1210
1211
        active = kwargs.get('active', '')
1212
        if active:
1213
            cmd.add_element('active', active)
1214
1215
        name = kwargs.get('name', '')
1216
        if name:
1217
            cmd.add_element('name', name)
1218
1219
        summary = kwargs.get('summary', '')
1220
        if summary:
1221
            cmd.add_element('summary', summary)
1222
1223
        param = kwargs.get('param', '')
1224
        if param:
1225
            p_name = param[0]
1226
            p_value = param[1]
1227
            _xmlparam = cmd.add_element('param')
1228
            _xmlparam.add_element('name', p_name)
1229
            _xmlparam.add_element('value', p_value)
1230
1231
        return cmd.to_string()
1232
1233 View Code Duplication
    def modify_role_command(self, role_id, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
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...
1234
        """Generates xml string for modify role on gvmd."""
1235
        if not role_id:
1236
            raise ValueError('modify_role requires a role_id element')
1237
1238
        cmd = XmlCommand('modify_role')
1239
        cmd.set_attribute('role_id', role_id)
1240
1241
        comment = kwargs.get('comment', '')
1242
        if comment:
1243
            cmd.add_element('comment', comment)
1244
1245
        name = kwargs.get('name', '')
1246
        if name:
1247
            cmd.add_element('name', name)
1248
1249
        users = kwargs.get('users', '')
1250
        if users:
1251
            cmd.add_element('users', users)
1252
1253
        return cmd.to_string()
1254
1255
    def modify_scanner_command(self, scanner_id, host, port, scanner_type,
0 ignored issues
show
best-practice introduced by
Too many arguments (6/5)
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...
1256
                               kwargs):
1257
        """Generates xml string for modify scanner on gvmd."""
1258
        if not scanner_id:
1259
            raise ValueError('modify_scanner requires a scanner_id element')
1260
        if not host:
1261
            raise ValueError('modify_scanner requires a host element')
1262
        if not port:
1263
            raise ValueError('modify_scanner requires a port element')
1264
        if not scanner_type:
1265
            raise ValueError('modify_scanner requires a type element')
1266
1267
        cmd = XmlCommand('modify_scanner')
1268
        cmd.set_attribute('scanner_id', scanner_id)
1269
        cmd.add_element('host', host)
1270
        cmd.add_element('port', port)
1271
        cmd.add_element('type', scanner_type)
1272
1273
        comment = kwargs.get('comment', '')
1274
        if comment:
1275
            cmd.add_element('comment', comment)
1276
1277
        name = kwargs.get('name', '')
1278
        if name:
1279
            cmd.add_element('name', name)
1280
1281
        ca_pub = kwargs.get('ca_pub', '')
1282
        if ca_pub:
1283
            cmd.add_element('ca_pub', ca_pub)
1284
1285
        credential_id = kwargs.get('credential_id', '')
1286
        if credential_id:
1287
            cmd.add_element('credential', attrs={'id': str(credential_id)})
1288
1289
        return cmd.to_string()
1290
1291 View Code Duplication
    def modify_schedule_command(self, schedule_id, kwargs):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (19/15).
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...
1292
        """Generates xml string for modify schedule on gvmd."""
1293
        if not schedule_id:
1294
            raise ValueError('modify_schedule requires a schedule_id element')
1295
1296
        cmd = XmlCommand('modify_schedule')
1297
        cmd.set_attribute('schedule_id', schedule_id)
1298
        comment = kwargs.get('comment', '')
1299
        if comment:
1300
            cmd.add_element('comment', comment)
1301
1302
        name = kwargs.get('name', '')
1303
        if name:
1304
            cmd.add_element('name', name)
1305
1306
        first_time = kwargs.get('first_time', '')
1307
        if first_time:
1308
            first_time_minute = first_time['minute']
1309
            first_time_hour = first_time['hour']
1310
            first_time_day_of_month = first_time['day_of_month']
1311
            first_time_month = first_time['month']
1312
            first_time_year = first_time['year']
1313
1314
            _xmlftime = cmd.add_element('first_time')
1315
            _xmlftime.add_element('minute', str(first_time_minute))
1316
            _xmlftime.add_element('hour', str(first_time_hour))
1317
            _xmlftime.add_element('day_of_month', str(first_time_day_of_month))
1318
            _xmlftime.add_element('month', str(first_time_month))
1319
            _xmlftime.add_element('year', str(first_time_year))
1320
1321
        duration = kwargs.get('duration', '')
1322
        if len(duration) > 1:
1323
            _xmlduration = cmd.add_element('duration', str(duration[0]))
1324
            _xmlduration.add_element('unit', str(duration[1]))
1325
1326
        period = kwargs.get('period', '')
1327
        if len(period) > 1:
1328
            _xmlperiod = cmd.add_element('period', str(period[0]))
1329
            _xmlperiod.add_element('unit', str(period[1]))
1330
1331
        timezone = kwargs.get('timezone', '')
1332
        if timezone:
1333
            cmd.add_element('timezone', str(timezone))
1334
1335
        return cmd.to_string()
1336
1337
    def modify_tag_command(self, tag_id, kwargs):
0 ignored issues
show
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...
1338
        """Generates xml string for modify tag on gvmd."""
1339
        if not tag_id:
1340
            raise ValueError('modify_tag requires a tag_id element')
1341
1342
        cmd = XmlCommand('modify_tag')
1343
        cmd.set_attribute('tag_id', str(tag_id))
1344
1345
        comment = kwargs.get('comment', '')
1346
        if comment:
1347
            cmd.add_element('comment', comment)
1348
1349
        name = kwargs.get('name', '')
1350
        if name:
1351
            cmd.add_element('name', name)
1352
1353
        value = kwargs.get('value', '')
1354
        if value:
1355
            cmd.add_element('value', value)
1356
1357
        active = kwargs.get('active', '')
1358
        if active:
1359
            cmd.add_element('active', value)
1360
1361
        resource = kwargs.get('resource', '')
1362
        if resource:
1363
            resource_id = resource['id']
1364
            resource_type = resource['type']
1365
            _xmlresource = cmd.add_element('resource',
1366
                                           attrs={'resource_id': resource_id})
1367
            _xmlresource.add_element('type', resource_type)
1368
1369
        return cmd.to_string()
1370
1371
    def modify_target_command(self, target_id, kwargs):
0 ignored issues
show
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...
1372
        """Generates xml string for modify target on gvmd."""
1373
        if not target_id:
1374
            raise ValueError('modify_target requires a target_id element')
1375
1376
        cmd = XmlCommand('modify_target')
1377
        cmd.set_attribute('target_id', target_id)
1378
1379
        comment = kwargs.get('comment', '')
1380
        if comment:
1381
            cmd.add_element('comment', comment)
1382
1383
        name = kwargs.get('name', '')
1384
        if name:
1385
            cmd.add_element('name', name)
1386
1387
        hosts = kwargs.get('hosts', '')
1388
        if hosts:
1389
            cmd.add_element('hosts', hosts)
1390
1391
        copy = kwargs.get('copy', '')
1392
        if copy:
1393
            cmd.add_element('copy', copy)
1394
1395
        exclude_hosts = kwargs.get('exclude_hosts', '')
1396
        if exclude_hosts:
1397
            cmd.add_element('exclude_hosts', exclude_hosts)
1398
1399
        alive_tests = kwargs.get('alive_tests', '')
1400
        if alive_tests:
1401
            cmd.add_element('alive_tests', alive_tests)
1402
1403
        reverse_lookup_only = kwargs.get('reverse_lookup_only', '')
1404
        if reverse_lookup_only:
1405
            cmd.add_element('reverse_lookup_only', reverse_lookup_only)
1406
1407
        reverse_lookup_unify = kwargs.get('reverse_lookup_unify', '')
1408
        if reverse_lookup_unify:
1409
            cmd.add_element('reverse_lookup_unify', reverse_lookup_unify)
1410
1411
        port_range = kwargs.get('port_range', '')
1412
        if port_range:
1413
            cmd.add_element('port_range', port_range)
1414
1415
        port_list = kwargs.get('port_list', '')
1416
        if port_list:
1417
            cmd.add_element('port_list', attrs={'id': str(port_list)})
1418
1419
        return cmd.to_string()
1420
1421
    def modify_task_command(self, task_id, kwargs):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (22/15).
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...
1422
        """Generates xml string for modify task on gvmd."""
1423
        if not task_id:
1424
            raise ValueError('modify_task requires a task_id element')
1425
1426
        cmd = XmlCommand('modify_task')
1427
        cmd.set_attribute('task_id', task_id)
1428
1429
        name = kwargs.get('name', '')
1430
        if name:
1431
            cmd.add_element('name', name)
1432
1433
        comment = kwargs.get('comment', '')
1434
        if comment:
1435
            cmd.add_element('comment', comment)
1436
1437
        target_id = kwargs.get('target_id', '')
1438
        if target_id:
1439
            cmd.add_element('target', attrs={'id': target_id})
1440
1441
        scanner = kwargs.get('scanner', '')
1442
        if scanner:
1443
            cmd.add_element('scanner', attrs={'id': scanner})
1444
1445
        schedule_periods = kwargs.get('schedule_periods', '')
1446
        if schedule_periods:
1447
            cmd.add_element('schedule_periods', str(schedule_periods))
1448
1449
        schedule = kwargs.get('schedule', '')
1450
        if schedule:
1451
            cmd.add_element('schedule', attrs={'id': str(schedule)})
1452
1453
        alert = kwargs.get('alert', '')
1454
        if alert:
1455
            cmd.add_element('alert', attrs={'id': str(alert)})
1456
1457
        observers = kwargs.get('observers', '')
1458
        if observers:
1459
            cmd.add_element('observers', str(observers))
1460
1461
        preferences = kwargs.get('preferences', '')
1462
        if preferences:
1463
            _xmlprefs = cmd.add_element('preferences')
1464
            for n in range(len(preferences["scanner_name"])):
0 ignored issues
show
Coding Style Naming introduced by
The name n 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...
1465
                preferences_scanner_name = preferences["scanner_name"][n]
1466
                preferences_value = preferences["value"][n]
1467
                _xmlpref = _xmlprefs.add_element('preference')
1468
                _xmlpref.add_element('scanner_name', preferences_scanner_name)
1469
                _xmlpref.add_element('value', preferences_value)
1470
1471
        file = kwargs.get('file', '')
1472
        if file:
1473
            file_name = file['name']
1474
            file_action = file['action']
1475
            if file_action != "update" and file_action != "remove":
1476
                raise ValueError('action can only be "update" or "remove"!')
1477
            cmd.add_element('file', attrs={'name': file_name,
1478
                                           'action': file_action})
1479
1480
        return cmd.to_string()
1481
1482
    def modify_user_command(self, kwargs):
0 ignored issues
show
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...
1483
        """Generates xml string for modify user on gvmd."""
1484
        user_id = kwargs.get('user_id', '')
1485
        name = kwargs.get('name', '')
1486
1487
        if not user_id and not name:
1488
            raise ValueError('modify_user requires '
1489
                             'either a user_id or a name element')
1490
1491
        cmd = XmlCommand('modify_user')
1492
        cmd.set_attribute('user_id', str(user_id))
1493
1494
        new_name = kwargs.get('new_name', '')
1495
        if new_name:
1496
            cmd.add_element('new_name', new_name)
1497
1498
        password = kwargs.get('password', '')
1499
        if password:
1500
            cmd.add_element('password', password)
1501
1502
        role_ids = kwargs.get('role_ids', '')
1503
        if len(role_ids) > 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
1504
            for role in role_ids:
1505
                cmd.add_element('role', attrs={'id': str(role)})
1506
1507
        hosts = kwargs.get('hosts', '')
1508
        hosts_allow = kwargs.get('hosts_allow', '')
1509
        if hosts or hosts_allow:
1510
            cmd.add_element('hosts', hosts, attrs={'allow': str(hosts_allow)})
1511
1512
        ifaces = kwargs.get('ifaces', '')
1513
        ifaces_allow = kwargs.get('ifaces_allow', '')
1514
        if ifaces or ifaces_allow:
1515
            cmd.add_element('ifaces', ifaces,
1516
                            attrs={'allow': str(ifaces_allow)})
1517
1518
        sources = kwargs.get('sources', '')
1519
        if sources:
1520
            cmd.add_element('sources', sources)
1521
1522
        return cmd.to_string()
1523
1524
    def delete_agent_command(self, kwargs):
0 ignored issues
show
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...
1525
        """Generates xml string for delete agent on gvmd"""
1526
        cmd = XmlCommand('delete_agent')
1527
        for key, value in kwargs.items():
1528
            cmd.set_attribute(key, value)
1529
1530
        return cmd.to_string()
1531
1532
    def delete_alert_command(self, kwargs):
0 ignored issues
show
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...
1533
        """Generates xml string for delete alert on gvmd"""
1534
        cmd = XmlCommand('delete_alert')
1535
        for key, value in kwargs.items():
1536
            cmd.set_attribute(key, value)
1537
1538
        return cmd.to_string()
1539
1540
    def delete_asset_command(self, asset_id, ultimate=0):
0 ignored issues
show
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...
1541
        """Generates xml string for delete asset on gvmd"""
1542
        cmd = XmlCommand('delete_asset')
1543
        cmd.set_attribute('asset_id', asset_id)
1544
        cmd.set_attribute('ultimate', ultimate)
1545
1546
        return cmd.to_string()
1547
1548
    def delete_config_command(self, config_id, ultimate=0):
0 ignored issues
show
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...
1549
        """Generates xml string for delete config on gvmd"""
1550
        cmd = XmlCommand('delete_config')
1551
        cmd.set_attribute('config_id', config_id)
1552
        cmd.set_attribute('ultimate', ultimate)
1553
1554
        return cmd.to_string()
1555
1556
    def delete_credential_command(self, credential_id, ultimate=0):
0 ignored issues
show
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...
1557
        """Generates xml string for delete credential on gvmd"""
1558
        cmd = XmlCommand('delete_credential')
1559
        cmd.set_attribute('credential_id', credential_id)
1560
        cmd.set_attribute('ultimate', ultimate)
1561
        return cmd.to_string()
1562
1563
    def delete_filter_command(self, filter_id, ultimate=0):
0 ignored issues
show
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...
1564
        """Generates xml string for delete filter on gvmd"""
1565
        cmd = XmlCommand('delete_filter')
1566
        cmd.set_attribute('filter_id', filter_id)
1567
        cmd.set_attribute('ultimate', ultimate)
1568
1569
        return cmd.to_string()
1570
1571
    def delete_group_command(self, group_id, ultimate=0):
0 ignored issues
show
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...
1572
        """Generates xml string for delete group on gvmd"""
1573
        cmd = XmlCommand('delete_group')
1574
        cmd.set_attribute('group_id', group_id)
1575
        cmd.set_attribute('ultimate', ultimate)
1576
1577
        return cmd.to_string()
1578
1579
    def delete_note_command(self, note_id, ultimate=0):
0 ignored issues
show
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...
1580
        """Generates xml string for delete note on gvmd"""
1581
        cmd = XmlCommand('delete_note')
1582
        cmd.set_attribute('note_id', note_id)
1583
        cmd.set_attribute('ultimate', ultimate)
1584
1585
        return cmd.to_string()
1586
1587
    def delete_override_command(self, override_id, ultimate=0):
0 ignored issues
show
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...
1588
        """Generates xml string for delete override on gvmd"""
1589
        cmd = XmlCommand('delete_override')
1590
        cmd.set_attribute('override_id', override_id)
1591
        cmd.set_attribute('ultimate', ultimate)
1592
1593
        return cmd.to_string()
1594
1595
    def delete_permission_command(self, permission_id, ultimate=0):
0 ignored issues
show
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...
1596
        """Generates xml string for delete permission on gvmd"""
1597
        cmd = XmlCommand('delete_permission')
1598
        cmd.set_attribute('permission_id', permission_id)
1599
        cmd.set_attribute('ultimate', ultimate)
1600
1601
        return cmd.to_string()
1602
1603
    def delete_port_list_command(self, port_list_id, ultimate=0):
0 ignored issues
show
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...
1604
        """Generates xml string for delete port on gvmd"""
1605
        cmd = XmlCommand('delete_port_list')
1606
        cmd.set_attribute('port_list_id', port_list_id)
1607
        cmd.set_attribute('ultimate', ultimate)
1608
1609
        return cmd.to_string()
1610
1611
    def delete_port_range_command(self, port_range_id):
0 ignored issues
show
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...
1612
        """Generates xml string for delete port on gvmd"""
1613
        cmd = XmlCommand('delete_port_range')
1614
        cmd.set_attribute('port_range_id', port_range_id)
1615
1616
        return cmd.to_string()
1617
1618
    def delete_report_command(self, report_id):
0 ignored issues
show
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...
1619
        """Generates xml string for delete report on gvmd"""
1620
        cmd = XmlCommand('delete_report')
1621
        cmd.set_attribute('report_id', report_id)
1622
1623
        return cmd.to_string()
1624
1625
    def delete_report_format_command(self, report_format_id, ultimate=0):
0 ignored issues
show
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...
1626
        """Generates xml string for delete report on gvmd"""
1627
        cmd = XmlCommand('delete_report_format')
1628
        cmd.set_attribute('report_format_id', report_format_id)
1629
        cmd.set_attribute('ultimate', ultimate)
1630
1631
        return cmd.to_string()
1632
1633
    def delete_role_command(self, role_id, ultimate=0):
0 ignored issues
show
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...
1634
        """Generates xml string for delete role on gvmd"""
1635
        cmd = XmlCommand('delete_role')
1636
        cmd.set_attribute('role_id', role_id)
1637
        cmd.set_attribute('ultimate', ultimate)
1638
1639
        return cmd.to_string()
1640
1641
    def delete_scanner_command(self, scanner_id, ultimate=0):
0 ignored issues
show
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...
1642
        """Generates xml string for delete scanner on gvmd"""
1643
        cmd = XmlCommand('delete_scanner')
1644
        cmd.set_attribute('scanner_id', scanner_id)
1645
        cmd.set_attribute('ultimate', ultimate)
1646
1647
        return cmd.to_string()
1648
1649
    def delete_schedule_command(self, schedule_id, ultimate=0):
0 ignored issues
show
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...
1650
        """Generates xml string for delete schedule on gvmd"""
1651
        # if self.ask_yes_or_no('Are you sure to delete this schedule? '):
1652
        cmd = XmlCommand('delete_schedule')
1653
        cmd.set_attribute('schedule_id', schedule_id)
1654
        cmd.set_attribute('ultimate', ultimate)
1655
1656
        return cmd.to_string()
1657
1658
    def delete_tag_command(self, tag_id, ultimate=0):
0 ignored issues
show
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...
1659
        """Generates xml string for delete tag on gvmd"""
1660
        cmd = XmlCommand('delete_tag')
1661
        cmd.set_attribute('tag_id', tag_id)
1662
        cmd.set_attribute('ultimate', ultimate)
1663
1664
        return cmd.to_string()
1665
1666
    def delete_target_command(self, target_id, ultimate=0):
0 ignored issues
show
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...
1667
        """Generates xml string for delete target on gvmd"""
1668
        cmd = XmlCommand('delete_target')
1669
        cmd.set_attribute('target_id', target_id)
1670
        cmd.set_attribute('ultimate', ultimate)
1671
1672
        return cmd.to_string()
1673
1674
    def delete_task_command(self, task_id, ultimate=0):
0 ignored issues
show
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...
1675
        """Generates xml string for delete task on gvmd"""
1676
        cmd = XmlCommand('delete_task')
1677
        cmd.set_attribute('task_id', task_id)
1678
        cmd.set_attribute('ultimate', ultimate)
1679
1680
        return cmd.to_string()
1681
1682
    def delete_user_command(self, kwargs):
0 ignored issues
show
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...
1683
        """Generates xml string for delete user on gvmd"""
1684
        cmd = XmlCommand('delete_user')
1685
1686
        user_id = kwargs.get('user_id', '')
1687
        if user_id:
1688
            cmd.set_attribute('user_id', user_id)
1689
1690
        name = kwargs.get('name', '')
1691
        if name:
1692
            cmd.set_attribute('name', name)
1693
1694
        inheritor_id = kwargs.get('inheritor_id', '')
1695
        if inheritor_id:
1696
            cmd.set_attribute('inheritor_id', inheritor_id)
1697
1698
        inheritor_name = kwargs.get('inheritor_name', '')
1699
        if inheritor_name:
1700
            cmd.set_attribute('inheritor_name', inheritor_name)
1701
1702
        return cmd.to_string()
1703
1704
    def describe_auth_command(self):
0 ignored issues
show
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...
1705
        """Generates xml string for describe auth on gvmd"""
1706
        cmd = XmlCommand('describe_auth')
1707
        return cmd.to_string()
1708
1709
    def empty_trashcan_command(self):
0 ignored issues
show
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...
1710
        """Generates xml string for empty trashcan on gvmd"""
1711
        cmd = XmlCommand('empty_trashcan')
1712
        return cmd.to_string()
1713
1714
    def get_agents_command(self, kwargs):
0 ignored issues
show
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...
1715
        """Generates xml string for get agents on gvmd."""
1716
        cmd = XmlCommand('get_agents')
1717
        cmd.set_attributes(kwargs)
1718
        return cmd.to_string()
1719
1720
    def get_aggregates_command(self, kwargs):
0 ignored issues
show
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...
1721
        """Generates xml string for get aggregates on gvmd."""
1722
        cmd = XmlCommand('get_aggregates')
1723
        cmd.set_attributes(kwargs)
1724
        return cmd.to_string()
1725
1726
    def get_alerts_command(self, kwargs):
0 ignored issues
show
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...
1727
        """Generates xml string for get alerts on gvmd."""
1728
        cmd = XmlCommand('get_alerts')
1729
        cmd.set_attributes(kwargs)
1730
        return cmd.to_string()
1731
1732
    def get_assets_command(self, kwargs):
0 ignored issues
show
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...
1733
        """Generates xml string for get assets on gvmd."""
1734
        cmd = XmlCommand('get_assets')
1735
        cmd.set_attributes(kwargs)
1736
        return cmd.to_string()
1737
1738
    def get_credentials_command(self, kwargs):
0 ignored issues
show
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...
1739
        """Generates xml string for get credentials on gvmd."""
1740
        cmd = XmlCommand('get_credentials')
1741
        cmd.set_attributes(kwargs)
1742
        return cmd.to_string()
1743
1744
    def get_configs_command(self, kwargs):
0 ignored issues
show
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...
1745
        """Generates xml string for get configs on gvmd."""
1746
        cmd = XmlCommand('get_configs')
1747
        cmd.set_attributes(kwargs)
1748
        return cmd.to_string()
1749
1750
    def get_feeds_command(self, kwargs):
0 ignored issues
show
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...
1751
        """Generates xml string for get feeds on gvmd."""
1752
        cmd = XmlCommand('get_feeds')
1753
        cmd.set_attributes(kwargs)
1754
        return cmd.to_string()
1755
1756
    def get_filters_command(self, kwargs):
0 ignored issues
show
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...
1757
        """Generates xml string for get filters on gvmd."""
1758
        cmd = XmlCommand('get_filters')
1759
        cmd.set_attributes(kwargs)
1760
        return cmd.to_string()
1761
1762
    def get_groups_command(self, kwargs):
0 ignored issues
show
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...
1763
        """Generates xml string for get groups on gvmd."""
1764
        cmd = XmlCommand('get_groups')
1765
        cmd.set_attributes(kwargs)
1766
        return cmd.to_string()
1767
1768
    def get_info_command(self, kwargs):
0 ignored issues
show
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...
1769
        """Generates xml string for get info on gvmd."""
1770
        cmd = XmlCommand('get_info')
1771
        cmd.set_attributes(kwargs)
1772
        return cmd.to_string()
1773
1774
    def get_notes_command(self, kwargs):
0 ignored issues
show
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...
1775
        """Generates xml string for get notes on gvmd."""
1776
        cmd = XmlCommand('get_notes')
1777
        cmd.set_attributes(kwargs)
1778
        return cmd.to_string()
1779
1780
    def get_nvts_command(self, kwargs):
0 ignored issues
show
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...
1781
        """Generates xml string for get nvts on gvmd."""
1782
        cmd = XmlCommand('get_nvts')
1783
        cmd.set_attributes(kwargs)
1784
        return cmd.to_string()
1785
1786
    def get_nvt_families_command(self, kwargs):
0 ignored issues
show
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...
1787
        """Generates xml string for get nvt on gvmd."""
1788
        cmd = XmlCommand('get_nvt_families')
1789
        cmd.set_attributes(kwargs)
1790
        return cmd.to_string()
1791
1792
    def get_overrides_command(self, kwargs):
0 ignored issues
show
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...
1793
        """Generates xml string for get overrides on gvmd."""
1794
        cmd = XmlCommand('get_overrides')
1795
        cmd.set_attributes(kwargs)
1796
        return cmd.to_string()
1797
1798
    def get_permissions_command(self, kwargs):
0 ignored issues
show
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...
1799
        """Generates xml string for get permissions on gvmd."""
1800
        cmd = XmlCommand('get_permissions')
1801
        cmd.set_attributes(kwargs)
1802
        return cmd.to_string()
1803
1804
    def get_port_lists_command(self, kwargs):
0 ignored issues
show
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...
1805
        """Generates xml string for get port on gvmd."""
1806
        cmd = XmlCommand('get_port_lists')
1807
        cmd.set_attributes(kwargs)
1808
        return cmd.to_string()
1809
1810
    def get_preferences_command(self, kwargs):
0 ignored issues
show
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...
1811
        """Generates xml string for get preferences on gvmd."""
1812
        cmd = XmlCommand('get_preferences')
1813
        cmd.set_attributes(kwargs)
1814
        return cmd.to_string()
1815
1816
    def get_reports_command(self, kwargs):
0 ignored issues
show
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...
1817
        """Generates xml string for get reports on gvmd."""
1818
        cmd = XmlCommand('get_reports')
1819
        cmd.set_attributes(kwargs)
1820
        return cmd.to_string()
1821
1822
    def get_report_formats_command(self, kwargs):
0 ignored issues
show
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...
1823
        """Generates xml string for get report on gvmd."""
1824
        cmd = XmlCommand('get_report_formats')
1825
        cmd.set_attributes(kwargs)
1826
        return cmd.to_string()
1827
1828
    def get_results_command(self, kwargs):
0 ignored issues
show
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...
1829
        """Generates xml string for get results on gvmd."""
1830
        cmd = XmlCommand('get_results')
1831
        cmd.set_attributes(kwargs)
1832
        return cmd.to_string()
1833
1834
    def get_roles_command(self, kwargs):
0 ignored issues
show
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...
1835
        """Generates xml string for get roles on gvmd."""
1836
        cmd = XmlCommand('get_roles')
1837
        cmd.set_attributes(kwargs)
1838
        return cmd.to_string()
1839
1840
    def get_scanners_command(self, kwargs):
0 ignored issues
show
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...
1841
        """Generates xml string for get scanners on gvmd."""
1842
        cmd = XmlCommand('get_scanners')
1843
        cmd.set_attributes(kwargs)
1844
        return cmd.to_string()
1845
1846
    def get_schedules_command(self, kwargs):
0 ignored issues
show
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...
1847
        """Generates xml string for get schedules on gvmd."""
1848
        cmd = XmlCommand('get_schedules')
1849
        cmd.set_attributes(kwargs)
1850
        return cmd.to_string()
1851
1852
    def get_settings_command(self, kwargs):
0 ignored issues
show
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...
1853
        """Generates xml string for get settings on gvmd."""
1854
        cmd = XmlCommand('get_settings')
1855
        cmd.set_attributes(kwargs)
1856
        return cmd.to_string()
1857
1858
    def get_system_reports_command(self, kwargs):
0 ignored issues
show
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...
1859
        """Generates xml string for get system on gvmd."""
1860
        cmd = XmlCommand('get_system')
1861
        cmd.set_attributes(kwargs)
1862
        return cmd.to_string()
1863
1864
    def get_tags_command(self, kwargs):
0 ignored issues
show
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...
1865
        """Generates xml string for get tags on gvmd."""
1866
        cmd = XmlCommand('get_tags')
1867
        cmd.set_attributes(kwargs)
1868
        return cmd.to_string()
1869
1870
    def get_targets_command(self, kwargs):
0 ignored issues
show
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...
1871
        """Generates xml string for get targets on gvmd."""
1872
        cmd = XmlCommand('get_targets')
1873
        cmd.set_attributes(kwargs)
1874
        return cmd.to_string()
1875
1876
    def get_tasks_command(self, kwargs):
0 ignored issues
show
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...
1877
        """Generates xml string for get tasks on gvmd."""
1878
        cmd = XmlCommand('get_tasks')
1879
        cmd.set_attributes(kwargs)
1880
        return cmd.to_string()
1881
1882
    def get_users_command(self, kwargs):
0 ignored issues
show
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...
1883
        """Generates xml string for get users on gvmd."""
1884
        cmd = XmlCommand('get_users')
1885
        cmd.set_attributes(kwargs)
1886
        return cmd.to_string()
1887
1888
    def get_version_command(self):
0 ignored issues
show
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...
1889
        """Generates xml string for get version on gvmd."""
1890
        cmd = XmlCommand('get_version')
1891
        return cmd.to_string()
1892
1893
    def help_command(self, kwargs):
0 ignored issues
show
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...
1894
        """Generates xml string for help on gvmd."""
1895
        cmd = XmlCommand('help')
1896
        cmd.set_attributes(kwargs)
1897
        return cmd.to_string()
1898