backend/server/action_extra_data/scap.py | 3 ---
client/rhel/spacewalk-oscap/scap.py | 15 ++++++---------
2 files changed, 6 insertions(+), 12 deletions(-)
New commits:
commit 1a2f2ebff0a5f69337d718c81e32101ee7861dcc
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Feb 28 16:30:11 2012 +0100
Do not unlink file, tempfile will do that automatically.
Enforce destructor instead.
Addressing:
Exception exceptions.OSError: (2, 'No such file or directory',
'/tmp/tmpRNALDd') in <bound method _TemporaryFileWrapper.__del__ of <closed
file '<fdopen>', mode 'w+b' at 0x9c07ba8>> ignored
diff --git a/client/rhel/spacewalk-oscap/scap.py b/client/rhel/spacewalk-oscap/scap.py
index d9994f9..ec93248 100644
--- a/client/rhel/spacewalk-oscap/scap.py
+++ b/client/rhel/spacewalk-oscap/scap.py
@@ -1,5 +1,4 @@
-import os
import sys
import subprocess
import xml.sax
@@ -23,7 +22,7 @@ def xccdf_eval(args, cache_only=None):
return (1, 'oscap tool did not produce valid xml.', {})
ret, resume, xslt_err = _xccdf_resume(results_file.name)
- os.unlink(results_file.name)
+ del(results_file)
if ret != 0 or resume == '':
return (1, 'Problems with extracting resume:\n' + xslt_err, {})
return (0, 'openscap scan completed', {
commit 43ed18ffc829a7dbf791d18f45e043ff5e664a0a
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Feb 28 16:16:08 2012 +0100
This module is not supposed to be used as a stand-alone script.
diff --git a/client/rhel/spacewalk-oscap/scap.py b/client/rhel/spacewalk-oscap/scap.py
index 773a7b8..d9994f9 100644
--- a/client/rhel/spacewalk-oscap/scap.py
+++ b/client/rhel/spacewalk-oscap/scap.py
@@ -66,8 +66,3 @@ def _assert_xml(filename):
finally:
f.close()
-if __name__ == "__main__":
- print xccdf_eval({
- 'params': '--profile
united_states_government_configuration_baseline',
- 'path': 'usgcb-rhel5desktop-xccdf.xml'
- })
commit 4be31138685e1d0f36a556d70048b1c88ecadb77
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Feb 28 16:03:59 2012 +0100
Do submit empty dict, when something goes wrong
Addressing:
Traceback (most recent call last):
File "/usr/sbin/rhn_check", line 332, in __run_action
(status, message, data) = CheckCli.__do_call(method, params, kwargs)
exceptions.ValueError: need more than 2 values to unpack
diff --git a/client/rhel/spacewalk-oscap/scap.py b/client/rhel/spacewalk-oscap/scap.py
index c363822..773a7b8 100644
--- a/client/rhel/spacewalk-oscap/scap.py
+++ b/client/rhel/spacewalk-oscap/scap.py
@@ -20,7 +20,7 @@ def xccdf_eval(args, cache_only=None):
oscap_err = _run_oscap(['xccdf', 'eval', '--results',
results_file.name]
+ args['params'].split(' ') + [args['path']])
if not _assert_xml(results_file.name):
- return (1, 'oscap tool did not produce valid xml.')
+ return (1, 'oscap tool did not produce valid xml.', {})
ret, resume, xslt_err = _xccdf_resume(results_file.name)
os.unlink(results_file.name)
commit 34cc72c081ea9b0d151a5fb74ab2f22d0f14cd20
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Feb 28 15:39:47 2012 +0100
Fix syntax for python 2.4
Addressing:
File "scap.py", line 59
with open(filename, 'rb') as f:
^
SyntaxError: invalid syntax
Python 2.4 does not even support except and finally
clauses in a single statement.
diff --git a/client/rhel/spacewalk-oscap/scap.py b/client/rhel/spacewalk-oscap/scap.py
index 55ba2a1..c363822 100644
--- a/client/rhel/spacewalk-oscap/scap.py
+++ b/client/rhel/spacewalk-oscap/scap.py
@@ -56,12 +56,15 @@ def _popen(args):
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
def _assert_xml(filename):
- with open(filename, 'rb') as f:
+ f = open(filename, 'rb')
+ try:
try:
xml.sax.parse(f, xml.sax.ContentHandler())
return True
except:
return False
+ finally:
+ f.close()
if __name__ == "__main__":
print xccdf_eval({
commit 713168a8804fc01afd82cdaa45812ee3274fac17
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Feb 28 14:47:49 2012 +0100
Remove unstructured debugging outputs.
diff --git a/backend/server/action_extra_data/scap.py
b/backend/server/action_extra_data/scap.py
index 956a946..950af08 100644
--- a/backend/server/action_extra_data/scap.py
+++ b/backend/server/action_extra_data/scap.py
@@ -75,9 +75,6 @@ def _process_ruleresults(testresult_id, tr):
inserts['system'].append(ident.getAttribute('system'))
inserts['ident'].append(_get_text(ident))
inserts['type'].append(rule_result.nodeName)
- log_error(inserts)
- for i in ['tr_id', 'system', 'ident', 'type']:
- log_error(i, len(inserts[i]))
_store_ruleresults(inserts)
def _store_ruleresults(data):