Completed
Push — master ( 60e59c...00b80e )
by
unknown
16s queued 13s
created

_GmpCommandFactory.modify_permission_command()   B

Complexity

Conditions 6

Size

Total Lines 33
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 25
nop 3
dl 0
loc 33
rs 8.3466
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
coding-style introduced by
Too many lines in module (1270/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
class XmlCommandElement:
24
25
    def __init__(self, element):
26
        self._element = element
27
28
    def add_element(self, name, text=None, attrs=None):
29
        node = etree.SubElement(self._element, name, attrib=attrs)
30
        node.text = text
31
        return XmlCommandElement(node)
32
33
    def set_attribute(self, name, value):
34
        self._element.set(name, value)
35
36
    def set_attributes(self, attrs):
37
        """Set several attributes at once.
38
39
        Arguments:
40
            attrs (dict): Attributes to be set on the element
41
        """
42
        for key, value in attrs.items():
43
            self._element.set(key, value)
44
45
    def append_xml_str(self, xml_text):
46
        """Append a xml element in string format."""
47
        node = secET.fromstring(xml_text)
48
        self._element.append(node)
49
50
    def to_string(self):
51
        return etree.tostring(self._element).decode('utf-8')
52
53
    def __str__(self):
54
        return self.to_string()
55
56
57
class XmlCommand(XmlCommandElement):
58
59
    def __init__(self, name):
60
        super().__init__(etree.Element(name))
61
62
63
class _GmpCommandFactory:
0 ignored issues
show
best-practice introduced by
Too many public methods (89/30)
Loading history...
64
65
    """Factory to create gmp - Greenbone Management Protocol - commands
66
    """
67
68
    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...
69
        """Generates xml string for modify agent on gvmd."""
70
        if not agent_id:
71
            raise ValueError('modify_agent requires an agent_id element')
72
73
        cmd = XmlCommand('modify_agent')
74
        cmd.set_attribute('agent_id', str(agent_id))
75
        if name:
76
            cmd.add_element('name', name)
77
        if comment:
78
            cmd.add_element('comment', comment)
79
80
        return cmd.to_string()
81
82
    def modify_alert_command(self, alert_id, kwargs):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (17/15).
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

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

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

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
83
        """Generates xml string for modify alert on gvmd."""
84
85
        if not alert_id:
86
            raise ValueError('modify_alert requires an agent_id element')
87
88
        cmd = XmlCommand('modify_alert')
89
        cmd.set_attribute('alert_id', str(alert_id))
90
91
        name = kwargs.get('name', '')
92
        if name:
93
            cmd.add_element('name', name)
94
95
        comment = kwargs.get('comment', '')
96
        if comment:
97
            cmd.add_element('comment', comment)
98
99
        filter_id = kwargs.get('filter_id', '')
100
        if filter_id:
101
            cmd.add_element('filter', attrs={'id': filter_id})
102
103
        event = kwargs.get('event', '')
104
        if len(event) > 1:
105
            _xmlevent = cmd.add_element('event', event[0])
106
            for value, key in event[1].items():
107
                _xmldata = _xmlevent.add_element('data', value)
108
                _xmldata.add_element('name', key)
109
110
        condition = kwargs.get('condition', '')
111
        if len(condition) > 1:
112
            _xmlcond = cmd.add_element('condition', condition[0])
113
            for value, key in condition[1].items():
114
                _xmldata = _xmlcond.add_element('data', value)
115
                _xmldata.add_element('name', key)
116
117
        method = kwargs.get('method', '')
118
        if len(method) > 1:
119
            _xmlmethod = cmd.add_element('method', method[0])
120
            for value, key in method[1].items():
121
                _xmldata = _xmlmethod.add_element('data', value)
122
                _xmldata.add_element('name', key)
123
124
        return cmd.to_string()
125
126
    def modify_asset_command(self, asset_id, 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...
127
        """Generates xml string for modify asset on gvmd."""
128
        cmd = XmlCommand('modify_asset')
129
        cmd.set_attribute('asset_id', asset_id)
130
        cmd.add_element('comment', comment)
131
        return cmd.to_string()
132
133
    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...
134
        """Generates xml string for modify auth on gvmd."""
135
        if not group_name:
136
            raise ValueError('modify_auth requires a group element '
137
                             'with a name attribute')
138
        if not auth_conf_settings:
139
            raise ValueError('modify_auth requires '
140
                             'an auth_conf_settings element')
141
        cmd = XmlCommand('modify_auth')
142
        _xmlgroup = cmd.add_element('group', attrs={'name': str(group_name)})
143
144
        for key, value in auth_conf_settings.items():
145
            _xmlauthconf = _xmlgroup.add_element('auth_conf_setting')
146
            _xmlauthconf.add_element('key', key)
147
            _xmlauthconf.add_element('value', value)
148
149
        return cmd.to_string()
150
151
    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...
152
        """Generates xml string for modify config on gvmd."""
153
        if selection not in ('nvt_pref', 'sca_pref',
154
                             'family_selection', 'nvt_selection'):
155
            raise ValueError('selection must be one of nvt_pref, sca_pref, '
156
                             'family_selection or nvt_selection')
157
        config_id = kwargs.get('config_id')
158
159
        cmd = XmlCommand('modify_config')
160
        cmd.set_attribute('config_id', str(config_id))
161
162
        if selection in 'nvt_pref':
163
            nvt_oid = kwargs.get('nvt_oid')
164
            name = kwargs.get('name')
165
            value = kwargs.get('value')
166
            _xmlpref = cmd.add_element('preference')
167
            _xmlpref.add_element('nvt', attrs={'oid': nvt_oid})
168
            _xmlpref.add_element('name', name)
169
            _xmlpref.add_element('value', value)
170
171
        elif selection in 'nvt_selection':
172
            nvt_oid = kwargs.get('nvt_oid')
173
            family = kwargs.get('family')
174
            _xmlnvtsel = cmd.add_element('nvt_selection')
175
            _xmlnvtsel.add_element('family', family)
176
177
            if isinstance(nvt_oid, list):
178
                for nvt in nvt_oid:
179
                    _xmlnvtsel.add_element('nvt', attrs={'oid': nvt})
180
            else:
181
                _xmlnvtsel.add_element('nvt', attrs={'oid': nvt_oid})
182
183
        elif selection in 'family_selection':
184
            family = kwargs.get('family')
185
            _xmlfamsel = cmd.add_element('family_selection')
186
            _xmlfamsel.add_element('growing', '1')
187
            _xmlfamily = _xmlfamsel.add_element('family')
188
            _xmlfamily.add_element('name', family)
189
            _xmlfamily.add_element('all', '1')
190
            _xmlfamily.add_element('growing', '1')
191
        else:
192
            raise NotImplementedError
193
194
        return cmd.to_string()
195
196
    def modify_credential_command(self, credential_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...
197
        """Generates xml string for modify credential on gvmd."""
198
        if not credential_id:
199
            raise ValueError('modify_credential requires '
200
                             'a credential_id attribute')
201
202
        cmd = XmlCommand('modify_credential')
203
        cmd.set_attribute('credential_id', credential_id)
204
205
        comment = kwargs.get('comment', '')
206
        if comment:
207
            cmd.add_element('comment', comment)
208
209
        name = kwargs.get('name', '')
210
        if name:
211
            cmd.add_element('name', name)
212
213
        allow_insecure = kwargs.get('allow_insecure', '')
214
        if allow_insecure:
215
            cmd.add_element('allow_insecure', allow_insecure)
216
217
        certificate = kwargs.get('certificate', '')
218
        if certificate:
219
            cmd.add_element('certificate', certificate)
220
221
        key = kwargs.get('key', '')
222
        if key:
223
            phrase = key['phrase']
224
            private = key['private']
225
            if not phrase:
226
                raise ValueError('modify_credential requires a phrase element')
227
            if not private:
228
                raise ValueError('modify_credential requires '
229
                                 'a private element')
230
            _xmlkey = cmd.add_element('key')
231
            _xmlkey.add_element('phrase', phrase)
232
            _xmlkey.add_element('private', private)
233
234
        login = kwargs.get('login', '')
235
        if login:
236
            cmd.add_element('login', login)
237
238
        password = kwargs.get('password', '')
239
        if password:
240
            cmd.add_element('password', password)
241
242
        auth_algorithm = kwargs.get('auth_algorithm', '')
243
        if auth_algorithm:
244
            if auth_algorithm not in ('md5', 'sha1'):
245
                raise ValueError('modify_credential requires auth_algorithm '
246
                                 'to be either md5 or sha1')
247
            cmd.add_element('auth_algorithm', auth_algorithm)
248
249
        community = kwargs.get('community', '')
250
        if community:
251
            cmd.add_element('community', community)
252
253
        privacy = kwargs.get('privacy', '')
254
        if privacy:
255
            algorithm = privacy.algorithm
256
            if algorithm not in ('aes', 'des'):
257
                raise ValueError('modify_credential requires algorithm '
258
                                 'to be either aes or des')
259
            p_password = privacy.password
260
            _xmlprivacy = cmd.add_element('privacy')
261
            _xmlprivacy.add_element('algorithm', algorithm)
262
            _xmlprivacy.add_element('password', p_password)
263
264
        cred_type = kwargs.get('type', '')
265
        if cred_type:
266
            if cred_type not in ('cc', 'snmp', 'up', 'usk'):
267
                raise ValueError('modify_credential requires type '
268
                                 'to be either cc, snmp, up or usk')
269
            cmd.add_element('type', cred_type)
270
271
        return cmd.to_string()
272
273
    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...
274
        """Generates xml string for modify filter on gvmd."""
275
        if not filter_id:
276
            raise ValueError('modify_filter requires a filter_id attribute')
277
278
        cmd = XmlCommand('modify_filter')
279
        cmd.set_attribute('filter_id', filter_id)
280
281
        comment = kwargs.get('comment', '')
282
        if comment:
283
            cmd.add_element('comment', comment)
284
285
        name = kwargs.get('name', '')
286
        if name:
287
            cmd.add_element('name', name)
288
289
        copy = kwargs.get('copy', '')
290
        if copy:
291
            cmd.add_element('copy', copy)
292
293
        term = kwargs.get('term', '')
294
        if term:
295
            cmd.add_element('term', term)
296
297
        filter_type = kwargs.get('type', '')
298
        if filter_type:
299
            if filter_type not in ('cc', 'snmp', 'up', 'usk'):
300
                raise ValueError('modify_filter requires type '
301
                                 'to be either cc, snmp, up or usk')
302
            cmd.add_element('type', filter_type)
303
304
        return cmd.to_string()
305
306 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...
307
        """Generates xml string for modify group on gvmd."""
308
        if not group_id:
309
            raise ValueError('modify_group requires a group_id attribute')
310
311
        cmd = XmlCommand('modify_group')
312
        cmd.set_attribute('group_id', group_id)
313
314
        comment = kwargs.get('comment', '')
315
        if comment:
316
            cmd.add_element('comment', comment)
317
318
        name = kwargs.get('name', '')
319
        if name:
320
            cmd.add_element('name', name)
321
322
        users = kwargs.get('users', '')
323
        if users:
324
            cmd.add_element('users', users)
325
326
        return cmd.to_string()
327
328
    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...
329
        """Generates xml string for modify note on gvmd."""
330
        if not note_id:
331
            raise ValueError('modify_note requires a note_id attribute')
332
        if not text:
333
            raise ValueError('modify_note requires a text element')
334
335
        cmd = XmlCommand('modify_note')
336
        cmd.set_attribute('note_id', note_id)
337
        cmd.add_element('text', text)
338
339
        active = kwargs.get('active', '')
340
        if active:
341
            cmd.add_element('active', active)
342
343
        hosts = kwargs.get('hosts', '')
344
        if hosts:
345
            cmd.add_element('hosts', hosts)
346
347
        port = kwargs.get('port', '')
348
        if port:
349
            cmd.add_element('port', port)
350
351
        result_id = kwargs.get('result_id', '')
352
        if result_id:
353
            cmd.add_element('result', attrs={'id': result_id})
354
355
        severity = kwargs.get('severity', '')
356
        if severity:
357
            cmd.add_element('severity', severity)
358
359
        task_id = kwargs.get('task_id', '')
360
        if task_id:
361
            cmd.add_element('task', attrs={'id': task_id})
362
363
        threat = kwargs.get('threat', '')
364
        if threat:
365
            cmd.add_element('threat', threat)
366
367
        return cmd.to_string()
368
369
    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...
370
        """Generates xml string for modify override on gvmd."""
371
        cmd = XmlCommand('modify_override')
372
        cmd.set_attribute('override_id', override_id)
373
        cmd.add_element('text', text)
374
375
        active = kwargs.get('active', '')
376
        if active:
377
            cmd.add_element('active', active)
378
379
        hosts = kwargs.get('hosts', '')
380
        if hosts:
381
            cmd.add_element('hosts', hosts)
382
383
        port = kwargs.get('port', '')
384
        if port:
385
            cmd.add_element('port', port)
386
387
        result_id = kwargs.get('result_id', '')
388
        if result_id:
389
            cmd.add_element('result', attrs={'id': result_id})
390
391
        severity = kwargs.get('severity', '')
392
        if severity:
393
            cmd.add_element('severity', severity)
394
395
        new_severity = kwargs.get('new_severity', '')
396
        if new_severity:
397
            cmd.add_element('new_severity', new_severity)
398
399
        task_id = kwargs.get('task_id', '')
400
        if task_id:
401
            cmd.add_element('task', attrs={'id': task_id})
402
403
        threat = kwargs.get('threat', '')
404
        if threat:
405
            cmd.add_element('threat', threat)
406
407
        new_threat = kwargs.get('new_threat', '')
408
        if new_threat:
409
            cmd.add_element('new_threat', new_threat)
410
411
        return cmd.to_string()
412
413
    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...
414
        """Generates xml string for modify permission on gvmd."""
415
        if not permission_id:
416
            raise ValueError('modify_permission requires '
417
                             'a permission_id element')
418
419
        cmd = XmlCommand('modify_permission')
420
        cmd.set_attribute('permission_id', permission_id)
421
422
        comment = kwargs.get('comment', '')
423
        if comment:
424
            cmd.add_element('comment', comment)
425
426
        name = kwargs.get('name', '')
427
        if name:
428
            cmd.add_element('name', name)
429
430
        resource = kwargs.get('resource', '')
431
        if resource:
432
            resource_id = resource['id']
433
            resource_type = resource['type']
434
            _xmlresource = cmd.add_element('resource',
435
                                           attrs={'id': resource_id})
436
            _xmlresource.add_element('type', resource_type)
437
438
        subject = kwargs.get('subject', '')
439
        if subject:
440
            subject_id = subject['id']
441
            subject_type = subject['type']
442
            _xmlsubject = cmd.add_element('subject', attrs={'id': subject_id})
443
            _xmlsubject.add_element('type', subject_type)
444
445
        return cmd.to_string()
446
447
    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...
448
        """Generates xml string for modify port list on gvmd."""
449
        if not port_list_id:
450
            raise ValueError('modify_port_list requires '
451
                             'a port_list_id attribute')
452
        cmd = XmlCommand('modify_port_list')
453
        cmd.set_attribute('port_list_id', port_list_id)
454
455
        comment = kwargs.get('comment', '')
456
        if comment:
457
            cmd.add_element('comment', comment)
458
459
        name = kwargs.get('name', '')
460
        if name:
461
            cmd.add_element('name', name)
462
463
        return cmd.to_string()
464
465
    def modify_report_command(self, report_id, 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...
466
        """Generates xml string for modify report on gvmd."""
467
        cmd = XmlCommand('modify_report')
468
        cmd.set_attribute('report_id', report_id)
469
        cmd.add_element('comment', comment)
470
        return cmd.to_string()
471
472
    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...
473
        """Generates xml string for modify report format on gvmd."""
474
        if len(kwargs) < 1:
475
            raise Exception('modify_report_format: Missing parameter')
476
477
        cmd = XmlCommand('modify_report_format')
478
        cmd.set_attribute('report_format_id', report_format_id)
479
480
        active = kwargs.get('active', '')
481
        if active:
482
            cmd.add_element('active', active)
483
484
        name = kwargs.get('name', '')
485
        if name:
486
            cmd.add_element('name', name)
487
488
        summary = kwargs.get('summary', '')
489
        if summary:
490
            cmd.add_element('summary', summary)
491
492
        param = kwargs.get('param', '')
493
        if param:
494
            p_name = param[0]
495
            p_value = param[1]
496
            _xmlparam = cmd.add_element('param')
497
            _xmlparam.add_element('name', p_name)
498
            _xmlparam.add_element('value', p_value)
499
500
        return cmd.to_string()
501
502 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...
503
        """Generates xml string for modify role on gvmd."""
504
        if not role_id:
505
            raise ValueError('modify_role requires a role_id element')
506
507
        cmd = XmlCommand('modify_role')
508
        cmd.set_attribute('role_id', role_id)
509
510
        comment = kwargs.get('comment', '')
511
        if comment:
512
            cmd.add_element('comment', comment)
513
514
        name = kwargs.get('name', '')
515
        if name:
516
            cmd.add_element('name', name)
517
518
        users = kwargs.get('users', '')
519
        if users:
520
            cmd.add_element('users', users)
521
522
        return cmd.to_string()
523
524
    def modify_scanner_command(self, scanner_id, host, port, scanner_type,
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...
525
                               kwargs):
526
        """Generates xml string for modify scanner on gvmd."""
527
        if not scanner_id:
528
            raise ValueError('modify_scanner requires a scanner_id element')
529
        if not host:
530
            raise ValueError('modify_scanner requires a host element')
531
        if not port:
532
            raise ValueError('modify_scanner requires a port element')
533
        if not scanner_type:
534
            raise ValueError('modify_scanner requires a type element')
535
536
        cmd = XmlCommand('modify_scanner')
537
        cmd.set_attribute('scanner_id', scanner_id)
538
        cmd.add_element('host', host)
539
        cmd.add_element('port', port)
540
        cmd.add_element('type', scanner_type)
541
542
        comment = kwargs.get('comment', '')
543
        if comment:
544
            cmd.add_element('comment', comment)
545
546
        name = kwargs.get('name', '')
547
        if name:
548
            cmd.add_element('name', name)
549
550
        ca_pub = kwargs.get('ca_pub', '')
551
        if ca_pub:
552
            cmd.add_element('ca_pub', ca_pub)
553
554
        credential_id = kwargs.get('credential_id', '')
555
        if credential_id:
556
            cmd.add_element('credential', attrs={'id': str(credential_id)})
557
558
        return cmd.to_string()
559
560
    def modify_schedule_command(self, schedule_id, kwargs):
0 ignored issues
show
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...
561
        """Generates xml string for modify schedule on gvmd."""
562
        if not schedule_id:
563
            raise ValueError('modify_schedule requires a schedule_id element')
564
565
        cmd = XmlCommand('modify_schedule')
566
        cmd.set_attribute('schedule_id', schedule_id)
567
        comment = kwargs.get('comment', '')
568
        if comment:
569
            cmd.add_element('comment', comment)
570
571
        name = kwargs.get('name', '')
572
        if name:
573
            cmd.add_element('name', name)
574
575
        first_time = kwargs.get('first_time', '')
576
        if first_time:
577
            first_time_minute = first_time['minute']
578
            first_time_hour = first_time['hour']
579
            first_time_day_of_month = first_time['day_of_month']
580
            first_time_month = first_time['month']
581
            first_time_year = first_time['year']
582
583
            _xmlftime = cmd.add_element('first_time')
584
            _xmlftime.add_element('minute', str(first_time_minute))
585
            _xmlftime.add_element('hour', str(first_time_hour))
586
            _xmlftime.add_element('day_of_month', str(first_time_day_of_month))
587
            _xmlftime.add_element('month', str(first_time_month))
588
            _xmlftime.add_element('year', str(first_time_year))
589
590
        duration = kwargs.get('duration', '')
591
        if len(duration) > 1:
592
            _xmlduration = cmd.add_element('duration', str(duration[0]))
593
            _xmlduration.add_element('unit', str(duration[1]))
594
595
        period = kwargs.get('period', '')
596
        if len(period) > 1:
597
            _xmlperiod = cmd.add_element('period', str(period[0]))
598
            _xmlperiod.add_element('unit', str(period[1]))
599
600
        timezone = kwargs.get('timezone', '')
601
        if timezone:
602
            cmd.add_element('timezone', str(timezone))
603
604
        return cmd.to_string()
605
606
    def modify_setting_command(self, setting_id, name, value):
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...
607
        """Generates xml string for modify setting format on gvmd."""
608
        cmd = XmlCommand('modify_setting')
609
        cmd.set_attribute('setting_id', setting_id)
610
        cmd.add_element('name', name)
611
        cmd.add_element('value', value)
612
613
        return cmd.to_string()
614
615
    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...
616
        """Generates xml string for modify tag on gvmd."""
617
        if not tag_id:
618
            raise ValueError('modify_tag requires a tag_id element')
619
620
        cmd = XmlCommand('modify_tag')
621
        cmd.set_attribute('tag_id', str(tag_id))
622
623
        comment = kwargs.get('comment', '')
624
        if comment:
625
            cmd.add_element('comment', comment)
626
627
        name = kwargs.get('name', '')
628
        if name:
629
            cmd.add_element('name', name)
630
631
        value = kwargs.get('value', '')
632
        if value:
633
            cmd.add_element('value', value)
634
635
        active = kwargs.get('active', '')
636
        if active:
637
            cmd.add_element('active', value)
638
639
        resource = kwargs.get('resource', '')
640
        if resource:
641
            resource_id = resource['id']
642
            resource_type = resource['type']
643
            _xmlresource = cmd.add_element('resource',
644
                                           attrs={'resource_id': resource_id})
645
            _xmlresource.add_element('type', resource_type)
646
647
        return cmd.to_string()
648
649
    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...
650
        """Generates xml string for modify target on gvmd."""
651
        if not target_id:
652
            raise ValueError('modify_target requires a target_id element')
653
654
        cmd = XmlCommand('modify_target')
655
        cmd.set_attribute('target_id', target_id)
656
657
        comment = kwargs.get('comment', '')
658
        if comment:
659
            cmd.add_element('comment', comment)
660
661
        name = kwargs.get('name', '')
662
        if name:
663
            cmd.add_element('name', name)
664
665
        hosts = kwargs.get('hosts', '')
666
        if hosts:
667
            cmd.add_element('hosts', hosts)
668
669
        copy = kwargs.get('copy', '')
670
        if copy:
671
            cmd.add_element('copy', copy)
672
673
        exclude_hosts = kwargs.get('exclude_hosts', '')
674
        if exclude_hosts:
675
            cmd.add_element('exclude_hosts', exclude_hosts)
676
677
        alive_tests = kwargs.get('alive_tests', '')
678
        if alive_tests:
679
            cmd.add_element('alive_tests', alive_tests)
680
681
        reverse_lookup_only = kwargs.get('reverse_lookup_only', '')
682
        if reverse_lookup_only:
683
            cmd.add_element('reverse_lookup_only', reverse_lookup_only)
684
685
        reverse_lookup_unify = kwargs.get('reverse_lookup_unify', '')
686
        if reverse_lookup_unify:
687
            cmd.add_element('reverse_lookup_unify', reverse_lookup_unify)
688
689
        port_range = kwargs.get('port_range', '')
690
        if port_range:
691
            cmd.add_element('port_range', port_range)
692
693
        port_list = kwargs.get('port_list', '')
694
        if port_list:
695
            cmd.add_element('port_list', attrs={'id': str(port_list)})
696
697
        return cmd.to_string()
698
699
    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...
700
        """Generates xml string for modify task on gvmd."""
701
        if not task_id:
702
            raise ValueError('modify_task requires a task_id element')
703
704
        cmd = XmlCommand('modify_task')
705
        cmd.set_attribute('task_id', task_id)
706
707
        name = kwargs.get('name', '')
708
        if name:
709
            cmd.add_element('name', name)
710
711
        comment = kwargs.get('comment', '')
712
        if comment:
713
            cmd.add_element('comment', comment)
714
715
        target_id = kwargs.get('target_id', '')
716
        if target_id:
717
            cmd.add_element('target', attrs={'id': target_id})
718
719
        scanner = kwargs.get('scanner', '')
720
        if scanner:
721
            cmd.add_element('scanner', attrs={'id': scanner})
722
723
        schedule_periods = kwargs.get('schedule_periods', '')
724
        if schedule_periods:
725
            cmd.add_element('schedule_periods', str(schedule_periods))
726
727
        schedule = kwargs.get('schedule', '')
728
        if schedule:
729
            cmd.add_element('schedule', attrs={'id': str(schedule)})
730
731
        alert = kwargs.get('alert', '')
732
        if alert:
733
            cmd.add_element('alert', attrs={'id': str(alert)})
734
735
        observers = kwargs.get('observers', '')
736
        if observers:
737
            cmd.add_element('observers', str(observers))
738
739
        preferences = kwargs.get('preferences', '')
740
        if preferences:
741
            _xmlprefs = cmd.add_element('preferences')
742
            for n in range(len(preferences["scanner_name"])):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to '[a-z_][a-z0-9_]+$' pattern ('[a-z_][a-z0-9_]+$' pattern)

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...
743
                preferences_scanner_name = preferences["scanner_name"][n]
744
                preferences_value = preferences["value"][n]
745
                _xmlpref = _xmlprefs.add_element('preference')
746
                _xmlpref.add_element('scanner_name', preferences_scanner_name)
747
                _xmlpref.add_element('value', preferences_value)
748
749
        file = kwargs.get('file', '')
750
        if file:
751
            file_name = file['name']
752
            file_action = file['action']
753
            if file_action != "update" and file_action != "remove":
0 ignored issues
show
Unused Code introduced by
Consider merging these comparisons with "in" to "file_action not in ('update', 'remove')"
Loading history...
754
                raise ValueError('action can only be "update" or "remove"!')
755
            cmd.add_element('file', attrs={'name': file_name,
756
                                           'action': file_action})
757
758
        return cmd.to_string()
759
760
    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...
761
        """Generates xml string for modify user on gvmd."""
762
        user_id = kwargs.get('user_id', '')
763
        name = kwargs.get('name', '')
764
765
        if not user_id and not name:
766
            raise ValueError('modify_user requires '
767
                             'either a user_id or a name element')
768
769
        cmd = XmlCommand('modify_user')
770
        cmd.set_attribute('user_id', str(user_id))
771
772
        new_name = kwargs.get('new_name', '')
773
        if new_name:
774
            cmd.add_element('new_name', new_name)
775
776
        password = kwargs.get('password', '')
777
        if password:
778
            cmd.add_element('password', password)
779
780
        role_ids = kwargs.get('role_ids', '')
781
        if len(role_ids) > 0:
782
            for role in role_ids:
783
                cmd.add_element('role', attrs={'id': str(role)})
784
785
        hosts = kwargs.get('hosts', '')
786
        hosts_allow = kwargs.get('hosts_allow', '')
787
        if hosts or hosts_allow:
788
            cmd.add_element('hosts', hosts, attrs={'allow': str(hosts_allow)})
789
790
        ifaces = kwargs.get('ifaces', '')
791
        ifaces_allow = kwargs.get('ifaces_allow', '')
792
        if ifaces or ifaces_allow:
793
            cmd.add_element('ifaces', ifaces,
794
                            attrs={'allow': str(ifaces_allow)})
795
796
        sources = kwargs.get('sources', '')
797
        if sources:
798
            cmd.add_element('sources', sources)
799
800
        return cmd.to_string()
801
802
    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...
803
        """Generates xml string for delete agent on gvmd"""
804
        cmd = XmlCommand('delete_agent')
805
        for key, value in kwargs.items():
806
            cmd.set_attribute(key, value)
807
808
        return cmd.to_string()
809
810
    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...
811
        """Generates xml string for delete alert on gvmd"""
812
        cmd = XmlCommand('delete_alert')
813
        for key, value in kwargs.items():
814
            cmd.set_attribute(key, value)
815
816
        return cmd.to_string()
817
818
    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...
819
        """Generates xml string for delete asset on gvmd"""
820
        cmd = XmlCommand('delete_asset')
821
        cmd.set_attribute('asset_id', asset_id)
822
        cmd.set_attribute('ultimate', ultimate)
823
824
        return cmd.to_string()
825
826
    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...
827
        """Generates xml string for delete config on gvmd"""
828
        cmd = XmlCommand('delete_config')
829
        cmd.set_attribute('config_id', config_id)
830
        cmd.set_attribute('ultimate', ultimate)
831
832
        return cmd.to_string()
833
834
    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...
835
        """Generates xml string for delete credential on gvmd"""
836
        cmd = XmlCommand('delete_credential')
837
        cmd.set_attribute('credential_id', credential_id)
838
        cmd.set_attribute('ultimate', ultimate)
839
        return cmd.to_string()
840
841
    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...
842
        """Generates xml string for delete filter on gvmd"""
843
        cmd = XmlCommand('delete_filter')
844
        cmd.set_attribute('filter_id', filter_id)
845
        cmd.set_attribute('ultimate', ultimate)
846
847
        return cmd.to_string()
848
849
    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...
850
        """Generates xml string for delete group on gvmd"""
851
        cmd = XmlCommand('delete_group')
852
        cmd.set_attribute('group_id', group_id)
853
        cmd.set_attribute('ultimate', ultimate)
854
855
        return cmd.to_string()
856
857
    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...
858
        """Generates xml string for delete note on gvmd"""
859
        cmd = XmlCommand('delete_note')
860
        cmd.set_attribute('note_id', note_id)
861
        cmd.set_attribute('ultimate', ultimate)
862
863
        return cmd.to_string()
864
865
    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...
866
        """Generates xml string for delete override on gvmd"""
867
        cmd = XmlCommand('delete_override')
868
        cmd.set_attribute('override_id', override_id)
869
        cmd.set_attribute('ultimate', ultimate)
870
871
        return cmd.to_string()
872
873
    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...
874
        """Generates xml string for delete permission on gvmd"""
875
        cmd = XmlCommand('delete_permission')
876
        cmd.set_attribute('permission_id', permission_id)
877
        cmd.set_attribute('ultimate', ultimate)
878
879
        return cmd.to_string()
880
881
    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...
882
        """Generates xml string for delete port on gvmd"""
883
        cmd = XmlCommand('delete_port_list')
884
        cmd.set_attribute('port_list_id', port_list_id)
885
        cmd.set_attribute('ultimate', ultimate)
886
887
        return cmd.to_string()
888
889
    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...
890
        """Generates xml string for delete port on gvmd"""
891
        cmd = XmlCommand('delete_port_range')
892
        cmd.set_attribute('port_range_id', port_range_id)
893
894
        return cmd.to_string()
895
896
    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...
897
        """Generates xml string for delete report on gvmd"""
898
        cmd = XmlCommand('delete_report')
899
        cmd.set_attribute('report_id', report_id)
900
901
        return cmd.to_string()
902
903
    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...
904
        """Generates xml string for delete report on gvmd"""
905
        cmd = XmlCommand('delete_report_format')
906
        cmd.set_attribute('report_format_id', report_format_id)
907
        cmd.set_attribute('ultimate', ultimate)
908
909
        return cmd.to_string()
910
911
    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...
912
        """Generates xml string for delete role on gvmd"""
913
        cmd = XmlCommand('delete_role')
914
        cmd.set_attribute('role_id', role_id)
915
        cmd.set_attribute('ultimate', ultimate)
916
917
        return cmd.to_string()
918
919
    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...
920
        """Generates xml string for delete scanner on gvmd"""
921
        cmd = XmlCommand('delete_scanner')
922
        cmd.set_attribute('scanner_id', scanner_id)
923
        cmd.set_attribute('ultimate', ultimate)
924
925
        return cmd.to_string()
926
927
    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...
928
        """Generates xml string for delete schedule on gvmd"""
929
        # if self.ask_yes_or_no('Are you sure to delete this schedule? '):
930
        cmd = XmlCommand('delete_schedule')
931
        cmd.set_attribute('schedule_id', schedule_id)
932
        cmd.set_attribute('ultimate', ultimate)
933
934
        return cmd.to_string()
935
936
    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...
937
        """Generates xml string for delete tag on gvmd"""
938
        cmd = XmlCommand('delete_tag')
939
        cmd.set_attribute('tag_id', tag_id)
940
        cmd.set_attribute('ultimate', ultimate)
941
942
        return cmd.to_string()
943
944
    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...
945
        """Generates xml string for delete target on gvmd"""
946
        cmd = XmlCommand('delete_target')
947
        cmd.set_attribute('target_id', target_id)
948
        cmd.set_attribute('ultimate', ultimate)
949
950
        return cmd.to_string()
951
952
    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...
953
        """Generates xml string for delete task on gvmd"""
954
        cmd = XmlCommand('delete_task')
955
        cmd.set_attribute('task_id', task_id)
956
        cmd.set_attribute('ultimate', ultimate)
957
958
        return cmd.to_string()
959
960
    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...
961
        """Generates xml string for delete user on gvmd"""
962
        cmd = XmlCommand('delete_user')
963
964
        user_id = kwargs.get('user_id', '')
965
        if user_id:
966
            cmd.set_attribute('user_id', user_id)
967
968
        name = kwargs.get('name', '')
969
        if name:
970
            cmd.set_attribute('name', name)
971
972
        inheritor_id = kwargs.get('inheritor_id', '')
973
        if inheritor_id:
974
            cmd.set_attribute('inheritor_id', inheritor_id)
975
976
        inheritor_name = kwargs.get('inheritor_name', '')
977
        if inheritor_name:
978
            cmd.set_attribute('inheritor_name', inheritor_name)
979
980
        return cmd.to_string()
981
982
    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...
983
        """Generates xml string for describe auth on gvmd"""
984
        cmd = XmlCommand('describe_auth')
985
        return cmd.to_string()
986
987
    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...
988
        """Generates xml string for empty trashcan on gvmd"""
989
        cmd = XmlCommand('empty_trashcan')
990
        return cmd.to_string()
991
992
    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...
993
        """Generates xml string for get agents on gvmd."""
994
        cmd = XmlCommand('get_agents')
995
        cmd.set_attributes(kwargs)
996
        return cmd.to_string()
997
998
    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...
999
        """Generates xml string for get aggregates on gvmd."""
1000
        cmd = XmlCommand('get_aggregates')
1001
        cmd.set_attributes(kwargs)
1002
        return cmd.to_string()
1003
1004
    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...
1005
        """Generates xml string for get alerts on gvmd."""
1006
        cmd = XmlCommand('get_alerts')
1007
        cmd.set_attributes(kwargs)
1008
        return cmd.to_string()
1009
1010
    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...
1011
        """Generates xml string for get assets on gvmd."""
1012
        cmd = XmlCommand('get_assets')
1013
        cmd.set_attributes(kwargs)
1014
        return cmd.to_string()
1015
1016
    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...
1017
        """Generates xml string for get credentials on gvmd."""
1018
        cmd = XmlCommand('get_credentials')
1019
        cmd.set_attributes(kwargs)
1020
        return cmd.to_string()
1021
1022
    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...
1023
        """Generates xml string for get configs on gvmd."""
1024
        cmd = XmlCommand('get_configs')
1025
        cmd.set_attributes(kwargs)
1026
        return cmd.to_string()
1027
1028
    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...
1029
        """Generates xml string for get feeds on gvmd."""
1030
        cmd = XmlCommand('get_feeds')
1031
        cmd.set_attributes(kwargs)
1032
        return cmd.to_string()
1033
1034
    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...
1035
        """Generates xml string for get filters on gvmd."""
1036
        cmd = XmlCommand('get_filters')
1037
        cmd.set_attributes(kwargs)
1038
        return cmd.to_string()
1039
1040
    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...
1041
        """Generates xml string for get groups on gvmd."""
1042
        cmd = XmlCommand('get_groups')
1043
        cmd.set_attributes(kwargs)
1044
        return cmd.to_string()
1045
1046
    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...
1047
        """Generates xml string for get info on gvmd."""
1048
        cmd = XmlCommand('get_info')
1049
        cmd.set_attributes(kwargs)
1050
        return cmd.to_string()
1051
1052
    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...
1053
        """Generates xml string for get notes on gvmd."""
1054
        cmd = XmlCommand('get_notes')
1055
        cmd.set_attributes(kwargs)
1056
        return cmd.to_string()
1057
1058
    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...
1059
        """Generates xml string for get nvts on gvmd."""
1060
        cmd = XmlCommand('get_nvts')
1061
        cmd.set_attributes(kwargs)
1062
        return cmd.to_string()
1063
1064
    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...
1065
        """Generates xml string for get nvt on gvmd."""
1066
        cmd = XmlCommand('get_nvt_families')
1067
        cmd.set_attributes(kwargs)
1068
        return cmd.to_string()
1069
1070
    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...
1071
        """Generates xml string for get overrides on gvmd."""
1072
        cmd = XmlCommand('get_overrides')
1073
        cmd.set_attributes(kwargs)
1074
        return cmd.to_string()
1075
1076
    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...
1077
        """Generates xml string for get permissions on gvmd."""
1078
        cmd = XmlCommand('get_permissions')
1079
        cmd.set_attributes(kwargs)
1080
        return cmd.to_string()
1081
1082
    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...
1083
        """Generates xml string for get port on gvmd."""
1084
        cmd = XmlCommand('get_port_lists')
1085
        cmd.set_attributes(kwargs)
1086
        return cmd.to_string()
1087
1088
    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...
1089
        """Generates xml string for get preferences on gvmd."""
1090
        cmd = XmlCommand('get_preferences')
1091
        cmd.set_attributes(kwargs)
1092
        return cmd.to_string()
1093
1094
    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...
1095
        """Generates xml string for get reports on gvmd."""
1096
        cmd = XmlCommand('get_reports')
1097
        cmd.set_attributes(kwargs)
1098
        return cmd.to_string()
1099
1100
    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...
1101
        """Generates xml string for get report on gvmd."""
1102
        cmd = XmlCommand('get_report_formats')
1103
        cmd.set_attributes(kwargs)
1104
        return cmd.to_string()
1105
1106
    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...
1107
        """Generates xml string for get results on gvmd."""
1108
        cmd = XmlCommand('get_results')
1109
        cmd.set_attributes(kwargs)
1110
        return cmd.to_string()
1111
1112
    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...
1113
        """Generates xml string for get roles on gvmd."""
1114
        cmd = XmlCommand('get_roles')
1115
        cmd.set_attributes(kwargs)
1116
        return cmd.to_string()
1117
1118
    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...
1119
        """Generates xml string for get scanners on gvmd."""
1120
        cmd = XmlCommand('get_scanners')
1121
        cmd.set_attributes(kwargs)
1122
        return cmd.to_string()
1123
1124
    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...
1125
        """Generates xml string for get schedules on gvmd."""
1126
        cmd = XmlCommand('get_schedules')
1127
        cmd.set_attributes(kwargs)
1128
        return cmd.to_string()
1129
1130
    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...
1131
        """Generates xml string for get settings on gvmd."""
1132
        cmd = XmlCommand('get_settings')
1133
        cmd.set_attributes(kwargs)
1134
        return cmd.to_string()
1135
1136
    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...
1137
        """Generates xml string for get system on gvmd."""
1138
        cmd = XmlCommand('get_system')
1139
        cmd.set_attributes(kwargs)
1140
        return cmd.to_string()
1141
1142
    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...
1143
        """Generates xml string for get tags on gvmd."""
1144
        cmd = XmlCommand('get_tags')
1145
        cmd.set_attributes(kwargs)
1146
        return cmd.to_string()
1147
1148
    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...
1149
        """Generates xml string for get targets on gvmd."""
1150
        cmd = XmlCommand('get_targets')
1151
        cmd.set_attributes(kwargs)
1152
        return cmd.to_string()
1153
1154
    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...
1155
        """Generates xml string for get tasks on gvmd."""
1156
        cmd = XmlCommand('get_tasks')
1157
        cmd.set_attributes(kwargs)
1158
        return cmd.to_string()
1159
1160
    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...
1161
        """Generates xml string for get users on gvmd."""
1162
        cmd = XmlCommand('get_users')
1163
        cmd.set_attributes(kwargs)
1164
        return cmd.to_string()
1165
1166
    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...
1167
        """Generates xml string for get version on gvmd."""
1168
        cmd = XmlCommand('get_version')
1169
        return cmd.to_string()
1170
1171
    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...
1172
        """Generates xml string for help on gvmd."""
1173
        cmd = XmlCommand('help')
1174
        cmd.set_attributes(kwargs)
1175
        return cmd.to_string()
1176
1177
    def move_task_command(self, task_id, slave_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...
1178
        """Generates xml string for move task on gvmd."""
1179
        cmd = XmlCommand('move_task')
1180
        cmd.set_attribute('task_id', task_id)
1181
        cmd.set_attribute('slave_id', slave_id)
1182
        return cmd.to_string()
1183
1184
    def restore_command(self, entity_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...
1185
        """Generates xml string for restore on gvmd."""
1186
        cmd = XmlCommand('restore')
1187
        cmd.set_attribute('id', entity_id)
1188
        return cmd.to_string()
1189
1190
    def resume_task_command(self, task_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...
1191
        """Generates xml string for resume task on gvmd."""
1192
        cmd = XmlCommand('resume_task')
1193
        cmd.set_attribute('task_id', task_id)
1194
        return cmd.to_string()
1195
1196
    def start_task_command(self, task_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...
1197
        """Generates xml string for start task on gvmd."""
1198
        cmd = XmlCommand('start_task')
1199
        cmd.set_attribute('task_id', task_id)
1200
        return cmd.to_string()
1201
1202
    def stop_task_command(self, task_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...
1203
        """Generates xml string for stop task on gvmd."""
1204
        cmd = XmlCommand('stop_task')
1205
        cmd.set_attribute('task_id', task_id)
1206
        return cmd.to_string()
1207
1208
    def sync_cert_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...
1209
        """Generates xml string for sync cert on gvmd."""
1210
        cmd = XmlCommand('sync_cert')
1211
        return cmd.to_string()
1212
1213
    def sync_config_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...
1214
        """Generates xml string for sync config on gvmd."""
1215
        cmd = XmlCommand('sync_config')
1216
        return cmd.to_string()
1217
1218
    def sync_feed_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...
1219
        """Generates xml string for sync feed on gvmd."""
1220
        cmd = XmlCommand('sync_feed')
1221
        return cmd.to_string()
1222
1223
    def sync_scap_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...
1224
        """Generates xml string for sync scap on gvmd."""
1225
        cmd = XmlCommand('sync_scap')
1226
        return cmd.to_string()
1227
1228
    def test_alert_command(self, alert_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...
1229
        """Generates xml string for test alert on gvmd."""
1230
        cmd = XmlCommand('test_alert')
1231
        cmd.set_attribute('alert_id', alert_id)
1232
        return cmd.to_string()
1233
1234
    def verify_agent_command(self, agent_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...
1235
        """Generates xml string for verify agent on gvmd."""
1236
        cmd = XmlCommand('verify_agent')
1237
        cmd.set_attribute('agent_id', agent_id)
1238
        return cmd.to_string()
1239
1240
    def verify_report_format_command(self, report_format_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...
1241
        """Generates xml string for verify report format on gvmd."""
1242
        cmd = XmlCommand('verify_report_format')
1243
        cmd.set_attribute('report_format_id', report_format_id)
1244
        return cmd.to_string()
1245
1246
    def verify_scanner_command(self, scanner_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...
1247
        """Generates xml string for verify scanner on gvmd."""
1248
        cmd = XmlCommand('verify_scanner')
1249
        cmd.set_attribute('scanner_id', scanner_id)
1250
        return cmd.to_string()
1251
1252
1253
def pretty_print(xml):
1254
    """Prints beautiful XML-Code
1255
1256
    This function gets an object of list<lxml.etree._Element>
1257
    or directly a lxml element.
1258
    Print it with good readable format.
1259
1260
    Arguments:
1261
        xml: List<lxml.etree.Element> or directly a lxml element
1262
    """
1263
    if isinstance(xml, list):
1264
        for item in xml:
1265
            if etree.iselement(item):
1266
                print(etree.tostring(item, pretty_print=True).decode('utf-8'))
1267
            else:
1268
                print(item)
1269
    elif etree.iselement(xml):
1270
        print(etree.tostring(xml, pretty_print=True).decode('utf-8'))
1271