rel-eng/packages/spacecmd | 2
spacecmd/spacecmd.spec | 13 ++-
spacecmd/src/lib/scap.py | 158 ++++++++++++++++++++++++++++++++++++++++++++++
spacecmd/src/lib/shell.py | 2
4 files changed, 170 insertions(+), 5 deletions(-)
New commits:
commit e33b95c87db52865dd6fce68c1137e801602f97f
Author: Tomas Kasparek <tkasparek(a)redhat.com>
Date: Tue Aug 6 11:33:53 2013 +0200
Automatic commit of package [spacecmd] release [2.1.3-1].
diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index c88f653..d9f9424 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-2.1.2-1 spacecmd/
+2.1.3-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index ecb6b23..960c1f9 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
%endif
Name: spacecmd
-Version: 2.1.2
+Version: 2.1.3
Release: 1%{?dist}
Summary: Command-line interface to Spacewalk and Satellite servers
@@ -64,8 +64,15 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
-* Mon Aug 05 2013 Gregor Gruener <ggruner(a)redhat.com>
-- spacecmd - add new function is_monitoringenabled and list_proxies
+* Tue Aug 06 2013 Gregor Gruener <ggruner(a)redhat.com> 2.1.3-1
+- add new function scap_listxccdfscans
+- add new function scap_getxccdfscandetails
+- add new function scap_getxccdfscanruleresults
+- add new function scap_schedulexccdfscan
+
+* Mon Aug 05 2013 Gregor Gruener <ggruner(a)redhat.com> 2.1.2-1
+- add new function is_monitoringenabled
+- add new function list_proxies
* Mon Jul 22 2013 Gregor Gruener <ggruner(a)redhat.com> 2.1.1-1
- add new function custominfo_updatekey
commit 58dc4b990d6e94a73935c318d6fd8d39f25de1c6
Author: Gregor Gruener <ggruner(a)redhat.com>
Date: Tue Aug 6 09:41:44 2013 +0200
Added new scap features into spacecmd
diff --git a/spacecmd/src/lib/scap.py b/spacecmd/src/lib/scap.py
new file mode 100644
index 0000000..28b3e1b
--- /dev/null
+++ b/spacecmd/src/lib/scap.py
@@ -0,0 +1,158 @@
+#
+# Licensed under the GNU General Public License Version 3
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright 2013 Aron Parsons <aronparsons(a)gmail.com>
+# Copyright (c) 2013 Red Hat, Inc.
+#
+
+# NOTE: the 'self' variable is an instance of SpacewalkShell
+
+from optparse import Option
+from spacecmd.utils import *
+
+def help_scap_listxccdfscans(self):
+ print 'scap_listxccdfscans: Return a list of finished OpenSCAP scans for given
systems'
+ print 'usage: scap_listxccdfscans <SYSTEMS>'
+
+def complete_system_scap_listxccdfscans(self, text, line, beg, end):
+ return self.tab_complete_systems(text)
+
+def do_scap_listxccdfscans(self, args):
+ (args, options) = parse_arguments(args)
+
+ if not len(args):
+ self.help_scap_listxccdfscans()
+ return
+
+ # use the systems listed in the SSM
+ if re.match('ssm', args[0], re.I):
+ systems = self.ssm.keys()
+ else:
+ systems = self.expand_systems(args)
+
+ add_separator = False
+
+ for system in sorted(systems):
+ if add_separator: print self.SEPARATOR
+ add_separator = True
+
+ if len(systems) > 1:
+ print 'System: %s' % system
+ print
+
+ system_id = self.get_system_id(system)
+ if not system_id: continue
+
+ scan_list = self.client.system.scap.listXccdfScans(self.session, system_id)
+
+ for s in scan_list:
+ print 'XID: %d Profile: %s Path: (%s) Completed: %s' %
(s['xid'], s['profile'], s['path'], s['completed'])
+
+####################
+
+def help_scap_getxccdfscanruleresults(self):
+ print 'scap_getxccdfscanruleresults: Return a full list of RuleResults for given
OpenSCAP XCCDF scan'
+ print 'usage: scap_getxccdfscanruleresults <XID>'
+
+def do_scap_getxccdfscanruleresults(self, args):
+ (args, options) = parse_arguments(args)
+
+ if not len(args):
+ self.help_scap_getxccdfscanruleresults()
+ return
+
+ add_separator = False
+
+ for xid in args:
+ if add_separator: print self.SEPARATOR
+ add_separator = True
+
+ if len(args) > 1:
+ print 'XID: %s' % xid
+ print
+
+ xid = int(xid)
+ scan_results = self.client.system.scap.getXccdfScanRuleResults(self.session,
xid)
+
+ for s in scan_results:
+ print 'IDref: %s Result: %s Idents: (%s)' % (s['idref'],
s['result'], s['idents'])
+
+####################
+
+def help_scap_getxccdfscandetails(self):
+ print 'scap_getxccdfscandetails: Get details of given OpenSCAP XCCDF scan'
+ print 'usage: scap_getxccdfscandetails <XID>'
+
+def do_scap_getxccdfscandetails(self, args):
+ (args, options) = parse_arguments(args)
+
+ if not len(args):
+ self.help_scap_getxccdfscandetails()
+ return
+
+ add_separator = False
+
+ for xid in args:
+ if add_separator: print self.SEPARATOR
+ add_separator = True
+
+ if len(args) > 1:
+ print 'XID: %s' % xid
+ print
+
+ xid = int(xid)
+ scan_details = self.client.system.scap.getXccdfScanDetails(self.session, xid)
+
+ print
"XID:",scan_details['xid'],"SID:",scan_details['sid'],"Action_ID:",scan_details['action_id'],"Path:",scan_details['path'],\
+
"OSCAP_Parameters:",scan_details['oscap_parameters'],"Test_Result:",scan_details['test_result'],\
+
"Benchmark:",scan_details['benchmark'],"Benchmark_Version:",scan_details['benchmark_version'],\
+
"Profile:",scan_details['profile'],"Profile_Title:",scan_details['profile_title'],"Start_Time:",scan_details['start_time'],\
+
"End_Time:",scan_details['end_time'],"Errors:",scan_details['errors']
+
+####################
+
+def help_scap_schedulexccdfscan(self):
+ print 'scap_schedulexccdfscan: Schedule Scap XCCDF scan'
+ print 'usage: scap_schedulexccdfscan PATH_TO_XCCDF_FILE XCCDF_OPTIONS
SYSTEMS'
+ print
+ print 'Example:'
+ print '> scap_schedulexccdfscan
\'/usr/share/openscap/scap-security-xccdf.xml\' \'profile Web-Default\'
system-scap.example.com'
+
+def do_scap_schedulexccdfscan(self, args):
+ (args, options) = parse_arguments(args)
+
+ if len(args) < 3:
+ self.help_scap_schedulexccdfscan()
+ return
+
+ path = args[0]
+ param = "--"
+ param += args[1]
+
+ # use the systems listed in the SSM
+ if re.match('ssm', args[0], re.I):
+ systems = self.ssm.keys()
+ else:
+ systems = self.expand_systems(args[2:])
+
+ for system in systems:
+ system_id = self.get_system_id(system)
+ if not system_id: continue
+
+ scan_schedule = self.client.system.scap.scheduleXccdfScan(self.session,
system_id, path, param)
+
+# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/shell.py b/spacecmd/src/lib/shell.py
index 64bcbee..4417d7e 100644
--- a/spacecmd/src/lib/shell.py
+++ b/spacecmd/src/lib/shell.py
@@ -30,7 +30,7 @@ class SpacewalkShell(Cmd):
'filepreservation', 'group', 'kickstart',
'misc', 'org', 'package', 'repo',
'report', 'schedule',
'snippet', 'softwarechannel', 'ssm',
'api',
- 'system', 'user', 'utils' ]
+ 'system', 'user', 'utils', 'scap'
]
# a SyntaxError is thrown if we don't wrap this in an 'exec'
for module in __module_list: