Skip to content

Commit 3b9e247

Browse files
Merge pull request diffblue#484 from diffblue/testy/DSpace
Make DSpace pass stage 1
2 parents dc0ce77 + b21c33f commit 3b9e247

16 files changed

+188
-2
lines changed

benchmarks/GENUINE/DSpace.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ cd $SECURITY_SCANNER_HOME
4949
python3 $SCRIPT_DIR/../../driver/run.py \
5050
-C $SCRIPT_DIR/DSpace_rules.json \
5151
-I $DEPLOY_DIR/webapps/jspui \
52+
-L $SCRIPT_DIR/DSpace_files/DI/target \
5253
-R $OUTPUT_DIR/DSpace/results \
5354
-T $OUTPUT_DIR/DSpace/temp \
5455
--name DSpace-jspui-BrowseServlet \
55-
--use-models-library --use-apache-tomcat --use-spring-framework \
56+
--use-models-library \
5657
--timeout 10000000 --verbosity 9 --rebuild \
5758
--do-not-use-precise-access-paths \
5859
--entry-point org.dspace.app.webui.servlet.BrowserServlet.doDSGet
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.diffblue;
2+
3+
public @interface IgnoredMethodImplementation {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.diffblue;
2+
3+
public @interface OverlayClassImplementation {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.diffblue;
2+
3+
public @interface OverlayMethodImplementation {
4+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.dspace.browse;
2+
3+
import com.diffblue.IgnoredMethodImplementation;
4+
import com.diffblue.OverlayClassImplementation;
5+
import com.diffblue.OverlayMethodImplementation;
6+
import org.dspace.core.Context;
7+
8+
@OverlayClassImplementation
9+
public class BrowseDAOFactory
10+
{
11+
@IgnoredMethodImplementation
12+
BrowseDAOFactory()
13+
{
14+
}
15+
16+
@OverlayMethodImplementation
17+
public static BrowseDAO getInstance(Context context)
18+
throws BrowseException
19+
{
20+
return new BrowseDAOOracle(context);
21+
}
22+
}
Binary file not shown.
Binary file not shown.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
org.dspace.app.webui.servlet.BrowserServlet.doGet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/BrowserServlet.java]
2+
- This should be the entry point, but since 'doGet' is not overriden in 'BrowserServlet', we need to pass to the command line:
3+
--function org.dspace.app.webui.servlet.DSpaceServlet.doGet
4+
implemented in file DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/DSpaceServlet.java
5+
- the class hierarchy is:
6+
org.dspace.app.webui.servlet.BrowserServlet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/BrowserServlet.java]
7+
org.dspace.app.webui.servlet.AbstractBrowserServlet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/AbstractBrowserServlet.java]
8+
org.dspace.app.webui.servlet.DSpaceServlet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/DSpaceServlet.java]
9+
10+
The error-trace:
11+
12+
org.dspace.app.webui.servlet.DSpaceServlet.doGet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/DSpaceServlet.java]
13+
LINE 67: Calling org.dspace.app.webui.servlet.DSpaceServlet.processRequest [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/DSpaceServlet.java]
14+
LINE 94: Calling org.dspace.app.webui.util.UIUtil.storeOriginalURL [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/util/UIUtil.java]
15+
LINE 209: RULE APPLICATION: Obtaining 'tainted object' by calling HttpServletRequest.getAttribute (but this one is not of interest)
16+
LINE 211: Take ELSE
17+
RETURN
18+
LINE 100: Calling org.dspace.app.webui.util.UIUtil.obtainContext [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/util/UIUtil.java]
19+
LINE 99: RULE APPLICATION: Obtaining 'tainted object' by calling ServletRequest.getAttribute (but this one is not of interest)
20+
LINE 102: Take IF
21+
LINE 105: Calling org.dspace.core.Context.Context [DSpace/dspace-api/src/main/java/org/dspace/core/Context.java]
22+
LINE 95: Calling org.dspace.core.Context.init [DSpace/dspace-api/src/main/java/org/dspace/core/Context.java]
23+
LINE 121: Calling org.dspace.storage.rdbms.DatabaseManager.getConnection [DSpace/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java]
24+
LINE 629: Calling org.dspace.storage.rdbms.DatabaseManager.getDataSource [DSpace/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java]
25+
LINE 646: Take IF
26+
LINE 650: Calling org.dspace.storage.rdbms.DatabaseManager.initialize [DSpace/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java]
27+
LINE 1325: Take ELSE
28+
LINE 1333: Calling org.dspace.storage.rdbms.DatabaseManager.initDataSource [DSpace/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java]
29+
LINE 1409: Taking JNDI name
30+
LINE 1410: Take IF
31+
LINE 1414: Initialise JNDI Context
32+
LINE 1415: Lookup for the root of servlet data
33+
LINE 1416: Obtain the DataSource instance
34+
LINE 1433: Take ELSE
35+
RETURN
36+
LINE 1344: Take ELSE
37+
LINE 1348: Take IF
38+
RETURN
39+
RETURN
40+
LINE 633: Take IF
41+
RETURN
42+
RETURN
43+
RETURN
44+
LINE 109: RULE APPLICATION: Obtaining 'tainted object' by calling ServletRequest.getAttribute (but this one is not of interest)
45+
LINE 112: Take ELSE
46+
LINE 140: Take ELSE
47+
LINE 143: RULE APPLICATION: Obtaining 'tainted request header' by calling ServletRequest.getHeader (but this one is not of interest)
48+
LINE 143: Take ELSE
49+
LINE 157: RULE APPLICATION: Storing 'tainted object' to request by calling ServletRequest.getAttribute (but the stored object is actually not tainted)
50+
RETURN
51+
LINE 104: Calling org.dspace.app.webui.util.Authenticate.getRealRequest [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/util/Authenticate.java]
52+
LINE 59: Take ELSE (We do not want to wrap the request due to redirection from successful authentication)
53+
RETURN
54+
LINE 106: Take ELSE
55+
LINE 113: Take ELSE
56+
LINE 119: Calling org.dspace.app.webui.servlet.BrowserServlet.doDSGet [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/BrowserServlet.java]
57+
58+
59+
LINE 66: Calling org.dspace.app.webui.servlet.AbstractBrowserServlet.getBrowserScopeForRequest [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/AbstractBrowserServlet.java]
60+
LINE 86: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
61+
LINE 87: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
62+
LINE 88: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
63+
LINE 89: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
64+
LINE 90: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter
65+
LINE 91: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter
66+
LINE 92: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter
67+
LINE 92: Assign returned tainted string to startsWith
68+
69+
- ONLY IN THE VERSION WITH THE XSS ISSUE FIXED:
70+
LINE 96: RULE APPLICATION: Sanitised 'tainted string' (exception is thrown, if the string is not a number; then HttpServletResponse.SC_BAD_REQUEST is set to the response and the servlet terminates)
71+
LINE 99: RULE APPLICATION: Sanitised 'tainted string' (exception is thrown, if the string is not a number; then HttpServletResponse.SC_BAD_REQUEST is set to the response and the servlet terminates)
72+
LINE 102: Calling org.dspace.core.Utils.addEntities [DSpace/dspace-api/src/main/java/org/dspace/core/Utils.java]
73+
LINE 283: RULE APPLICATION: Sanitising 'tainted string' by calling com.coverity.security.Escape.html
74+
RETURN
75+
76+
LINE 112: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
77+
LINE 113: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
78+
LINE 114: RULE APPLICATION: Obtaining 'tainted string' by calling ServletRequest.getParameter (but this one is not of interest)
79+
LINE 127: Take ANY
80+
LINE 134: Take ANY
81+
LINE 141: Take ANY
82+
LINE 154: Take ANY
83+
LINE 163: Take ANY
84+
LINE 182: Take ANY
85+
LINE 188: Take ANY
86+
LINE 194: Take ANY
87+
LINE 201: Take ELSE
88+
LINE 230: Take ANY
89+
LINE 236: Take ANY
90+
LINE 242: Take ANY
91+
LINE 260: Take ANY
92+
LINE 265: Take ANY
93+
LINE 281: Create new BrowserScope and assign to scope
94+
LINE 282: Call scope.setBrowseIndex(bi)
95+
LINE 287: Calling org.dspace.browse.BrowserScope.setStartsWith on scope passing tainted string startsWith [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java]
96+
LINE 471: Putting the 'tainted string' into the startsWith field of scope.
97+
RETURN
98+
LINE 296: Take ANY
99+
LINE 300: Take ANY
100+
LINE 306: Take ANY
101+
LINE 313: Return scope
102+
LINE 66: Assign return value to scope of type BrowserScope
103+
LINE 68: Take ELSE
104+
LINE 81: Take ELSE
105+
LINE 88: Calling org.dspace.app.webui.servlet.AbstractBrowserServlet.processBrowse, passing tainted scope as second argument [DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/AbstractBrowserServlet.java]
106+
LINE 338: Calling org.dspace.browse.BrowseEngine.BrowseEngine [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java]
107+
LINE 64: Calling org.dspace.browse.BrowseDAOFactory.getInstance [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseDAOFactory.java]
108+
LINE 34: Take ELSE
109+
LINE 41: Resolve the construction
110+
RETURN
111+
LINE 64: Assign to member dao
112+
LINE 338: Assign newly constructed BrowseEngine to local variable be
113+
LINE 339: Calling org.dspace.browse.BrowseEngine.browse on be passing scope as first argument [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java]
114+
LINE 77: Tainted scope assigned to parameter bs
115+
LINE 83: Assign bs to member scope
116+
LINE 90: Take IF
117+
LINE 94: Calling org.dspace.browse.BrowseEngine.browseByValue on this passing bs as first argument [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java]
118+
LINE 399: Tainted scope assigned to parameter bs
119+
!! TODO !! Some missing control flow here
120+
LINE 462: Take IF
121+
LINE 470: Calling org.dspace.browse.BrowseEngine.normalizeJumpToValue [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java]
122+
LINE 693: Take ELSE
123+
LINE 698: Take IF
124+
LINE 701: Call scope.getStartsWith() on member scope [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java]
125+
LINE 463: Return the tainted string startsWith
126+
LINE 701: Call OrderFormat.makeSortString with the tainted string as parameter 1 [DSpace/dspace-api/src/main/java/org/dspace/sort/OrderFormat.java]
127+
LINE 57: Tainted string assigned to parameter value
128+
LINE 62: Don't take IF
129+
LINE 68: Don't take IF
130+
LINE 104: Return value (the tainted string)
131+
LINE 701: Return the tainted string
132+
LINE 470: Assign the returned tainted string to focusValue
133+
LINE 472: Calling org.dspace.browse.BrowseEngine.getOffsetForDistinctValue passing focusValue as first argument [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java]
134+
LINE 667: Assign tainted string to parameter value
135+
LINE 670: Don't take IF
136+
LINE 678: Calling org.dspace.browse.BrowseDAO.doDistinctOffsetQuery passing value as argument 2 ; This is an interface, so possible callee can be e.g. org.dspace.browse.BrowseDAOOracle [DSpace/dspace-api/src/main/java/org/dspace/browse/BrowseDAOOracle.java]
137+
LINE 282: Assign tainted string to parameter value
138+
LINE 295: Take ANY
139+
LINE 298/303: RULE APPLICATION: 'Tainted list' from inserted 'Tainted string'
140+
LINE 306: Take ANY
141+
LINE 312: RULE APPLICATION: 'tainted list of strings' -> 'tainted array of strings'.
142+
LINE 312: Call DatabaseManager.query - SINK: 'tainted array of strings' used in a query to database.

benchmarks/GENUINE/DSpace_rules.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
},
1414
{
15-
"comment": "Obtained ServletRequest's poarameter with potentially tainted data.",
15+
"comment": "Obtained ServletRequest's parameter with potentially tainted data.",
1616
"class": "javax.servlet.http.HttpServletRequest",
1717
"method": "getParameter:(Ljava/lang/String;)Ljava/lang/String;",
1818
"result": {
@@ -50,6 +50,15 @@
5050
"taint": "Tainted string"
5151
}
5252
},
53+
{
54+
"comment": "Passing tainted array to DatabaseManager.query is a sink",
55+
"class": "org.dspace.storage.rdbms.DatabaseManager",
56+
"method": "query:(Lorg/dspace/core/Context;Ljava/lang/String;[Ljava/lang/Object;)Lorg/dspace/storage/rdbms/TableRowIterator;",
57+
"sinkTarget": {
58+
"location": "arg2",
59+
"taint": "Tainted array"
60+
}
61+
},
5362
{
5463
"comment": "Writing content of a tainted stream to disk is a sink.",
5564
"class": "java.nio.file.Files",

0 commit comments

Comments
 (0)