Passed
Pull Request — master (#121)
by Juan José
01:35
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 (1892/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_from_args(self, kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

Loading history...
61
        for key, value in kwargs.items():
62
            self._element.set(key, value)
63
64
    def append_xml_str(self, xml_text):
65
        """Append a xml element in string format."""
66
        node = secET.fromstring(xml_text)
67
        self._element.append(node)
68
69
    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...
70
        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...
71
72
    def __str__(self):
73
        return self.to_string()
74
75
76
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...
77
78
    def __init__(self, name):
79
        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...
80
81
82
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...
83
84
    """Factory to create gmp - Greenbone Manangement Protocol - commands
85
    """
86
87
    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...
88
                             copy='', howto_install='', howto_use=''):
89
90
        cmd = XmlCommand('create_agent')
91
        cmd.add_element('installer', installer)
92
        cmd.add_element('signature', signature)
93
        cmd.add_element('name', name)
94
95
        if comment:
96
            cmd.add_element('comment', comment)
97
98
        if copy:
99
            cmd.add_element('copy', copy)
100
101
        if howto_install:
102
            cmd.add_element('howto_install', howto_install)
103
104
        if howto_use:
105
            cmd.add_element('howto_use', howto_use)
106
107
        return cmd.to_string()
108
109
    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...
110
                             copy='', comment=''):
111
112
        cmd = XmlCommand('create_alert')
113
        cmd.add_element('name', name)
114
115
        if len(condition) > 1:
116
            conditions = cmd.add_element('condition', condition[0])
117
            for value, key in condition[1].items():
118
                _data = conditions.add_element('data', value)
119
                _data.add_element('name', key)
120
121
        elif condition[0] == "Always":
122
            conditions = cmd.add_element('condition', condition[0])
123
124
        if len(event) > 1:
125
            events = cmd.add_element('event', event[0])
126
            for value, key in event[1].items():
127
                _data = events.add_element('data', value)
128
                _data.add_element('name', key)
129
130
        if len(method) > 1:
131
            methods = cmd.add_element('method', method[0])
132
            for value, key in method[1].items():
133
                _data = methods.add_element('data', value)
134
                _data.add_element('name', key)
135
136
        if filter_id:
137
            cmd.add_element('filter', attrs={'id': filter_id})
138
139
        if copy:
140
            cmd.add_element('copy', copy)
141
142
        if comment:
143
            cmd.add_element('comment', comment)
144
145
        return cmd.to_string()
146
147
    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...
148
        if asset_type not in ('host', 'os'):
149
            raise ValueError('create_asset requires asset_type to be either '
150
                             'host or os')
151
        cmd = XmlCommand('create_asset')
152
        asset = cmd.add_element('asset')
153
        asset.add_element('type', asset_type)
154
        asset.add_element('name', name)
155
156
        if comment:
157
            asset.add_element('comment', comment)
158
159
        return cmd.to_string()
160
161
    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...
162
        """Generates string for authentification on gvmd
163
164
        Creates the gmp authentication xml string.
165
        Inserts the username and password into it.
166
167
        Keyword Arguments:
168
            username {str} -- Username for GVM User
169
            password {str} -- Password for GVM User
170
        """
171
        cmd = XmlCommand('authenticate')
172
173
        credentials = cmd.add_element('credentials')
174
        credentials.add_element('username', username)
175
        credentials.add_element('password', password)
176
177
        return cmd.to_string()
178
179
    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...
180
        """Generates xml string for create config on gvmd."""
181
        cmd = XmlCommand('create_config')
182
        cmd.add_element('copy', copy_id)
183
        cmd.add_element('name', name)
184
185
        return cmd.to_string()
186
187 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...
188
        """Generates xml string for create credential on gvmd."""
189
        cmd = XmlCommand('create_credential')
190
        cmd.add_element('name', name)
191
192
        comment = kwargs.get('comment', '')
193
        if comment:
194
            cmd.add_element('comment', comment)
195
196
        copy = kwargs.get('copy', '')
197
        if copy:
198
            cmd.add_element('copy', copy)
199
200
        allow_insecure = kwargs.get('allow_insecure', '')
201
        if allow_insecure:
202
            cmd.add_element('allow_insecure', allow_insecure)
203
204
        certificate = kwargs.get('certificate', '')
205
        if certificate:
206
            cmd.add_element('certificate', certificate)
207
208
        key = kwargs.get('key', '')
209
        if key:
210
            phrase = key['phrase']
211
            private = key['private']
212
            if not phrase:
213
                raise ValueError('create_credential requires a phrase element')
214
            if not private:
215
                raise ValueError('create_credential requires a '
216
                                 'private element')
217
218
            _xmlkey = cmd.add_element('key')
219
            _xmlkey.add_element('phrase', phrase)
220
            _xmlkey.add_element('private', private)
221
222
        login = kwargs.get('login', '')
223
        if login:
224
            cmd.add_element('login', login)
225
226
        password = kwargs.get('password', '')
227
        if password:
228
            cmd.add_element('password', password)
229
230
        auth_algorithm = kwargs.get('auth_algorithm', '')
231
        if auth_algorithm:
232
            if auth_algorithm not in ('md5', 'sha1'):
233
                raise ValueError('create_credential requires auth_algorithm '
234
                                 'to be either md5 or sha1')
235
            cmd.add_element('auth_algorithm', auth_algorithm)
236
237
        community = kwargs.get('community', '')
238
        if community:
239
            cmd.add_element('community', community)
240
241
        privacy = kwargs.get('privacy', '')
242
        if privacy:
243
            algorithm = privacy.algorithm
244
            if algorithm not in ('aes', 'des'):
245
                raise ValueError('create_credential requires algorithm '
246
                                 'to be either aes or des')
247
            p_password = privacy.password
248
            _xmlprivacy = cmd.add_element('privacy')
249
            _xmlprivacy.add_element('algorithm', algorithm)
250
            _xmlprivacy.add_element('password', p_password)
251
252
        cred_type = kwargs.get('type', '')
253
        if cred_type:
254
            if cred_type not in ('cc', 'snmp', 'up', 'usk'):
255
                raise ValueError('create_credential requires type '
256
                                 'to be either cc, snmp, up or usk')
257
            cmd.add_element('type', cred_type)
258
259
        return cmd.to_string()
260
261
    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...
262
        """Generates xml string for create filter on gvmd."""
263
264
        cmd = XmlCommand('create_filter')
265
        _xmlname = cmd.add_element('name', name)
266
        if make_unique:
267
            _xmlname.add_element('make_unique', '1')
268
        else:
269
            _xmlname.add_element('make_unique', '0')
270
271
        comment = kwargs.get('comment', '')
272
        if comment:
273
            cmd.add_element('comment', comment)
274
275
        copy = kwargs.get('copy', '')
276
        if copy:
277
            cmd.add_element('copy', copy)
278
279
        term = kwargs.get('term', '')
280
        if term:
281
            cmd.add_element('term', term)
282
283
        filter_type = kwargs.get('type', '')
284
        if filter_type:
285
            if filter_type not in FILTER_NAMES:
286
                raise ValueError('create_filter requires type '
287
                                 'to be either cc, snmp, up or usk')
288
            cmd.add_element('type', filter_type)
289
290
        return cmd.to_string()
291
292
    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...
293
        """Generates xml string for create group on gvmd."""
294
295
        cmd = XmlCommand('create_group')
296
        cmd.add_element('name', name)
297
298
        comment = kwargs.get('comment', '')
299
        if comment:
300
            cmd.add_element('comment', comment)
301
302
        copy = kwargs.get('copy', '')
303
        if copy:
304
            cmd.add_element('copy', copy)
305
306
        special = kwargs.get('special', '')
307
        if special:
308
            _xmlspecial = cmd.add_element('specials')
309
            _xmlspecial.add_element('full')
310
311
        users = kwargs.get('users', '')
312
        if users:
313
            cmd.add_element('users', users)
314
315
        return cmd.to_string()
316
317
    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...
318
        """Generates xml string for create note on gvmd."""
319
320
        cmd = XmlCommand('create_note')
321
        cmd.add_element('text', text)
322
        cmd.add_element('nvt', attrs={"oid": nvt_oid})
323
324
        active = kwargs.get('active', '')
325
        if active:
326
            cmd.add_element('active', active)
327
328
        comment = kwargs.get('comment', '')
329
        if comment:
330
            cmd.add_element('comment', comment)
331
332
        copy = kwargs.get('copy', '')
333
        if copy:
334
            cmd.add_element('copy', copy)
335
336
        hosts = kwargs.get('hosts', '')
337
        if hosts:
338
            cmd.add_element('hosts', hosts)
339
340
        port = kwargs.get('port', '')
341
        if port:
342
            cmd.add_element('port', port)
343
344
        result_id = kwargs.get('result_id', '')
345
        if result_id:
346
            cmd.add_element('result', attrs={'id': result_id})
347
348
        severity = kwargs.get('severity', '')
349
        if severity:
350
            cmd.add_element('severity', severity)
351
352
        task_id = kwargs.get('task_id', '')
353
        if task_id:
354
            cmd.add_element('task', attrs={'id': task_id})
355
356
        threat = kwargs.get('threat', '')
357
        if threat:
358
            cmd.add_element('threat', threat)
359
360
        return cmd.to_string()
361
362
    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...
363
        """Generates xml string for create override on gvmd."""
364
365
        cmd = XmlCommand('create_override')
366
        cmd.add_element('text', text)
367
        cmd.add_element('nvt', attrs={'oid': nvt_oid})
368
369
        active = kwargs.get('active', '')
370
        if active:
371
            cmd.add_element('active', active)
372
373
        comment = kwargs.get('comment', '')
374
        if comment:
375
            cmd.add_element('comment', comment)
376
377
        copy = kwargs.get('copy', '')
378
        if copy:
379
            cmd.add_element('copy', copy)
380
381
        hosts = kwargs.get('hosts', '')
382
        if hosts:
383
            cmd.add_element('hosts', hosts)
384
385
        port = kwargs.get('port', '')
386
        if port:
387
            cmd.add_element('port', port)
388
389
        result_id = kwargs.get('result_id', '')
390
        if result_id:
391
            cmd.add_element('result', attrs={'id': result_id})
392
393
        severity = kwargs.get('severity', '')
394
        if severity:
395
            cmd.add_element('severity', severity)
396
397
        new_severity = kwargs.get('new_severity', '')
398
        if new_severity:
399
            cmd.add_element('new_severity', new_severity)
400
401
        task_id = kwargs.get('task_id', '')
402
        if task_id:
403
            cmd.add_element('task', attrs={'id': task_id})
404
405
        threat = kwargs.get('threat', '')
406
        if threat:
407
            cmd.add_element('threat', threat)
408
409
        new_threat = kwargs.get('new_threat', '')
410
        if new_threat:
411
            cmd.add_element('new_threat', new_threat)
412
413
        return cmd.to_string()
414
415
    def create_permission_command(self, name, subject_id, type, kwargs):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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

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

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

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

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

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