backend/server/action/scap.py
| 24 +++++--
backend/server/handlers/xmlrpc/Makefile
| 2
client/rhel/spacewalk-oscap/scap.py
| 6 -
java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml
| 2
java/code/src/com/redhat/rhn/domain/org/OrgConfig.java
| 32 ++++++++++
java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
| 18 ++++-
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
| 12 +++
java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp
| 27 ++++++++
schema/spacewalk/common/tables/rhnOrgConfiguration.sql
| 8 ++
schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/018-rhnOrgConfiguration-scap.sql
| 8 ++
10 files changed, 126 insertions(+), 13 deletions(-)
New commits:
commit e20d499601f15d76826166fee096151621780dc3
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 19:16:19 2013 +0200
Add scap into list of packaged modules.
diff --git a/backend/server/handlers/xmlrpc/Makefile
b/backend/server/handlers/xmlrpc/Makefile
index 1b29cf2..2378238 100644
--- a/backend/server/handlers/xmlrpc/Makefile
+++ b/backend/server/handlers/xmlrpc/Makefile
@@ -6,7 +6,7 @@ TOP = ../../..
SUBDIR = server/handlers/xmlrpc
FILES = __init__ country queue registration states up2date errata \
- getMethod proxy get_handler abrt
+ getMethod proxy get_handler abrt scap
include $(TOP)/Makefile.defs
commit 42429b4ae06260a6d640ae4746796ae2e80bc7ca
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 15:31:31 2013 +0200
SCAP file size limit shall be configurable through web interface
diff --git a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml
b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml
index e026401..84c7ab1 100644
--- a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml
@@ -14,6 +14,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="crashReportingEnabled"
column="crash_reporting_enabled" type="yes_no"
not-null="true"/>
<property name="crashfileUploadEnabled"
column="crashfile_upload_enabled" type="yes_no"
not-null="true"/>
<property name="crashFileSizelimit"
column="crash_file_sizelimit" type="long"
not-null="true"/>
+ <property name="scapfileUploadEnabled"
column="scapfile_upload_enabled" type="yes_no"
not-null="true"/>
+ <property name="scapFileSizelimit"
column="scap_file_sizelimit" type="long"
not-null="true"/>
</class>
</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java
b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java
index 8fc40c0..e63181c 100644
--- a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java
+++ b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java
@@ -32,6 +32,8 @@ public class OrgConfig extends BaseDomainHelper {
private boolean crashReportingEnabled;
private boolean crashfileUploadEnabled;
private Long crashFileSizelimit;
+ private boolean scapfileUploadEnabled;
+ private Long scapFileSizelimit;
/**
* Gets the current value of org_id
@@ -106,4 +108,34 @@ public class OrgConfig extends BaseDomainHelper {
public void setCrashFileSizelimit(Long sizeLimitIn) {
crashFileSizelimit = sizeLimitIn;
}
+
+ /**
+ * @return Returns the scapfileUploadEnabled flag.
+ */
+ public boolean isScapfileUploadEnabled() {
+ return scapfileUploadEnabled;
+ }
+
+ /**
+ * @param scapfileUploadEnabledIn The scapfileUploadEnabled to set.
+ */
+ public void setScapfileUploadEnabled(boolean scapfileUploadEnabledIn) {
+ scapfileUploadEnabled = scapfileUploadEnabledIn;
+ }
+
+ /**
+ * Get the org-wide SCAP file size limit.
+ * @return Returns the org-wide scap file size limit.
+ */
+ public Long getScapFileSizelimit() {
+ return scapFileSizelimit;
+ }
+
+ /**
+ * Set the org-wide SCAP file size limit.
+ * @param sizeLimitIn The org-wide SCAP file size limit to set.
+ */
+ public void setScapFileSizelimit(Long sizeLimitIn) {
+ scapFileSizelimit = sizeLimitIn;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
index ed700b3..cfe7455 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
@@ -60,12 +60,19 @@ public class OrgConfigAction extends RhnAction {
getParameter("crashfile_upload_enabled") != null);
}
+ org.getOrgConfig().setScapfileUploadEnabled(request.
+ getParameter("scapfile_upload_enabled") != null);
+
Long newCrashLimit = null;
+ Long newScapLimit = null;
try {
newCrashLimit = Long.parseLong(
request.getParameter("crashfile_sizelimit").trim());
- if (newCrashLimit < 0) {
+ newScapLimit = Long.parseLong(
+ request.getParameter("scapfile_sizelimit").trim());
+
+ if (newCrashLimit < 0 || newScapLimit < 0) {
throw new IllegalArgumentException();
}
}
@@ -80,6 +87,9 @@ public class OrgConfigAction extends RhnAction {
if
(StringUtils.isNotEmpty(request.getParameter("crashfile_sizelimit"))) {
org.getOrgConfig().setCrashFileSizelimit(newCrashLimit);
}
+ if
(StringUtils.isNotEmpty(request.getParameter("scapfile_sizelimit"))) {
+ org.getOrgConfig().setScapFileSizelimit(newScapLimit);
+ }
ActionMessages msg = new ActionMessages();
msg.add(ActionMessages.GLOBAL_MESSAGE,
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 7662af1..180ac89 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -3339,6 +3339,18 @@ button below, and <b>will be unable to log back
in</b>.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context>
</context-group>
</trans-unit>
+ <trans-unit id="org-config.scapfile-upload.jsp">
+ <source>Enable Upload Of Detailed SCAP Files</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="org-config.scapfile-sizelimit.jsp">
+ <source>SCAP File Upload Size Limit</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="org.id.jsp">
<source>Organization ID</source>
<context-group name="ctx">
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp
index f398f8e..8ea22aa 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp
@@ -111,6 +111,33 @@ function modifyUploadCheckbox(checkbox) {
id="crashfile_sizelimit" />
<td>
</tr>
+ <tr>
+ <th>
+ <label for="scapfile_upload_enabled">
+ <bean:message key="org-config.scapfile-upload.jsp"/>
+ </th>
+ <td>
+ <input type="checkbox"
+ name="scapfile_upload_enabled"
+ value="enabled"
+ id="scapfile_upload_enabled"
+ <c:if test = "${org.orgConfig.scapfileUploadEnabled}">
+ checked="checked"
+ </c:if>
+ />
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <bean:message key="org-config.scapfile-sizelimit.jsp"/>
+ </th>
+ <td>
+ <input type="number"
+ name="scapfile_sizelimit"
+ value="${org.orgConfig.scapFileSizelimit}"
+ id="scapfile_sizelimit" />
+ <td>
+ </tr>
</table>
<div align="right">
commit 82b85cf31c2f01000c6454de3090fe283ae9a718
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 15:44:19 2013 +0200
Precede internal error messages by xccdf_eval: prefix.
Help user identify where the error comes from.
diff --git a/client/rhel/spacewalk-oscap/scap.py b/client/rhel/spacewalk-oscap/scap.py
index 4caa7cc..0f4cb32 100644
--- a/client/rhel/spacewalk-oscap/scap.py
+++ b/client/rhel/spacewalk-oscap/scap.py
@@ -133,7 +133,7 @@ def _upload_results(xccdf_result, results_dir, args):
def _upload_file(server, systemid, args, path, filename, f):
if not _assert_xml(f):
log.log_debug('Excluding "%s" file from upload. Not an XML.',
path)
- return '\nFile "%s" not uploaded. Not an XML file format.',
filename
+ return '\nxccdf_eval: File "%s" not uploaded. Not an XML file
format.', filename
stat = os.fstat(f.fileno())
if stat.st_size < args['file_size']:
@@ -148,9 +148,9 @@ def _upload_file(server, systemid, args, path, filename, f):
return ''
except up2dateErrors.Error, e:
log.log_exception(*sys.exc_info())
- return '\nFile "%s" not uploaded. %s' % (filename, e)
+ return '\nxccdf_eval: File "%s" not uploaded. %s' %
(filename, e)
else:
- return '\nFile "%s" not uploaded. File size (%d B) exceeds the
limit.' \
+ return '\nxccdf_eval: File "%s" not uploaded. File size (%d B)
exceeds the limit.' \
% (filename, stat.st_size)
def _cleanup_temp(results_dir):
commit 5f75d3095f907e8a55320b4fc25da4f464344257
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 15:34:01 2013 +0200
Refactor: Rename variable: newLimit -> newCrashLimit
diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
index 9bfc444..ed700b3 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java
@@ -60,12 +60,12 @@ public class OrgConfigAction extends RhnAction {
getParameter("crashfile_upload_enabled") != null);
}
- Long newLimit = null;
+ Long newCrashLimit = null;
try {
- newLimit = Long.parseLong(
+ newCrashLimit = Long.parseLong(
request.getParameter("crashfile_sizelimit").trim());
- if (newLimit < 0) {
+ if (newCrashLimit < 0) {
throw new IllegalArgumentException();
}
}
@@ -78,7 +78,7 @@ public class OrgConfigAction extends RhnAction {
RequestContext.ORG_ID, org.getId().toString());
}
if
(StringUtils.isNotEmpty(request.getParameter("crashfile_sizelimit"))) {
- org.getOrgConfig().setCrashFileSizelimit(newLimit);
+ org.getOrgConfig().setCrashFileSizelimit(newCrashLimit);
}
ActionMessages msg = new ActionMessages();
commit 76f6dcf8ef8b609deb43fc45009220676e0e77d0
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 14:51:40 2013 +0200
Do not use python key-word as a variable name
diff --git a/backend/server/action/scap.py b/backend/server/action/scap.py
index 81992ac..320aac5 100644
--- a/backend/server/action/scap.py
+++ b/backend/server/action/scap.py
@@ -27,15 +27,15 @@ def xccdf_eval(server_id, action_id, dry_run=0):
where action_id = :action_id"""
h = rhnSQL.prepare(statement)
h.execute(action_id=action_id)
- dict = h.fetchone_dict()
- if not dict:
+ d = h.fetchone_dict()
+ if not d:
raise InvalidAction("scap.xccdf_eval: Unknown action id "
"%s for server %s" % (action_id, server_id))
return ({
- 'path': dict['path'],
+ 'path': d['path'],
'id': action_id,
'file_size': _scap_file_limit(server_id),
- 'params': rhnSQL.read_lob(dict['parameters']) or ''
+ 'params': rhnSQL.read_lob(d['parameters']) or ''
},)
def _scap_file_limit(server_id):
commit 2aac39680bb9c614eb136d3ff3b63201041c6c0e
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue May 28 14:43:08 2013 +0200
Store SCAP-file-limit to the database
instead of hardcoding it in the backend code.
diff --git a/backend/server/action/scap.py b/backend/server/action/scap.py
index c28274b..81992ac 100644
--- a/backend/server/action/scap.py
+++ b/backend/server/action/scap.py
@@ -34,6 +34,20 @@ def xccdf_eval(server_id, action_id, dry_run=0):
return ({
'path': dict['path'],
'id': action_id,
- 'file_size': 2097152,
+ 'file_size': _scap_file_limit(server_id),
'params': rhnSQL.read_lob(dict['parameters']) or ''
},)
+
+def _scap_file_limit(server_id):
+ statement = """
+ select roc.scap_file_sizelimit as limit, roc.scapfile_upload_enabled as enabled
+ from rhnOrgConfiguration roc,
+ rhnServer rs
+ where rs.id = :server_id
+ and rs.org_id = roc.org_id"""
+ h = rhnSQL.prepare(statement)
+ h.execute(server_id=server_id)
+ d = h.fetchone_dict()
+ if not d or d['enabled'] != 'Y':
+ return 0
+ return d['limit']
diff --git a/schema/spacewalk/common/tables/rhnOrgConfiguration.sql
b/schema/spacewalk/common/tables/rhnOrgConfiguration.sql
index fc59afb..c004ef0 100644
--- a/schema/spacewalk/common/tables/rhnOrgConfiguration.sql
+++ b/schema/spacewalk/common/tables/rhnOrgConfiguration.sql
@@ -35,6 +35,14 @@ create table rhnOrgConfiguration
default(2048) not null
constraint rhn_org_conf_sizelimit_chk
check (crash_file_sizelimit >= 0),
+ scapfile_upload_enabled char(1)
+ default ('N') not null
+ constraint rhn_org_conf_scap_upload_chk
+ check (scapfile_upload_enabled in ('Y',
'N')),
+ scap_file_sizelimit number
+ default(2097152) not null
+ constraint rhn_org_conf_scap_sizelimit_chk
+ check (scap_file_sizelimit >= 0),
created timestamp with local time zone
default (current_timestamp) not null,
modified timestamp with local time zone
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/018-rhnOrgConfiguration-scap.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/018-rhnOrgConfiguration-scap.sql
new file mode 100644
index 0000000..02d1ae7
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.9-to-spacewalk-schema-1.10/018-rhnOrgConfiguration-scap.sql
@@ -0,0 +1,8 @@
+alter table rhnOrgConfiguration
+ add scapfile_upload_enabled
+ char(1) default ('N') not null
+ constraint rhn_org_conf_scap_upload_chk check (scapfile_upload_enabled in
('Y', 'N'));
+alter table rhnOrgConfiguration
+ add scap_file_sizelimit
+ number default(2097152) not null
+ constraint rhn_org_conf_scap_szlmt_chk check (scap_file_sizelimit >= 0);