diff options
author | Martin Sivak <msivak@redhat.com> | 2010-08-25 18:10:02 +0200 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2010-08-25 18:10:02 +0200 |
commit | 49d1764a44326c6708be65d21f3e41e6452eeaec (patch) | |
tree | 41c80a73dd965f065a4f4f30d552095e6395d41f | |
parent | ce3ed375301f70a15f974780876f8e11a0909b8e (diff) | |
download | firstaidkit-49d1764a44326c6708be65d21f3e41e6452eeaec.tar.gz firstaidkit-49d1764a44326c6708be65d21f3e41e6452eeaec.tar.xz firstaidkit-49d1764a44326c6708be65d21f3e41e6452eeaec.zip |
OpenSCAP plugin is able to select tests to run
-rw-r--r-- | plugins/openscap_plugin.py | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/plugins/openscap_plugin.py b/plugins/openscap_plugin.py index 7e93a30..c5f23f5 100644 --- a/plugins/openscap_plugin.py +++ b/plugins/openscap_plugin.py @@ -57,13 +57,37 @@ class OpenSCAPPlugin(Plugin): else: self._reporting.info("OpenSCAP initialized", origin = self, level = PLUGIN) + all_rules = self._policy.get_rules() + preprocess_rules = lambda x: (x.item, + self._policy.model.benchmark.get_item(x.item).title[0].text, + x.selected and 1 or 0, + self._policy.model.benchmark.get_item(x.item).description[0].text, + "0|1", + "Use 0 or 1 to disable or enable rule" + ) + all_rules = map(preprocess_rules, all_rules) + s = self._reporting.config_question_wait("Setup OpenScap rules", + "Enable or disable rules and press OK", + all_rules, origin = self, + level = PLUGIN) + enabled_rules = [] + for r in s: + if r[1] == "1": + enabled_rules.append(r[0]) + self._reporting.info("Enabled rules: %s" % repr(enabled_rules), origin = self, + level = PLUGIN) + + self._policy.set_rules(enabled_rules) + tailor_items = self._policy.get_tailor_items() - preproces_tailor_items = lambda i: (i["id"], i["titles"][0][1] or "", i["selected"][1] or "", len(i["descs"]) and i["descs"][0][1] or "") + preproces_tailor_items = lambda i: (i["id"], + i["titles"][i["lang"]] or "", + i["selected"][1] or "", + i["descs"][i["lang"]] or "", + i["match"] or ".*", + "Error setting the value, read the following description and try again:\n\n"+i["descs"][i["lang"]]) tailor_items = map(preproces_tailor_items, tailor_items) - self._reporting.info("Pre Options: %s" % repr(tailor_items), origin = self, - level = PLUGIN) - s = self._reporting.config_question_wait("Setup OpenScap policy", "Set preferred values and press OK", tailor_items, origin = self, @@ -71,11 +95,9 @@ class OpenSCAPPlugin(Plugin): preprocess_s = lambda v: {"id": v[0], "value": v[1]} s = map(preprocess_s, s) - self._reporting.info("Options: %s" % repr(s), origin = self, - level = PLUGIN) self._policy.set_tailor_items(s) - + self._reporting.info("Tailoring Done", origin = self, level = PLUGIN) self._result=ReturnSuccess def backup(self): @@ -103,6 +125,7 @@ class OpenSCAPPlugin(Plugin): origin = Plugin, level = PLUGIN) except Exception, e: + raise print e if Plugin.continuing(): @@ -111,6 +134,11 @@ class OpenSCAPPlugin(Plugin): return 1 def diagnose(self): + for x in self._policy.get_selected_rules(): + self._reporting.info("Selecting rule "+x.item, origin = self, level = PLUGIN) + + self._reporting.info("Starting OpenSCAP evaluation", origin = self, level = PLUGIN) + self._policy.model.benchmark.export("lala.xml") self._policy.evaluate() self._result=ReturnSuccess |