Passed
Pull Request — master (#188)
by Matěj
01:01
created

org_fedora_oscap.common.ssg_available()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
#
2
# Copyright (C) 2013  Red Hat, Inc.
3
#
4
# This copyrighted material is made available to anyone wishing to use,
5
# modify, copy, or redistribute it subject to the terms and conditions of
6
# the GNU General Public License v.2, or (at your option) any later version.
7
# This program is distributed in the hope that it will be useful, but WITHOUT
8
# ANY WARRANTY expressed or implied, including the implied warranties of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
10
# Public License for more details.  You should have received a copy of the
11
# GNU General Public License along with this program; if not, write to the
12
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13
# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
14
# source code or documentation are not subject to the GNU General Public
15
# License and may only be used or replicated with the express permission of
16
# Red Hat, Inc.
17
#
18
# Red Hat Author(s): Vratislav Podzimek <[email protected]>
19
#
20
21
"""
22
Module with various classes and functions needed by the OSCAP addon that are
23
not specific to any installation mode (tui, gui, ks).
24
25
"""
26
27
import os
28
import tempfile
29
import subprocess
30
import zipfile
31
import tarfile
32
33
import re
34
import logging
35
36
from collections import namedtuple
37
import gettext
38
from functools import wraps
39
40
from dasbus.identifier import DBusServiceIdentifier
41
from pyanaconda.core import constants
42
from pyanaconda.core.dbus import DBus
43
from pyanaconda.core.constants import PAYLOAD_TYPE_DNF
44
from pyanaconda.modules.common.constants.namespaces import ADDONS_NAMESPACE
45
from pyanaconda.modules.common.constants.services import NETWORK, PAYLOADS
46
from pyanaconda.modules.common.structures.packages import PackagesSelectionData
47
from pyanaconda.threading import threadMgr, AnacondaThread
48
49
from org_fedora_oscap import utils
50
from org_fedora_oscap import cpioarchive
51
52
53
log = logging.getLogger("anaconda")
54
55
56
# mimick pyanaconda/core/i18n.py
57
def _(string):
58
    if string:
59
        return gettext.translation("oscap-anaconda-addon", fallback=True).gettext(string)
60
    else:
61
        return ""
62
63
64
def N_(string): return string
65
66
67
# everything else should be private
68
__all__ = ["run_oscap_remediate", "get_fix_rules_pre",
69
           "extract_data", "strip_content_dir",
70
           "OSCAPaddonError", "get_payload_proxy", "get_packages_data",
71
           "set_packages_data"]
72
73
INSTALLATION_CONTENT_DIR = "/tmp/openscap_data/"
74
TARGET_CONTENT_DIR = "/root/openscap_data/"
75
76
SSG_DIR = "/usr/share/xml/scap/ssg/content/"
77
78
# Make it easy to change e.g. by sed substitution in spec files
79
# First name is the canonical addon name, rest are adapters
80
ADDON_NAMES = ["com_redhat_oscap", "org_fedora_oscap"]
81
82
COMPLAIN_ABOUT_NON_CANONICAL_NAMES = True
83
84
# Enable patches that set the content name at package-time
85
DEFAULT_SSG_CONTENT_NAME = ""
86
SSG_CONTENT = DEFAULT_SSG_CONTENT_NAME
87
if not SSG_CONTENT:
88
    if constants.shortProductName != 'anaconda':
89
        if constants.shortProductName == 'fedora':
90
            SSG_CONTENT = "ssg-fedora-ds.xml"
91
        else:
92
            SSG_CONTENT = (
93
                "ssg-{name}{version}-ds.xml"
94
                .format(
95
                    name=constants.shortProductName,
96
                    version=constants.productVersion.strip(".")[0]))
97
98
RESULTS_PATH = utils.join_paths(TARGET_CONTENT_DIR,
99
                                "eval_remediate_results.xml")
100
REPORT_PATH = utils.join_paths(TARGET_CONTENT_DIR,
101
                               "eval_remediate_report.html")
102
103
PRE_INSTALL_FIX_SYSTEM_ATTR = "urn:redhat:anaconda:pre"
104
105
THREAD_FETCH_DATA = "AnaOSCAPdataFetchThread"
106
107
SUPPORTED_ARCHIVES = (".zip", ".tar", ".tar.gz", ".tar.bz2", )
108
109
SUPPORTED_CONTENT_TYPES = (
110
    "datastream", "rpm", "archive", "scap-security-guide",
111
)
112
113
SUPPORTED_URL_PREFIXES = (
114
    "http://", "https://", "ftp://",  # LABEL:?, hdaX:?,
115
)
116
117
# buffer size for reading and writing out data (in bytes)
118
IO_BUF_SIZE = 2 * 1024 * 1024
119
120
# DBus constants
121
KDUMP = DBusServiceIdentifier(
122
    namespace=ADDONS_NAMESPACE,
123
    basename="Kdump",
124
    message_bus=DBus
125
)
126
127
128
class OSCAPaddonError(Exception):
129
    """Exception class for OSCAP addon related errors."""
130
131
    pass
132
133
134
class OSCAPaddonNetworkError(OSCAPaddonError):
135
    """Exception class for OSCAP addon related network errors."""
136
137
    pass
138
139
140
class ExtractionError(OSCAPaddonError):
141
    """Exception class for the extraction errors."""
142
143
    pass
144
145
146
MESSAGE_TYPE_FATAL = 0
147
MESSAGE_TYPE_WARNING = 1
148
MESSAGE_TYPE_INFO = 2
149
150
# namedtuple for messages returned from the rules evaluation
151
#   origin -- class (inherited from RuleHandler) that generated the message
152
#   type -- one of the MESSAGE_TYPE_* constants defined above
153
#   text -- the actual message that should be displayed, logged, ...
154
RuleMessage = namedtuple("RuleMessage", ["origin", "type", "text"])
155
156
157
class SubprocessLauncher(object):
158
    def __init__(self, args):
159
        self.args = args
160
        self.stdout = ""
161
        self.stderr = ""
162
        self.messages = []
163
        self.returncode = None
164
165
    def execute(self, ** kwargs):
166
        command_string = " ".join(self.args)
167
        log.info(
168
            "OSCAP addon: Executing subprocess: '{command_string}'"
169
            .format(command_string=command_string))
170
        try:
171
            proc = subprocess.Popen(self.args, stdout=subprocess.PIPE,
172
                                    stderr=subprocess.PIPE, ** kwargs)
173
        except OSError as oserr:
174
            msg = ("Failed to execute command '{command_string}': {oserr}"
175
                   .format(command_string=command_string, oserr=oserr))
176
            raise OSCAPaddonError(msg)
177
178
        (stdout, stderr) = proc.communicate()
179
        self.stdout = stdout.decode()
180
        self.stderr = stderr.decode(errors="replace")
181
        self.messages = re.findall(r'OpenSCAP Error:.*', self.stderr)
182
        self.messages = self.messages + re.findall(r'E: oscap:.*', self.stderr)
183
184
        self.returncode = proc.returncode
185
186
    def log_messages(self):
187
        for message in self.messages:
188
            log.warning("OSCAP addon: " + message)
189
190
191
def get_fix_rules_pre(profile, fpath, ds_id="", xccdf_id="", tailoring=""):
192
    """
193
    Get fix rules for the pre-installation environment for a given profile in a
194
    given datastream and checklist in a given file.
195
196
    :see: run_oscap_remediate
197
    :see: _run_oscap_gen_fix
198
    :return: fix rules for a given profile
199
    :rtype: str
200
201
    """
202
203
    return _run_oscap_gen_fix(profile, fpath, PRE_INSTALL_FIX_SYSTEM_ATTR,
204
                              ds_id=ds_id, xccdf_id=xccdf_id,
205
                              tailoring=tailoring)
206
207
208
def _run_oscap_gen_fix(profile, fpath, template, ds_id="", xccdf_id="",
209
                       tailoring=""):
210
    """
211
    Run oscap tool on a given file to get the contents of fix elements with the
212
    'system' attribute equal to a given template for a given datastream,
213
    checklist and profile.
214
215
    :see: run_oscap_remediate
216
    :param template: the value of the 'system' attribute of the fix elements
217
    :type template: str
218
    :return: oscap tool's stdout
219
    :rtype: str
220
221
    """
222
223
    if not profile:
224
        return ""
225
226
    args = ["oscap", "xccdf", "generate", "fix"]
227
    args.append("--template=%s" % template)
228
229
    # oscap uses the default profile by default
230
    if profile.lower() != "default":
231
        args.append("--profile=%s" % profile)
232
    if ds_id:
233
        args.append("--datastream-id=%s" % ds_id)
234
    if xccdf_id:
235
        args.append("--xccdf-id=%s" % xccdf_id)
236
    if tailoring:
237
        args.append("--tailoring-file=%s" % tailoring)
238
239
    args.append(fpath)
240
241
    proc = SubprocessLauncher(args)
242
    proc.execute()
243
    proc.log_messages()
244
    if proc.returncode != 0:
245
        msg = "Failed to generate fix rules with the oscap tool: %s" % proc.stderr
246
        raise OSCAPaddonError(msg)
247
248
    return proc.stdout
249
250
251
def do_chroot(chroot):
252
    """Helper function doing the chroot if requested."""
253
    if chroot and chroot != "/":
254
        os.chroot(chroot)
255
        os.chdir("/")
256
257
258
def assert_scanner_works(chroot, executable="oscap"):
259
    args = [executable, "--version"]
260
    command = " ".join(args)
261
262
    try:
263
        proc = subprocess.Popen(
264
            args, preexec_fn=lambda: do_chroot(chroot),
265
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
266
        (stdout, stderr) = proc.communicate()
267
        stderr = stderr.decode(errors="replace")
268
    except OSError as exc:
269
        msg = _(f"Basic invocation '{command}' fails: {str(exc)}")
270
        raise OSCAPaddonError(msg)
271
    if proc.returncode != 0:
272
        msg = _(
273
            f"Basic scanner invocation '{command}' exited "
274
            "with non-zero error code {proc.returncode}: {stderr}")
275
        raise OSCAPaddonError(msg)
276
    return True
277
278
279
def run_oscap_remediate(profile, fpath, ds_id="", xccdf_id="", tailoring="",
280
                        chroot=""):
281
    """
282
    Run the evaluation and remediation with the oscap tool on a given file,
283
    doing the remediation as defined in a given profile defined in a given
284
    checklist that is a part of a given datastream. If requested, run in
285
    chroot.
286
287
    :param profile: id of the profile that will drive the remediation
288
    :type profile: str
289
    :param fpath: path to a file with SCAP content
290
    :type fpath: str
291
    :param ds_id: ID of the datastream that contains the checklist defining
292
                  the profile
293
    :type ds_id: str
294
    :param xccdf_id: ID of the checklist that defines the profile
295
    :type xccdf_id: str
296
    :param tailoring: path to a tailoring file
297
    :type tailoring: str
298
    :param chroot: path to the root the oscap tool should be run in
299
    :type chroot: str
300
    :return: oscap tool's stdout (summary of the rules, checks and fixes)
301
    :rtype: str
302
303
    """
304
305
    if not profile:
306
        return ""
307
308
    # make sure the directory for the results exists
309
    results_dir = os.path.dirname(RESULTS_PATH)
310
    if chroot:
311
        results_dir = os.path.normpath(chroot + "/" + results_dir)
312
    utils.ensure_dir_exists(results_dir)
313
314
    args = ["oscap", "xccdf", "eval"]
315
    args.append("--remediate")
316
    args.append("--results=%s" % RESULTS_PATH)
317
    args.append("--report=%s" % REPORT_PATH)
318
319
    # oscap uses the default profile by default
320
    if profile.lower() != "default":
321
        args.append("--profile=%s" % profile)
322
    if ds_id:
323
        args.append("--datastream-id=%s" % ds_id)
324
    if xccdf_id:
325
        args.append("--xccdf-id=%s" % xccdf_id)
326
    if tailoring:
327
        args.append("--tailoring-file=%s" % tailoring)
328
329
    args.append(fpath)
330
331
    proc = SubprocessLauncher(args)
332
    proc.execute(preexec_fn=lambda: do_chroot(chroot))
333
    proc.log_messages()
334
335
    if proc.returncode not in (0, 2):
336
        # 0 -- success; 2 -- no error, but checks/remediation failed
337
        msg = "Content evaluation and remediation with the oscap tool "\
338
            "failed: %s" % proc.stderr
339
        raise OSCAPaddonError(msg)
340
341
    return proc.stdout
342
343
344
def extract_data(archive, out_dir, ensure_has_files=None):
345
    """
346
    Fuction that extracts the given archive to the given output directory. It
347
    tries to find out the archive type by the file name.
348
349
    :param archive: path to the archive file that should be extracted
350
    :type archive: str
351
    :param out_dir: output directory the archive should be extracted to
352
    :type out_dir: str
353
    :param ensure_has_files: relative paths to the files that must exist in the
354
                             archive
355
    :type ensure_has_files: iterable of strings or None
356
    :return: a list of files and directories extracted from the archive
357
    :rtype: [str]
358
359
    """
360
361
    if not ensure_has_files:
362
        ensure_has_files = []
363
364
    # get rid of empty file paths
365
    if not ensure_has_files:
366
        ensure_has_files = []
367
    else:
368
        ensure_has_files = [fpath for fpath in ensure_has_files if fpath]
369
370
    msg = "OSCAP addon: Extracting {archive}".format(archive=archive)
371
    if ensure_has_files:
372
        msg += ", expecting to find {files} there.".format(files=tuple(ensure_has_files))
373
    log.info(msg)
374
375
    result = []
376
    if archive.endswith(".zip"):
377
        # ZIP file
378
        try:
379
            zfile = zipfile.ZipFile(archive, "r")
380
        except Exception as exc:
381
            msg = _(f"Error extracting archive as a zipfile: {exc}")
382
            raise ExtractionError(msg)
383
384
        # generator for the paths of the files found in the archive (dirs end
385
        # with "/")
386
        files = set(info.filename for info in zfile.filelist
387
                    if not info.filename.endswith("/"))
388
        for fpath in ensure_has_files or ():
389
            if fpath not in files:
390
                msg = "File '%s' not found in the archive '%s'" % (fpath,
391
                                                                   archive)
392
                raise ExtractionError(msg)
393
394
        utils.ensure_dir_exists(out_dir)
395
        zfile.extractall(path=out_dir)
396
        result = [utils.join_paths(out_dir, info.filename) for info in zfile.filelist]
397
        zfile.close()
398
    elif archive.endswith(".tar"):
399
        # plain tarball
400
        result = _extract_tarball(archive, out_dir, ensure_has_files, None)
401
    elif archive.endswith(".tar.gz"):
402
        # gzipped tarball
403
        result = _extract_tarball(archive, out_dir, ensure_has_files, "gz")
404
    elif archive.endswith(".tar.bz2"):
405
        # bzipped tarball
406
        result = _extract_tarball(archive, out_dir, ensure_has_files, "bz2")
407
    elif archive.endswith(".rpm"):
408
        # RPM
409
        result = _extract_rpm(archive, out_dir, ensure_has_files)
410
    # elif other types of archives
411
    else:
412
        raise ExtractionError("Unsuported archive type")
413
    log.info("OSCAP addon: Extracted {files} from the supplied content"
414
             .format(files=result))
415
    return result
416
417
418
def _extract_tarball(archive, out_dir, ensure_has_files, alg):
419
    """
420
    Extract the given TAR archive to the given output directory and make sure
421
    the given file exists in the archive.
422
423
    :see: extract_data
424
    :param alg: compression algorithm used for the tarball
425
    :type alg: str (one of "gz", "bz2") or None
426
    :return: a list of files and directories extracted from the archive
427
    :rtype: [str]
428
429
    """
430
431
    if alg and alg not in ("gz", "bz2",):
432
        raise ExtractionError("Unsupported compression algorithm")
433
434
    mode = "r"
435
    if alg:
436
        mode += ":%s" % alg
437
438
    try:
439
        tfile = tarfile.TarFile.open(archive, mode)
440
    except tarfile.TarError as err:
441
        raise ExtractionError(str(err))
442
443
    # generator for the paths of the files found in the archive
444
    files = set(member.path for member in tfile.getmembers()
445
                if member.isfile())
446
447
    for fpath in ensure_has_files or ():
448
        if fpath not in files:
449
            msg = "File '%s' not found in the archive '%s'" % (fpath, archive)
450
            raise ExtractionError(msg)
451
452
    utils.ensure_dir_exists(out_dir)
453
    tfile.extractall(path=out_dir)
454
    result = [utils.join_paths(out_dir, member.path) for member in tfile.getmembers()]
455
    tfile.close()
456
457
    return result
458
459
460
def _extract_rpm(rpm_path, root="/", ensure_has_files=None):
461
    """
462
    Extract the given RPM into the directory tree given by the root argument
463
    and make sure the given file exists in the archive.
464
465
    :param rpm_path: path to the RPM file that should be extracted
466
    :type rpm_path: str
467
    :param root: root of the directory tree the RPM should be extracted into
468
    :type root: str
469
    :param ensure_has_files: relative paths to the files that must exist in the
470
                             RPM
471
    :type ensure_has_files: iterable of strings or None
472
    :return: a list of files and directories extracted from the archive
473
    :rtype: [str]
474
475
    """
476
477
    # run rpm2cpio and process the output with the cpioarchive module
478
    temp_fd, temp_path = tempfile.mkstemp(prefix="oscap_rpm")
479
    proc = subprocess.Popen(["rpm2cpio", rpm_path], stdout=temp_fd)
480
    proc.wait()
481
    if proc.returncode != 0:
482
        msg = "Failed to convert RPM '%s' to cpio archive" % rpm_path
483
        raise ExtractionError(msg)
484
485
    os.close(temp_fd)
486
487
    try:
488
        archive = cpioarchive.CpioArchive(temp_path)
489
    except cpioarchive.CpioError as err:
490
        raise ExtractionError(str(err))
491
492
    # get entries from the archive (supports only iteration over entries)
493
    entries = set(entry for entry in archive)
494
495
    # cpio entry names (paths) start with the dot
496
    entry_names = [entry.name.lstrip(".") for entry in entries]
497
498
    for fpath in ensure_has_files or ():
499
        # RPM->cpio entries have absolute paths
500
        if fpath not in entry_names and \
501
           os.path.join("/", fpath) not in entry_names:
502
            msg = "File '%s' not found in the archive '%s'" % (fpath, rpm_path)
503
            raise ExtractionError(msg)
504
505
    try:
506
        for entry in entries:
507
            if entry.size == 0:
508
                continue
509
            dirname = os.path.dirname(entry.name.lstrip("."))
510
            out_dir = os.path.normpath(root + dirname)
511
            utils.ensure_dir_exists(out_dir)
512
513
            out_fpath = os.path.normpath(root + entry.name.lstrip("."))
514
            if os.path.exists(out_fpath):
515
                continue
516
            with open(out_fpath, "wb") as out_file:
517
                buf = entry.read(IO_BUF_SIZE)
518
                while buf:
519
                    out_file.write(buf)
520
                    buf = entry.read(IO_BUF_SIZE)
521
    except (IOError, cpioarchive.CpioError) as e:
522
        raise ExtractionError(e)
523
524
    # cleanup
525
    archive.close()
526
    os.unlink(temp_path)
527
528
    return [os.path.normpath(root + name) for name in entry_names]
529
530
531
def strip_content_dir(fpaths, phase="preinst"):
532
    """
533
    Strip content directory prefix from the file paths for either
534
    pre-installation or post-installation phase.
535
536
    :param fpaths: iterable of file paths to strip content directory prefix
537
                   from
538
    :type fpaths: iterable of strings
539
    :param phase: specifies pre-installation or post-installation phase
540
    :type phase: "preinst" or "postinst"
541
    :return: the same iterable of file paths as given with the content
542
             directory prefix stripped
543
    :rtype: same type as fpaths
544
545
    """
546
547
    if phase == "preinst":
548
        remove_prefix = lambda x: x[len(INSTALLATION_CONTENT_DIR):]
549
    else:
550
        remove_prefix = lambda x: x[len(TARGET_CONTENT_DIR):]
551
552
    return utils.keep_type_map(remove_prefix, fpaths)
553
554
555
def get_ssg_path(root="/"):
556
    return utils.join_paths(root, SSG_DIR + SSG_CONTENT)
557
558
559
def ssg_available(root="/"):
560
    """
561
    Tries to find the SCAP Security Guide under the given root.
562
563
    :return: True if SSG was found under the given root, False otherwise
564
565
    """
566
567
    return os.path.exists(get_ssg_path(root))
568
569
570
def get_content_name(data):
571
    if data.content_type == "scap-security-guide":
572
        raise ValueError("Using scap-security-guide, no single content file")
573
574
    rest = "/anonymous_content"
575
    for prefix in SUPPORTED_URL_PREFIXES:
576
        if data.content_url.startswith(prefix):
577
            rest = data.content_url[len(prefix):]
578
            break
579
580
    parts = rest.rsplit("/", 1)
581
    if len(parts) != 2:
582
        raise ValueError("Unsupported url '%s'" % data.content_url)
583
584
    return parts[1]
585
586
587
def get_raw_preinst_content_path(data):
588
    """Path to the raw (unextracted, ...) pre-installation content file"""
589
    if data.content_type == "scap-security-guide":
590
        log.debug("OSCAP addon: Using scap-security-guide, no single content file")
591
        return None
592
593
    content_name = get_content_name(data)
594
    return utils.join_paths(INSTALLATION_CONTENT_DIR, content_name)
595
596
597
def get_preinst_content_path(data):
598
    """Path to the pre-installation content file"""
599
    if data.content_type == "scap-security-guide":
600
        # SSG is not copied to the standard place
601
        return data.content_path
602
603
    if data.content_type == "datastream":
604
        return get_raw_preinst_content_path(data)
605
606
    return utils.join_paths(
607
        INSTALLATION_CONTENT_DIR,
608
        data.content_path
609
    )
610
611
612
def get_postinst_content_path(data):
613
    """Path to the post-installation content file"""
614
    if data.content_type == "datastream":
615
        return utils.join_paths(
616
            TARGET_CONTENT_DIR,
617
            get_content_name(data)
618
        )
619
620
    if data.content_type in ("rpm", "scap-security-guide"):
621
        # no path magic in case of RPM (SSG is installed as an RPM)
622
        return data.content_path
623
624
    return utils.join_paths(
625
        TARGET_CONTENT_DIR,
626
        data.content_path
627
    )
628
629
630
def get_preinst_tailoring_path(data):
631
    """Path to the pre-installation tailoring file (if any)"""
632
    if not data.tailoring_path:
633
        return ""
634
635
    return utils.join_paths(
636
        INSTALLATION_CONTENT_DIR,
637
        data.tailoring_path
638
    )
639
640
641
def get_postinst_tailoring_path(data):
642
    """Path to the post-installation tailoring file (if any)"""
643
    if not data.tailoring_path:
644
        return ""
645
646
    if data.content_type == "rpm":
647
        # no path magic in case of RPM
648
        return data.tailoring_path
649
650
    return utils.join_paths(
651
        TARGET_CONTENT_DIR,
652
        data.tailoring_path
653
    )
654
655
656
def get_payload_proxy():
657
    """Get the DBus proxy of the active payload.
658
659
    :return: a DBus proxy
660
    """
661
    payloads_proxy = PAYLOADS.get_proxy()
662
    object_path = payloads_proxy.ActivePayload
663
664
    if not object_path:
665
        raise ValueError("Active payload is not set.")
666
667
    return PAYLOADS.get_proxy(object_path)
668
669
670
def get_packages_data() -> PackagesSelectionData:
671
    """Get the DBus data with the packages configuration.
672
673
    :return: a packages configuration
674
    """
675
    payload_proxy = get_payload_proxy()
676
677
    if payload_proxy.Type != PAYLOAD_TYPE_DNF:
678
        return PackagesSelectionData()
679
680
    return PackagesSelectionData.from_structure(
681
        payload_proxy.PackagesSelection
682
    )
683
684
685
def set_packages_data(data: PackagesSelectionData):
686
    """Set the DBus data with the packages configuration.
687
688
    :param data: a packages configuration
689
    """
690
    payload_proxy = get_payload_proxy()
691
692
    if payload_proxy.Type != PAYLOAD_TYPE_DNF:
693
        log.debug("OSCAP addon: The payload doesn't support packages.")
694
        return
695
696
    return payload_proxy.SetPackagesSelection(
697
        PackagesSelectionData.to_structure(data)
698
    )
699