[Oval-commits] r97 - in trunk/tools: . oval/definition
Pavel Vinogradov
blaze-guest at alioth.debian.org
Thu Aug 2 17:36:25 UTC 2007
Author: blaze-guest
Date: 2007-08-02 17:36:25 +0000 (Thu, 02 Aug 2007)
New Revision: 97
Modified:
trunk/tools/TODO
trunk/tools/oval/definition/generator.py
Log:
Fix generation of architecture tests. Update TODO.
Modified: trunk/tools/TODO
===================================================================
--- trunk/tools/TODO 2007-08-02 08:16:45 UTC (rev 96)
+++ trunk/tools/TODO 2007-08-02 17:36:25 UTC (rev 97)
@@ -1,9 +1,12 @@
-General:
+Summer:
+ Update uname architecture mappings
+ Build debian package
+ Refactoring and optimization of source code
+
+Later:
Rewrite structure for represent DSA information. (dict to class)
-
-Future:
- General
- Full refactoring of project source code
-
+ Full refactoring of project source code
+ Extract brief description from wml file.
+
oval/parser/wml.py
Save html tags instead of omit them
\ No newline at end of file
Modified: trunk/tools/oval/definition/generator.py
===================================================================
--- trunk/tools/oval/definition/generator.py 2007-08-02 08:16:45 UTC (rev 96)
+++ trunk/tools/oval/definition/generator.py 2007-08-02 17:36:25 UTC (rev 97)
@@ -56,7 +56,7 @@
statesCurId = 1
releaseArchHash = {"2.0" : 2, "2.1" : 4, "2.2": 6, "3.0" : 11, "3.1" : 12, "4.0" : 11}
-testsHash = {"arch" : {}, "release": {}, "obj": {}, "fileSte": {}, "dpkgSte": {}}
+testsHash = {"arch" : {}, "release": {}, "obj": {}, "fileSte": {}, "unameSte" : {}, "dpkgSte": {}}
def __trimzero (val):
value = val[:]
@@ -123,6 +123,22 @@
return (testsHash["obj"][name])
+def __createOVALUnameObject ():
+ """ Generate OVAL textfilecontent_object definition """
+ name = "uname_object"
+
+ if not testsHash["obj"].has_key(name):
+ objectId = __getNewId ("object");
+ object = __createXMLElement("uname_object",
+ attrs={"id":objectId,
+ "version":"1",
+ "xmlns":"http://oval.mitre.org/XMLSchema/oval-definitions-5#unix"})
+ objects.appendChild (object)
+
+ testsHash["obj"][name] = objectId
+
+ return (testsHash["obj"][name])
+
def __createOVALState (value, operation = "less than"):
""" Generate OVAL state definition
@@ -136,7 +152,7 @@
attrs={"id":stateId,
"version":"1",
"xmlns":"http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"})
- state.appendChild ( __createXMLElement ("evr", value,
+ state.appendChild ( __createXMLElement ("evr", "0:"+value,
{"datatype":"evr_string",
"operation":operation}))
states.appendChild (state)
@@ -145,6 +161,31 @@
return (testsHash["dpkgSte"][operation][value])
+def __createOVALUnameState (field, value, operation = "equals"):
+ """ Generate OVAL state definition
+
+ Use state hash for optimization of resulted XML
+ """
+
+ if value == "i386":
+ value = "i686"
+
+ #TODO: Add arch state generation
+ if not testsHash["unameSte"].has_key(operation) or not testsHash["unameSte"][operation].has_key(value):
+ stateId = __getNewId ("state")
+
+ state = __createXMLElement("uname_state",
+ attrs={"id":stateId,
+ "version":"1",
+ "xmlns":"http://oval.mitre.org/XMLSchema/oval-definitions-5#unix"})
+ state.appendChild ( __createXMLElement (field, value,
+ {"operation":operation}))
+ states.appendChild (state)
+
+ testsHash["unameSte"][operation] = {value : stateId}
+
+ return (testsHash["unameSte"][operation][value])
+
def __createOVALTextfilecontentState (value, operation = "equals"):
""" Generate OVAL state definition
@@ -183,9 +224,6 @@
tests.appendChild(test)
return (ref)
-
-def __createArchTest (arch, packages):
- ref = __getNewId("test")
def __createTest(testType, value):
""" Generate OVAL test for release or architecture cases"""
@@ -211,19 +249,19 @@
test.appendChild ( __createXMLElement("state", attrs={"state_ref" : __createOVALTextfilecontentState (value, "equals")}))
else:
- objectId = __createOVALDpkginfoObject ("architecture")
+ objectId = __createOVALUnameObject ()
comment = "Installed architecture is %s" % value
- test = __createXMLElement("dpkginfo_test",
+ test = __createXMLElement("uname_test",
attrs={"id":ref,
"version":"1",
"check":"all",
"check_existence":"at_least_one_exists",
"comment":comment,
- "xmlns":"http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"
+ "xmlns":"http://oval.mitre.org/XMLSchema/oval-definitions-5#unix"
})
test.appendChild ( __createXMLElement("object", attrs={"object_ref" : objectId}))
- test.appendChild ( __createXMLElement("state", attrs={"state_ref" : __createOVALState (value, "equals")}))
+ test.appendChild ( __createXMLElement("state", attrs={"state_ref" : __createOVALUnameState ("processor_type", value, "equals")}))
tests.appendChild(test)
More information about the Oval-commits
mailing list