Skip to content

Commit 959d9e1

Browse files
javax.servlet-api 3.1.0 update
Updating classes with new API configurations. Added configuration in versionRuleset.xml to prevent displays of anything newer than 3.x versions.
1 parent 54c56d9 commit 959d9e1

8 files changed

+99
-3
lines changed

pom.xml

+7-2
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,20 @@
149149
<dependency>
150150
<groupId>javax.servlet</groupId>
151151
<artifactId>javax.servlet-api</artifactId>
152-
<!-- Note: v3.1.0+ causes compilation errors. So would have to fix to upgrade. -->
153-
<version>3.0.1</version>
152+
<version>3.1.0</version>
154153
<scope>provided</scope>
155154
</dependency>
156155
<dependency>
157156
<groupId>javax.servlet.jsp</groupId>
158157
<artifactId>javax.servlet.jsp-api</artifactId>
159158
<version>2.3.3</version>
160159
<scope>provided</scope>
160+
<exclusions>
161+
<exclusion>
162+
<groupId>javax.servlet</groupId>
163+
<artifactId>javax.servlet-api</artifactId>
164+
</exclusion>
165+
</exclusions>
161166
</dependency>
162167
<dependency>
163168
<groupId>com.io7m.xom</groupId>

src/main/java/org/owasp/esapi/waf/internal/InterceptingHTTPServletRequest.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Enumeration;
2525
import java.util.Vector;
2626

27+
import javax.servlet.ReadListener;
2728
import javax.servlet.ServletInputStream;
2829
import javax.servlet.http.HttpServletRequest;
2930
import javax.servlet.http.HttpServletRequestWrapper;
@@ -171,18 +172,37 @@ public Enumeration getDictionaryParameterNames() {
171172
private class RAFInputStream extends ServletInputStream {
172173

173174
RandomAccessFile raf;
175+
boolean isDone = false;
174176

175177
public RAFInputStream(RandomAccessFile raf) throws IOException {
176178
this.raf = raf;
177179
this.raf.seek(0);
178180
}
179181

180182
public int read() throws IOException {
181-
return raf.read();
183+
int rval = raf.read();
184+
isDone = rval == -1;
185+
return rval;
182186
}
183187

184188
public synchronized void reset() throws IOException {
185189
raf.seek(0);
190+
isDone=false;
191+
}
192+
193+
@Override
194+
public boolean isFinished() {
195+
return isDone;
196+
}
197+
198+
@Override
199+
public boolean isReady() {
200+
return false;
201+
}
202+
203+
@Override
204+
public void setReadListener(ReadListener readListener) {
205+
//NO-OP. Unused in this scope
186206
}
187207
}
188208

src/main/java/org/owasp/esapi/waf/internal/InterceptingServletOutputStream.java

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.RandomAccessFile;
2222

2323
import javax.servlet.ServletOutputStream;
24+
import javax.servlet.WriteListener;
2425

2526
/**
2627
* This class was inspired by ModSecurity for Java by Ivan Ristic. We hook
@@ -161,4 +162,14 @@ public void close() throws IOException {
161162

162163
}
163164

165+
@Override
166+
public boolean isReady() {
167+
return os.isReady();
168+
}
169+
170+
@Override
171+
public void setWriteListener(WriteListener writeListener) {
172+
os.setWriteListener(writeListener);
173+
}
174+
164175
}

src/test/java/org/owasp/esapi/http/MockHttpServletRequest.java

+16
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import javax.servlet.http.HttpServletRequest;
4747
import javax.servlet.http.HttpServletResponse;
4848
import javax.servlet.http.HttpSession;
49+
import javax.servlet.http.HttpUpgradeHandler;
4950
import javax.servlet.http.Part;
5051

5152
/**
@@ -737,4 +738,19 @@ public DispatcherType getDispatcherType() {
737738
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
738739
}
739740

741+
@Override
742+
public long getContentLengthLong() {
743+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
744+
}
745+
746+
@Override
747+
public String changeSessionId() {
748+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
749+
}
750+
751+
@Override
752+
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException {
753+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
754+
}
755+
740756
}

src/test/java/org/owasp/esapi/http/MockHttpServletResponse.java

+16
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Locale;
2525

2626
import javax.servlet.ServletOutputStream;
27+
import javax.servlet.WriteListener;
2728
import javax.servlet.http.Cookie;
2829
import javax.servlet.http.HttpServletResponse;
2930

@@ -279,6 +280,16 @@ public ServletOutputStream getOutputStream() throws IOException {
279280
public void write(int b) throws IOException {
280281
body.append((char)b);
281282
}
283+
284+
@Override
285+
public boolean isReady() {
286+
return false;
287+
}
288+
289+
@Override
290+
public void setWriteListener(WriteListener writeListener) {
291+
//NO-OP
292+
}
282293
};
283294
}
284295

@@ -369,5 +380,10 @@ public void dump() {
369380
public Collection<String> getHeaders(String string) {
370381
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
371382
}
383+
384+
@Override
385+
public void setContentLengthLong(long len) {
386+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
387+
}
372388

373389
}

src/test/java/org/owasp/esapi/http/MockServletContext.java

+5
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,9 @@ public ClassLoader getClassLoader() {
693693
public void declareRoles(String... strings) {
694694
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
695695
}
696+
697+
@Override
698+
public String getVirtualServerName() {
699+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
700+
}
696701
}

src/test/java/org/owasp/esapi/http/MockServletInputStream.java

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.owasp.esapi.http;
1717

18+
import javax.servlet.ReadListener;
1819
import javax.servlet.ServletInputStream;
1920
import java.io.IOException;
2021

@@ -28,6 +29,7 @@ public class MockServletInputStream extends ServletInputStream {
2829

2930
private int next;
3031

32+
private boolean isDone = false;
3133
/**
3234
* constructor
3335
* @param body
@@ -45,7 +47,23 @@ public int read() throws IOException {
4547
if (next < body.length) {
4648
return body[next++];
4749
} else {
50+
isDone = true;
4851
return -1;
4952
}
5053
}
54+
55+
@Override
56+
public boolean isFinished() {
57+
return isDone;
58+
}
59+
60+
@Override
61+
public boolean isReady() {
62+
return false;
63+
}
64+
65+
@Override
66+
public void setReadListener(ReadListener readListener) {
67+
//NO_OP
68+
}
5169
}

versionRuleset.xml

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<ignoreVersion type="regex">^0{0,1}[4-9].*</ignoreVersion>
3434
</ignoreVersions>
3535
</rule>
36+
<rule groupId="javax.servlet" artifactId="javax.servlet-api" comparisonMethod="maven">
37+
<ignoreVersions>
38+
<ignoreVersion type="regex">^0{0,1}[4-9].*</ignoreVersion>
39+
</ignoreVersions>
40+
</rule>
3641
</rules>
3742
</ruleset>
3843
<!--

0 commit comments

Comments
 (0)