You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Copyright (c) 2010 United States Government. All Rights Reserved.
3
+
4
+
# Redistribution and use in source and binary forms, with or without
5
+
# modification, are permitted provided that the following conditions are met:
6
+
#
7
+
# * Redistributions of source code must retain the above copyright notice, this
8
+
# list of conditions and the following disclaimer.
9
+
#
10
+
# * Redistributions in binary form must reproduce the above copyright notice, this
11
+
# list of conditions and the following disclaimer in the documentation and/or
12
+
# other materials provided with the distribution.
13
+
#
14
+
# * Neither the name of the Center for Internet Security, Inc. (CIS) nor the names
15
+
# of its contributors may be used to endorse or promote products derived from
16
+
# this software without specific prior written permission.
17
+
18
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, CIS AND CONTRIBUTORS "AS
19
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, CIS OR CONTRIBUTORS BE
22
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+
# POSSIBILITY OF SUCH DAMAGE.
3
29
4
-
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
-
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
# * Neither the name of the Center for Internet Security, Inc. (CIS) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
-
10
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, CIS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, CIS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
30
"""Library to simplify working with the OVAL XML structure
12
31
13
32
@@ -39,29 +58,29 @@
39
58
40
59
1. Create an OvalDocument:
41
60
42
-
>> tree = ElementTree()
43
-
>> tree.parse("OvalTest.xml")
44
-
>> document = OvalDocument(tree)
61
+
>>> tree = ElementTree()
62
+
>>> tree.parse("OvalTest.xml")
63
+
>>> document = OvalDocument(tree)
45
64
46
65
2. Find an oval element within the loaded document:
47
66
48
-
>> element = document.getElementByID("oval:org.mitre.oval:def:22382")
49
-
>> if element is not None:
50
-
>> ....
67
+
>>> element = document.getElementByID("oval:org.mitre.oval:def:22382")
68
+
>>> if element is not None:
69
+
>>> ....
51
70
52
71
3. Read an XML file with a single OVAL Definition (error checking omitted for brevity):
53
72
54
-
>> tree = ElementTree()
55
-
>> tree.parse('test-definition.xml')
56
-
>> root = tree.getroot()
57
-
>> definition = lib_oval.OvalDefinition(root)
73
+
>>> tree = ElementTree()
74
+
>>> tree.parse('test-definition.xml')
75
+
>>> root = tree.getroot()
76
+
>>> definition = lib_oval.OvalDefinition(root)
58
77
59
78
4. Change information in the definition from #3 and write the changes
Copyright (c) 2010 United States Government. All Rights Reserved.
2
2
3
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+
Redistribution and use in source and binary forms, with or without modification,
4
+
are permitted provided that the following conditions are met:
4
5
5
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7
-
Neither the name of the Center for Internet Security, Inc. (CIS) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
6
+
Redistributions of source code must retain the above copyright notice, this
7
+
list of conditions and the following disclaimer.
8
8
9
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, CIS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, CIS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+
Redistributions in binary form must reproduce the above copyright notice,
10
+
this list of conditions and the following disclaimer in the documentation
11
+
and/or other materials provided with the distribution.
12
+
13
+
Neither the name of the Center for Internet Security, Inc. (CIS) nor the
14
+
names of its contributors may be used to endorse or promote products derived
15
+
from this software without specific prior written permission.
16
+
17
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, CIS AND CONTRIBUTORS "AS IS"
18
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, CIS OR CONTRIBUTORS BE LIABLE
21
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 commit comments