Passed
Pull Request — rawhide (#242)
by Jan
02:08
created

org_fedora_oscap.structures.PolicyData.clear_all()   A

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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