Skip to content

Commit 8df1619

Browse files
committed
Simplify configuration of 2 config files. Minor updates to a number of test cases.
1 parent 8d4fcf9 commit 8df1619

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+197
-333
lines changed

src/config/build.xml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
21
<!DOCTYPE xml>
32
<project>
43
<target name="run">
@@ -10,20 +9,10 @@
109
</daemons>
1110
</parallel>
1211
</target>
13-
<target name="permuteDatabaseServer">
14-
<parallel>
15-
<daemons>
16-
<java classname="org.hsqldb.Server" fork="false" failonerror="true">
17-
<arg line="--database.0 file:src/db/permute.db --dbname.0 permuteDataBase --port 9002 --remote_open true" />
18-
<classpath refid="maven.compile.classpath" />
19-
</java>
20-
</daemons>
21-
</parallel>
22-
</target>
2312
<target name="databaseServer">
2413
<parallel>
2514
<daemons>
26-
<java classname="org.hsqldb.Server" fork="false" failonerror="true">
15+
<java classname="org.hsqldb.Server" fork="true" failonerror="true">
2716
<arg line="--database.0 file:target/db/benchmark.db --dbname.0 benchmarkDataBase" />
2817
<classpath refid="maven.compile.classpath" />
2918
</java>
@@ -39,4 +28,5 @@
3928
</daemons>
4029
</parallel>
4130
</target>
42-
</project>
31+
</project>
32+

src/config/local/server.xml

Lines changed: 91 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,132 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="no"?><!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html -->
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?><!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
--><!-- Note: A "Server" is not itself a "Container", so you may not
17+
define subcomponents such as "Valves" at this level.
18+
Documentation at /docs/config/server.html
19+
-->
220
<Server port="8205" shutdown="SHUTDOWN">
321
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
4-
<!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> -->
22+
<!-- Security listener. Documentation at /docs/config/listeners.html
23+
<Listener className="org.apache.catalina.security.SecurityListener" />
24+
-->
525
<!--APR library loader. Documentation at /docs/apr.html -->
626
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener" />
727
<!-- Prevent memory leaks due to use of particular java/javax APIs -->
828
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
929
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
1030
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
1131

12-
<!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html -->
32+
<!-- Global JNDI resources
33+
Documentation at /docs/jndi-resources-howto.html
34+
-->
1335
<GlobalNamingResources>
14-
<!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -->
36+
<!-- Editable user database that can also be used by
37+
UserDatabaseRealm to authenticate users
38+
-->
1539
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" />
1640
<Resource name="jdbc/ApplicationContext_BenchmarkDB" auth="Container" type="javax.sql.DataSource" username="sa" password="" driverClassName="org.hsqldb.jdbc.JDBCDriver" url="jdbc:hsqldb:hsql://localhost/benchmarkDataBase;file:benchmark.db;sql.enforce_size=false;shutdown=false;" maxTotal="12" maxIdle="2" maxWaitMillis="5000" removeAbandonedOnBorrow="true" />
1741
</GlobalNamingResources>
1842

19-
<!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html -->
43+
<!-- A "Service" is a collection of one or more "Connectors" that share
44+
a single "Container" Note: A "Service" is not itself a "Container",
45+
so you may not define subcomponents such as "Valves" at this level.
46+
Documentation at /docs/config/service.html
47+
-->
2048
<Service name="Catalina">
2149

2250
<!--The connectors can use a shared executor, you can define one or more named thread pools -->
23-
<!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> -->
24-
25-
26-
<!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 -->
51+
<!--
52+
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
53+
maxThreads="150" minSpareThreads="4"/>
54+
-->
55+
56+
57+
<!-- A "Connector" represents an endpoint by which requests are received
58+
and responses are returned. Documentation at :
59+
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
60+
Java AJP Connector: /docs/config/ajp.html
61+
APR (HTTP/AJP) Connector: /docs/apr.html
62+
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
63+
-->
2764
<Connector address="127.0.0.1" SSLEnabled="true" URIEncoding="ISO-8859-1" clientAuth="false" connectionTimeout="20000" keyAlias="tomcat" keystoreFile="../../.keystore" keystorePass="changeit" port="8443" protocol="HTTP/1.1" redirectPort="8443" scheme="https" secure="true" sslProtocol="TLS" />
2865
<!-- A "Connector" using the shared thread pool -->
29-
<!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> -->
30-
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses the NIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation -->
31-
<!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> -->
66+
<!--
67+
<Connector executor="tomcatThreadPool"
68+
port="8080" protocol="HTTP/1.1"
69+
connectionTimeout="20000"
70+
redirectPort="8443" />
71+
-->
72+
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
73+
This connector uses the NIO implementation that requires the JSSE
74+
style configuration. When using the APR/native implementation, the
75+
OpenSSL style configuration is required as described in the APR/native
76+
documentation -->
77+
<!--
78+
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
79+
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
80+
clientAuth="false" sslProtocol="TLS" />
81+
-->
3282

3383
<!-- Define an AJP 1.3 Connector on port 8009 -->
3484
<!-- Connector port="8009" protocol="AJP/1.3" redirectPort="8443" address="127.0.0.01"/ -->
3585

3686

37-
<!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html -->
87+
<!-- An Engine represents the entry point (within Catalina) that processes
88+
every request. The Engine implementation for Tomcat stand alone
89+
analyzes the HTTP headers included with the request, and passes them
90+
on to the appropriate Host (virtual host).
91+
Documentation at /docs/config/engine.html -->
3892

39-
<!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> -->
93+
<!-- You should set jvmRoute to support load-balancing via AJP ie :
94+
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
95+
-->
4096
<Engine defaultHost="localhost" name="Catalina">
4197

42-
<!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) -->
43-
<!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> -->
98+
<!--For clustering, please take a look at documentation at:
99+
/docs/cluster-howto.html (simple how to)
100+
/docs/config/cluster.html (reference documentation) -->
101+
<!--
102+
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
103+
-->
44104

45-
<!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack -->
105+
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
106+
via a brute-force attack -->
46107
<Realm className="org.apache.catalina.realm.LockOutRealm">
47-
<!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. -->
108+
<!-- This Realm uses the UserDatabase configured in the global JNDI
109+
resources under the key "UserDatabase". Any edits
110+
that are performed against this UserDatabase are immediately
111+
available for use by the Realm. -->
48112
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
49113
</Realm>
50114

51115
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
52116

53-
<!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html -->
54-
<!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> -->
117+
<!-- SingleSignOn valve, share authentication between web applications
118+
Documentation at: /docs/config/valve.html -->
119+
<!--
120+
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
121+
-->
55122

56-
<!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" -->
123+
<!-- Access log processes all example.
124+
Documentation at: /docs/config/valve.html
125+
Note: The pattern used is equivalent to using pattern="common" -->
57126
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt" />
58127

59128

60129
</Host>
61130
</Engine>
62131
</Service>
63-
</Server>
132+
</Server>

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00025.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,14 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
4444
String param = request.getParameter("BenchmarkTest00025");
4545
if (param == null) param = "";
4646

47-
String sql =
48-
"SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + param + "'";
47+
String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + param + "'";
4948
try {
5049
// Long results =
5150
// org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql);
5251
Long results =
5352
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
5453
sql, Long.class);
55-
response.getWriter().println("Your results are: ");
56-
57-
// System.out.println("your results are");
58-
response.getWriter().println(results.toString());
59-
// System.out.println(results);
54+
response.getWriter().println("Your results are: " + String.valueOf(results));
6055
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
6156
response.getWriter()
6257
.println(

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00038.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
6464
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query(
6565
sql,
6666
new org.springframework.jdbc.core.RowMapper<String>() {
67+
@Override
6768
public String mapRow(java.sql.ResultSet rs, int rowNum)
6869
throws java.sql.SQLException {
6970
try {
@@ -78,11 +79,9 @@ public String mapRow(java.sql.ResultSet rs, int rowNum)
7879
});
7980
response.getWriter().println("Your results are: ");
8081

81-
// System.out.println("Your results are");
8282
for (String s : results) {
8383
response.getWriter()
8484
.println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "<br>");
85-
// System.out.println(s);
8685
}
8786
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
8887
response.getWriter()

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00197.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
6666
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.query(
6767
sql,
6868
new org.springframework.jdbc.core.RowMapper<String>() {
69+
@Override
6970
public String mapRow(java.sql.ResultSet rs, int rowNum)
7071
throws java.sql.SQLException {
7172
try {
@@ -80,11 +81,9 @@ public String mapRow(java.sql.ResultSet rs, int rowNum)
8081
});
8182
response.getWriter().println("Your results are: ");
8283

83-
// System.out.println("Your results are");
8484
for (String s : results) {
8585
response.getWriter()
8686
.println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(s) + "<br>");
87-
// System.out.println(s);
8887
}
8988
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
9089
response.getWriter()

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00198.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,15 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
5252
org.owasp.benchmark.helpers.ThingFactory.createThing();
5353
String bar = thing.doSomething(param);
5454

55-
String sql =
56-
"SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
55+
String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
5756
try {
5857
// int results =
5958
// org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql);
6059
Integer results =
6160
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
6261
sql, Integer.class);
63-
response.getWriter().println("Your results are: ");
64-
65-
// System.out.println("Your results are: ");
66-
response.getWriter().println(results.toString());
67-
// System.out.println(results);
62+
response.getWriter().println("Your results are: " + results);
63+
// System.out.println("Your results are: " + results);
6864
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
6965
response.getWriter()
7066
.println(

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00199.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,15 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
5555
if ((500 / 42) + num > 200) bar = param;
5656
else bar = "This should never happen";
5757

58-
String sql =
59-
"SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
58+
String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
6059
try {
6160
// int results =
6261
// org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql);
6362
Integer results =
6463
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
6564
sql, Integer.class);
66-
response.getWriter().println("Your results are: ");
67-
68-
// System.out.println("Your results are: ");
69-
response.getWriter().println(results.toString());
70-
// System.out.println(results);
65+
response.getWriter().println("Your results are: " + results);
66+
// System.out.println("Your results are: " + results);
7167
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
7268
response.getWriter()
7369
.println(

src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00336.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,14 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
5757
if ((7 * 42) - num > 200) bar = "This_should_always_happen";
5858
else bar = param;
5959

60-
String sql =
61-
"SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
60+
String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
6261
try {
6362
// Long results =
6463
// org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql);
6564
Long results =
6665
org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
6766
sql, Long.class);
68-
response.getWriter().println("Your results are: ");
69-
70-
// System.out.println("your results are");
71-
response.getWriter().println(results.toString());
72-
// System.out.println(results);
67+
response.getWriter().println("Your results are: " + String.valueOf(results));
7368
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
7469
response.getWriter()
7570
.println(

0 commit comments

Comments
 (0)