Passed
Pull Request — rhel8-branch (#178)
by Matěj
01:59
created

org_fedora_oscap.structures.PolicyData.__init__()   A

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nop 1
dl 0
loc 12
rs 9.85
c 0
b 0
f 0
1
#
2
# Copyright (C) 2020  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
from dasbus.structure import DBusData
19
from dasbus.typing import *  # pylint: disable=wildcard-import
20
21
__all__ = ["PolicyData"]
22
23
24
class PolicyData(DBusData):
25
    """The security policy data."""
26
27
    def __init__(self):
28
        # values specifying the content
29
        self._content_type = ""
30
        self._content_url = ""
31
        self._datastream_id = ""
32
        self._xccdf_id = ""
33
        self._profile_id = ""
34
        self._content_path = ""
35
        self._cpe_path = ""
36
        self._tailoring_path = ""
37
        self._fingerprint = ""
38
        self._certificates = ""
39
40
    def update_from(self, rhs):
41
        self._content_type = rhs._content_type
42
        self._content_url = rhs._content_url
43
        self._datastream_id = rhs._datastream_id
44
        self._xccdf_id = rhs._xccdf_id
45
        self._profile_id = rhs._profile_id
46
        self._content_path = rhs._content_path
47
        self._cpe_path = rhs._cpe_path
48
        self._tailoring_path = rhs._tailoring_path
49
        self._fingerprint = rhs._fingerprint
50
        self._certificates = rhs._certificates
51
52
    @property
53
    def content_type(self) -> Str:
54
        """Type of the security content.
55
56
        If the content type is scap-security-guide, the add-on
57
        will use content provided by the scap-security-guide.
58
        All other attributes except profile will have no effect.
59
60
        Supported values:
61
62
            datastream
63
            archive
64
            rpm
65
            scap-security-guide
66
67
        :return: a string
68
        """
69
        return self._content_type
70
71
    @content_type.setter
72
    def content_type(self, value: Str):
73
        self._content_type = value
74
75
    @property
76
    def content_url(self) -> Str:
77
        """Location of the security content.
78
79
         So far only http, https, and ftp URLs are supported.
80
81
        :return: an URL
82
        """
83
        return self._content_url
84
85
    @content_url.setter
86
    def content_url(self, value: Str):
87
        self._content_url = value
88
89
    @property
90
    def datastream_id(self) -> Str:
91
        """ID of the data stream.
92
93
        It is an ID of the data stream from a datastream
94
        collection referenced by the content url. Used only
95
        if the content type is datastream.
96
97
        :return: a string
98
        """
99
        return self._datastream_id
100
101
    @datastream_id.setter
102
    def datastream_id(self, value: Str):
103
        self._datastream_id = value
104
105
    @property
106
    def xccdf_id(self) -> Str:
107
        """ID of the benchmark that should be used.
108
109
        :return: a string
110
        """
111
        return self._xccdf_id
112
113
    @xccdf_id.setter
114
    def xccdf_id(self, value: Str):
115
        self._xccdf_id = value
116
117
    @property
118
    def profile_id(self) -> Str:
119
        """ID of the profile that should be applied.
120
121
        Use 'default' if the default profile should be used.
122
123
        :return: a string
124
        """
125
        return self._profile_id
126
127
    @profile_id.setter
128
    def profile_id(self, value: Str):
129
        self._profile_id = value
130
131
    @property
132
    def content_path(self) -> Str:
133
        """Path to the datastream or the XCCDF file which should be used.
134
135
        :return: a relative path in the archive
136
        """
137
        return self._content_path
138
139
    @content_path.setter
140
    def content_path(self, value: Str):
141
        self._content_path = value
142
143
    @property
144
    def cpe_path(self) -> Str:
145
        """Path to the datastream or the XCCDF file that should be used.
146
147
        :return: a relative path in the archive
148
        """
149
        return self._cpe_path
150
151
    @cpe_path.setter
152
    def cpe_path(self, value: Str):
153
        self._cpe_path = value
154
155
    @property
156
    def tailoring_path(self) -> Str:
157
        """Path of the tailoring file that should be used.
158
159
        :return: a relative path in the archive
160
        """
161
        return self._tailoring_path
162
163
    @tailoring_path.setter
164
    def tailoring_path(self, value: Str):
165
        self._tailoring_path = value
166
167
    @property
168
    def fingerprint(self) -> Str:
169
        """Checksum of the security content.
170
171
        It is an MD5, SHA1 or SHA2 fingerprint/hash/checksum
172
        of the content referred by the content url.
173
174
        :return: a string
175
        """
176
        return self._fingerprint
177
178
    @fingerprint.setter
179
    def fingerprint(self, value: Str):
180
        self._fingerprint = value
181
182
    @property
183
    def certificates(self) -> Str:
184
        """Path to a PEM file with CA certificate chain.
185
186
        :return: a path
187
        """
188
        return self._certificates
189
190
    @certificates.setter
191
    def certificates(self, value: Str):
192
        self._certificates = value
193