Skip to content

Commit 9942889

Browse files
authored
feat: support jakarta jsp (#75)
* resolves #64 * requires java 8 runtime * requires jdk 17 to build due to jakarta module tests * feat: support jakarta jsp * feat: add java-version file * fix: bump project version * fix: add actions * chore: remove travis * docs: initial release documentation * docs: update release notes * feat: add integration test for jakarta JSP * chore: workflow should use batch mode
1 parent 2f151ce commit 9942889

File tree

67 files changed

+4049
-29
lines changed

Some content is hidden

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

67 files changed

+4049
-29
lines changed

.github/workflows/build.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Java CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
- name: Run build
23+
run: |
24+
mvn -B install -PtestJakarta
25+
26+

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ nb-configuration.xml
1818
/jsp/target/
1919
/esapi/target/
2020
/target/
21+
/jakarta/target/
22+
/jakarta-test/target/

.java-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17.0

.travis.yml

-14
This file was deleted.

README.md

+62-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OWASP Java Encoder Project
44
[![Build Status](https://travis-ci.org/OWASP/owasp-java-encoder.svg?branch=main)](https://travis-ci.org/OWASP/owasp-java-encoder) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![javadoc](https://javadoc.io/badge2/org.owasp.encoder/encoder/javadoc.svg)](https://javadoc.io/doc/org.owasp.encoder/encoder)
55

66
Contextual Output Encoding is a computer programming technique necessary to stop
7-
Cross-Site Scripting. This project is a Java 1.5+ simple-to-use drop-in high-performance
7+
Cross-Site Scripting. This project is a Java 1.8+ simple-to-use drop-in high-performance
88
encoder class with little baggage.
99

1010
For more detailed documentation on the OWASP Javca Encoder please visit https://owasp.org/www-project-java-encoder/.
@@ -13,21 +13,31 @@ Start using the OWASP Java Encoders
1313
-----------------------------------
1414
You can download a JAR from [Maven Central](https://search.maven.org/#search|ga|1|g%3A%22org.owasp.encoder%22%20a%3A%22encoder%22).
1515

16-
JSP tags and EL functions are available in the encoder-jsp, also available in [Central](http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.3/encoder-jsp-1.2.3.jar).
16+
JSP tags and EL functions are available in the encoder-jsp, also available:
17+
- [encoder-jakarta-jsp](http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jakarta-jsp/1.2.3/encoder-jakarta-jsp-1.2.3.jar) - Servlet Spec 5.0
18+
- [encoder-jsp](http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.3/encoder-jsp-1.2.3.jar) - Servlet Spec 3.0
1719

18-
The jars are also available in Maven:
20+
The jars are also available in Central:
1921

2022
```xml
2123
<dependency>
2224
<groupId>org.owasp.encoder</groupId>
2325
<artifactId>encoder</artifactId>
24-
<version>1.2.3</version>
26+
<version>1.3.0</version>
2527
</dependency>
2628

29+
<!-- using Servlet Spec 5 in the jakarta.servlet package use: -->
30+
<dependency>
31+
<groupId>org.owasp.encoder</groupId>
32+
<artifactId>encoder-jakarta-jsp</artifactId>
33+
<version>1.3.0</version>
34+
</dependency>
35+
36+
<!-- using the Legacy Servlet Spec in the javax.servlet package use: -->
2737
<dependency>
2838
<groupId>org.owasp.encoder</groupId>
2939
<artifactId>encoder-jsp</artifactId>
30-
<version>1.2.3</version>
40+
<version>1.3.0</version>
3141
</dependency>
3242
```
3343

@@ -48,8 +58,55 @@ Please look at the javadoc for Encode to see the variety of contexts for which y
4858

4959
Happy Encoding!
5060

61+
Building
62+
--------
63+
64+
Due to test cases for the `encoder-jakarta-jsp` project Java 17 is required to package and test
65+
the project. Simply run:
66+
67+
```shell
68+
mvn package
69+
```
70+
71+
To run the Jakarta JSP intgration test, to validate that the JSP Tags and EL work correctly run:
72+
73+
```shell
74+
mvn verify -PtestJakarta
75+
```
76+
77+
* Note that the above test may fail on modern Apple silicon.
78+
79+
Java 9+ Module Names
80+
--------------------
81+
82+
| JAR | Module Name |
83+
|---------------------|-----------------------|
84+
| encoder | owasp.encoder |
85+
| encoder-jakarta-jsp | owasp.encoder.jakarta |
86+
| encoder-jsp | owasp.encoder.jsp |
87+
| encoder-espai | owasp.encoder.esapi |
88+
89+
90+
TagLib
91+
--------------------
92+
93+
| Lib | TagLib |
94+
|---------------------|-----------------------------------------------------------------------------------------------|
95+
| encoder-jakarta-jsp | &lt;%@taglib prefix="e" uri="owasp.encoder.jakarta"%&gt; |
96+
| encoder-jsp | &lt;%@taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project"%&gt; |
97+
98+
5199
News
52100
----
101+
### 2024-08-02 - 1.3.0 Release
102+
The team is happy to announce that version 1.3.0 has been released!
103+
* Minimum JDK Requirement is now Java 8
104+
- Requires Java 17 to build due to test case dependencies.
105+
* Adds Java 9 Module name via Multi-Release Jars (#77).
106+
* Fixed compilation errors with the ESAPI Thunk (#76).
107+
* Adds support for Servlet Spec 5 using the `jakarta.servlet.*` (#75).
108+
- taglib : &lt;%@taglib prefix="e" uri="owasp.encoder.jakarta"%&gt;
109+
53110
### 2020-11-08 - 1.2.3 Release
54111
The team is happy to announce that version 1.2.3 has been released!
55112
* Update to make the manifest OSGi-compliant (#39).

core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<parent>
4343
<groupId>org.owasp.encoder</groupId>
4444
<artifactId>encoder-parent</artifactId>
45-
<version>1.2.3</version>
45+
<version>1.3.0</version>
4646
</parent>
4747

4848
<artifactId>encoder</artifactId>

esapi/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<parent>
4343
<groupId>org.owasp.encoder</groupId>
4444
<artifactId>encoder-parent</artifactId>
45-
<version>1.2.3</version>
45+
<version>1.3.0</version>
4646
</parent>
4747

4848
<artifactId>encoder-esapi</artifactId>

jakarta-test/pom.xml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.3.2</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>org.owasp.encoder.testing</groupId>
12+
<artifactId>jakarta-test</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<packaging>war</packaging>
15+
<name>jakarta-test</name>
16+
<description>Test for OWASP encoder jakarta JSP</description>
17+
<properties>
18+
<java.version>17</java.version>
19+
</properties>
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.owasp.encoder</groupId>
23+
<artifactId>encoder-jakarta-jsp</artifactId>
24+
<version>1.3.0</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-web</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.tomcat.embed</groupId>
32+
<artifactId>tomcat-embed-jasper</artifactId>
33+
<version>10.1.18</version>
34+
<scope>provided</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-tomcat</artifactId>
39+
<version>3.2.2</version>
40+
<scope>provided</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>jakarta.servlet</groupId>
44+
<artifactId>jakarta.servlet-api</artifactId>
45+
<version>6.0.0</version>
46+
<scope>provided</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>jakarta.servlet.jsp</groupId>
50+
<artifactId>jakarta.servlet.jsp-api</artifactId>
51+
<version>3.1.0</version>
52+
<scope>provided</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>jakarta.servlet.jsp.jstl</groupId>
56+
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
57+
<version>3.0.0</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>jakarta.el</groupId>
61+
<artifactId>jakarta.el-api</artifactId>
62+
<version>5.0.1</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.glassfish.web</groupId>
66+
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
67+
<version>3.0.1</version>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.springframework.boot</groupId>
72+
<artifactId>spring-boot-starter-test</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-testcontainers</artifactId>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.testcontainers</groupId>
82+
<artifactId>selenium</artifactId>
83+
<version>1.20.0</version>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.seleniumhq.selenium</groupId>
88+
<artifactId>selenium-remote-driver</artifactId>
89+
<version>4.23.0</version>
90+
<scope>test</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.seleniumhq.selenium</groupId>
94+
<artifactId>selenium-chrome-driver</artifactId>
95+
<version>4.23.0</version>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.testcontainers</groupId>
100+
<artifactId>junit-jupiter</artifactId>
101+
<version>1.20.0</version>
102+
<scope>test</scope>
103+
</dependency>
104+
</dependencies>
105+
106+
<build>
107+
<finalName>jakarta-test</finalName>
108+
<plugins>
109+
<plugin>
110+
<groupId>org.springframework.boot</groupId>
111+
<artifactId>spring-boot-maven-plugin</artifactId>
112+
<configuration>
113+
<mainClass>org.owasp.encoder.testing.jakarta_test.JakartaTestApplication</mainClass>
114+
</configuration>
115+
<executions>
116+
<execution>
117+
<goals>
118+
<goal>repackage</goal>
119+
</goals>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
126+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.owasp.encoder.testing.jakarta_test;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.builder.SpringApplicationBuilder;
6+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7+
8+
@SpringBootApplication(scanBasePackages = "org.owasp.encoder.testing.jakarta_test")
9+
public class JakartaTestApplication extends SpringBootServletInitializer {
10+
11+
@Override
12+
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
13+
return builder.sources(JakartaTestApplication.class);
14+
}
15+
16+
public static void main(String[] args) {
17+
SpringApplication.run(JakartaTestApplication.class, args);
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.owasp.encoder.testing.jakarta_test.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
7+
/**
8+
*
9+
* @author jeremy
10+
*/
11+
@Controller
12+
@RequestMapping("/")
13+
public class HomeController {
14+
15+
@GetMapping("")
16+
public String index() {
17+
return "index";
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.owasp.encoder.testing.jakarta_test.controller;
2+
3+
import org.owasp.encoder.testing.jakarta_test.service.ItemService;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
9+
/**
10+
*
11+
* @author jeremy
12+
*/
13+
@Controller
14+
@RequestMapping("/item")
15+
public class ItemController {
16+
17+
private final ItemService itemService;
18+
19+
public ItemController(ItemService itemService) {
20+
this.itemService = itemService;
21+
}
22+
23+
@GetMapping("/viewItems")
24+
public String viewItems(Model model) {
25+
model.addAttribute("items", itemService.getItems());
26+
return "view-items";
27+
}
28+
}

0 commit comments

Comments
 (0)