Skip to content

Commit

Permalink
feat: support jakarta jsp (#75)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jeremylong authored Aug 2, 2024
1 parent 2f151ce commit 9942889
Show file tree
Hide file tree
Showing 67 changed files with 4,049 additions and 29 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java CI

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run build
run: |
mvn -B install -PtestJakarta
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ nb-configuration.xml
/jsp/target/
/esapi/target/
/target/
/jakarta/target/
/jakarta-test/target/
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

67 changes: 62 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OWASP Java Encoder Project
[![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)

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

For more detailed documentation on the OWASP Javca Encoder please visit https://owasp.org/www-project-java-encoder/.
Expand All @@ -13,21 +13,31 @@ Start using the OWASP Java Encoders
-----------------------------------
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).

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).
JSP tags and EL functions are available in the encoder-jsp, also available:
- [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
- [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

The jars are also available in Maven:
The jars are also available in Central:

```xml
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
</dependency>

<!-- using Servlet Spec 5 in the jakarta.servlet package use: -->
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-jakarta-jsp</artifactId>
<version>1.3.0</version>
</dependency>

<!-- using the Legacy Servlet Spec in the javax.servlet package use: -->
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-jsp</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
</dependency>
```

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

Happy Encoding!

Building
--------

Due to test cases for the `encoder-jakarta-jsp` project Java 17 is required to package and test
the project. Simply run:

```shell
mvn package
```

To run the Jakarta JSP intgration test, to validate that the JSP Tags and EL work correctly run:

```shell
mvn verify -PtestJakarta
```

* Note that the above test may fail on modern Apple silicon.

Java 9+ Module Names
--------------------

| JAR | Module Name |
|---------------------|-----------------------|
| encoder | owasp.encoder |
| encoder-jakarta-jsp | owasp.encoder.jakarta |
| encoder-jsp | owasp.encoder.jsp |
| encoder-espai | owasp.encoder.esapi |


TagLib
--------------------

| Lib | TagLib |
|---------------------|-----------------------------------------------------------------------------------------------|
| encoder-jakarta-jsp | &lt;%@taglib prefix="e" uri="owasp.encoder.jakarta"%&gt; |
| encoder-jsp | &lt;%@taglib prefix="e" uri="https://www.owasp.org/index.php/OWASP_Java_Encoder_Project"%&gt; |


News
----
### 2024-08-02 - 1.3.0 Release
The team is happy to announce that version 1.3.0 has been released!
* Minimum JDK Requirement is now Java 8
- Requires Java 17 to build due to test case dependencies.
* Adds Java 9 Module name via Multi-Release Jars (#77).
* Fixed compilation errors with the ESAPI Thunk (#76).
* Adds support for Servlet Spec 5 using the `jakarta.servlet.*` (#75).
- taglib : &lt;%@taglib prefix="e" uri="owasp.encoder.jakarta"%&gt;

### 2020-11-08 - 1.2.3 Release
The team is happy to announce that version 1.2.3 has been released!
* Update to make the manifest OSGi-compliant (#39).
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<parent>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-parent</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
</parent>

<artifactId>encoder</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion esapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<parent>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-parent</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
</parent>

<artifactId>encoder-esapi</artifactId>
Expand Down
126 changes: 126 additions & 0 deletions jakarta-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.owasp.encoder.testing</groupId>
<artifactId>jakarta-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jakarta-test</name>
<description>Test for OWASP encoder jakarta JSP</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder-jakarta-jsp</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>10.1.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>3.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>selenium</artifactId>
<version>1.20.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>4.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.20.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>jakarta-test</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.owasp.encoder.testing.jakarta_test.JakartaTestApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.owasp.encoder.testing.jakarta_test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication(scanBasePackages = "org.owasp.encoder.testing.jakarta_test")
public class JakartaTestApplication extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(JakartaTestApplication.class);
}

public static void main(String[] args) {
SpringApplication.run(JakartaTestApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.owasp.encoder.testing.jakarta_test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
*
* @author jeremy
*/
@Controller
@RequestMapping("/")
public class HomeController {

@GetMapping("")
public String index() {
return "index";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.owasp.encoder.testing.jakarta_test.controller;

import org.owasp.encoder.testing.jakarta_test.service.ItemService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
*
* @author jeremy
*/
@Controller
@RequestMapping("/item")
public class ItemController {

private final ItemService itemService;

public ItemController(ItemService itemService) {
this.itemService = itemService;
}

@GetMapping("/viewItems")
public String viewItems(Model model) {
model.addAttribute("items", itemService.getItems());
return "view-items";
}
}
Loading

0 comments on commit 9942889

Please sign in to comment.