|
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
|
|
|
@property |
|
41
|
|
|
def content_type(self) -> Str: |
|
42
|
|
|
"""Type of the security content. |
|
43
|
|
|
|
|
44
|
|
|
If the content type is scap-security-guide, the add-on |
|
45
|
|
|
will use content provided by the scap-security-guide. |
|
46
|
|
|
All other attributes except profile will have no effect. |
|
47
|
|
|
|
|
48
|
|
|
Supported values: |
|
49
|
|
|
|
|
50
|
|
|
datastream |
|
51
|
|
|
archive |
|
52
|
|
|
rpm |
|
53
|
|
|
scap-security-guide |
|
54
|
|
|
|
|
55
|
|
|
:return: a string |
|
56
|
|
|
""" |
|
57
|
|
|
return self._content_type |
|
58
|
|
|
|
|
59
|
|
|
@content_type.setter |
|
60
|
|
|
def content_type(self, value: Str): |
|
61
|
|
|
self._content_type = value |
|
62
|
|
|
|
|
63
|
|
|
@property |
|
64
|
|
|
def content_url(self) -> Str: |
|
65
|
|
|
"""Location of the security content. |
|
66
|
|
|
|
|
67
|
|
|
So far only http, https, and ftp URLs are supported. |
|
68
|
|
|
|
|
69
|
|
|
:return: an URL |
|
70
|
|
|
""" |
|
71
|
|
|
return self._content_url |
|
72
|
|
|
|
|
73
|
|
|
@content_url.setter |
|
74
|
|
|
def content_url(self, value: Str): |
|
75
|
|
|
self._content_url = value |
|
76
|
|
|
|
|
77
|
|
|
@property |
|
78
|
|
|
def datastream_id(self) -> Str: |
|
79
|
|
|
"""ID of the data stream. |
|
80
|
|
|
|
|
81
|
|
|
It is an ID of the data stream from a datastream |
|
82
|
|
|
collection referenced by the content url. Used only |
|
83
|
|
|
if the content type is datastream. |
|
84
|
|
|
|
|
85
|
|
|
:return: a string |
|
86
|
|
|
""" |
|
87
|
|
|
return self._datastream_id |
|
88
|
|
|
|
|
89
|
|
|
@datastream_id.setter |
|
90
|
|
|
def datastream_id(self, value: Str): |
|
91
|
|
|
self._datastream_id = value |
|
92
|
|
|
|
|
93
|
|
|
@property |
|
94
|
|
|
def xccdf_id(self) -> Str: |
|
95
|
|
|
"""ID of the benchmark that should be used. |
|
96
|
|
|
|
|
97
|
|
|
:return: a string |
|
98
|
|
|
""" |
|
99
|
|
|
return self._xccdf_id |
|
100
|
|
|
|
|
101
|
|
|
@xccdf_id.setter |
|
102
|
|
|
def xccdf_id(self, value: Str): |
|
103
|
|
|
self._xccdf_id = value |
|
104
|
|
|
|
|
105
|
|
|
@property |
|
106
|
|
|
def profile_id(self) -> Str: |
|
107
|
|
|
"""ID of the profile that should be applied. |
|
108
|
|
|
|
|
109
|
|
|
Use 'default' if the default profile should be used. |
|
110
|
|
|
|
|
111
|
|
|
:return: a string |
|
112
|
|
|
""" |
|
113
|
|
|
return self._profile_id |
|
114
|
|
|
|
|
115
|
|
|
@profile_id.setter |
|
116
|
|
|
def profile_id(self, value: Str): |
|
117
|
|
|
self._profile_id = value |
|
118
|
|
|
|
|
119
|
|
|
@property |
|
120
|
|
|
def content_path(self) -> Str: |
|
121
|
|
|
"""Path to the datastream or the XCCDF file which should be used. |
|
122
|
|
|
|
|
123
|
|
|
:return: a relative path in the archive |
|
124
|
|
|
""" |
|
125
|
|
|
return self._content_path |
|
126
|
|
|
|
|
127
|
|
|
@content_path.setter |
|
128
|
|
|
def content_path(self, value: Str): |
|
129
|
|
|
self._content_path = value |
|
130
|
|
|
|
|
131
|
|
|
@property |
|
132
|
|
|
def cpe_path(self) -> Str: |
|
133
|
|
|
"""Path to the datastream or the XCCDF file that should be used. |
|
134
|
|
|
|
|
135
|
|
|
:return: a relative path in the archive |
|
136
|
|
|
""" |
|
137
|
|
|
return self._cpe_path |
|
138
|
|
|
|
|
139
|
|
|
@cpe_path.setter |
|
140
|
|
|
def cpe_path(self, value: Str): |
|
141
|
|
|
self._cpe_path = value |
|
142
|
|
|
|
|
143
|
|
|
@property |
|
144
|
|
|
def tailoring_path(self) -> Str: |
|
145
|
|
|
"""Path of the tailoring file that should be used. |
|
146
|
|
|
|
|
147
|
|
|
:return: a relative path in the archive |
|
148
|
|
|
""" |
|
149
|
|
|
return self._tailoring_path |
|
150
|
|
|
|
|
151
|
|
|
@tailoring_path.setter |
|
152
|
|
|
def tailoring_path(self, value: Str): |
|
153
|
|
|
self._tailoring_path = value |
|
154
|
|
|
|
|
155
|
|
|
@property |
|
156
|
|
|
def fingerprint(self) -> Str: |
|
157
|
|
|
"""Checksum of the security content. |
|
158
|
|
|
|
|
159
|
|
|
It is an MD5, SHA1 or SHA2 fingerprint/hash/checksum |
|
160
|
|
|
of the content referred by the content url. |
|
161
|
|
|
|
|
162
|
|
|
:return: a string |
|
163
|
|
|
""" |
|
164
|
|
|
return self._fingerprint |
|
165
|
|
|
|
|
166
|
|
|
@fingerprint.setter |
|
167
|
|
|
def fingerprint(self, value: Str): |
|
168
|
|
|
self._fingerprint = value |
|
169
|
|
|
|
|
170
|
|
|
@property |
|
171
|
|
|
def certificates(self) -> Str: |
|
172
|
|
|
"""Path to a PEM file with CA certificate chain. |
|
173
|
|
|
|
|
174
|
|
|
:return: a path |
|
175
|
|
|
""" |
|
176
|
|
|
return self._certificates |
|
177
|
|
|
|
|
178
|
|
|
@certificates.setter |
|
179
|
|
|
def certificates(self, value: Str): |
|
180
|
|
|
self._certificates = value |
|
181
|
|
|
|