Difference between revisions of "Projects/OWASP Java Encoder Project"

Jump to: navigation, search
Line 26: Line 26:
| leader_email1 = jeff.ichnowski@gmail.com
| leader_email1 = jeff.ichnowski@gmail.com
| leader_username1 = Jeff_Ichnowski
| leader_username1 = Jeff_Ichnowski
| release_name = OWASP Java Encoder Project
| release_date = 30 March 2012
| release_description = First BETA version
| release_license = BSD
| release_download_link = http://code.google.com/p/owasp-java-encoder
| contributor_name1 = Jim Manico
| contributor_name1 = Jim Manico

Revision as of 15:23, 30 March 2012

Welcome to the OWASP Java Encoder Project

Contextual Output Encoding is a computer programming technique necessary to stop [Cross Site Scripting]. This project is a Java-based simple-to-use drop-in encoder class with little baggage.

What does this OWASP project offer you?
What releases are available for this project?
what is this project?
Name: OWASP Java Encoder Project (home page)
  • This project is a simple-to-use drop-in encoder class with little baggage.
  • No third party libraries or configuration necessary.
  • This code was designed for high-availability/high-performance encoding functionality.
  • The key motivation for the separate project was:
  1. Simple drop-in encoding functionality
  2. Redesigned for performance
  3. More complete API (uri and uri component encoding, etc) in some regards.
  • This is a Java 1.5 project.
License: New BSD License
who is working on this project?
Project Leader(s):
Project Contributor(s):
how can you learn more?
Project Pamphlet: Not Yet Created
Project Presentation:
Mailing list: Mailing List Archives
Project Roadmap: View
Main links:
Key Contacts
current release
OWASP Java Encoder Project 1.1.1 - January 30, 2014 - (download)
Release description: Critical fix of bug described here https://code.google.com/p/owasp-java-encoder/issues/detail?id=4
Rating: Not Rated
last reviewed release
Not Yet Reviewed

other releases

The general API pattern to utilize the Java Encoder Project is "Encode.forContextName(untrustedData)", where "ContextName" is the name of the target context and "untrustedData" in untrusted user input.

For example, to use in a JSP

<input type="text" name="data" value="<%= Encode.forHtmlAttribute(dataValue) %>" />

<textarea name="text"><%= Encode.forHtmlContent(textValue) %>" />

Generally Encode.forHtml(...) is safe but slightly less efficient for the above two contexts (since it encodes more characters than necessary).

For JavaScript string data

<button onclick="alert('<%= Encode.forJavaScriptAttribute(alertMsg) %>');">click me</button>

<script type="text/javascript"> var msg = "<%= Encode.forJavaScriptBlock(message) %>"; alert(msg); </script>

Again generally Encode.forJavaScript is safe for the above two context, but slightly less efficient since it encodes more characters.

Other Contexts

Other contexts can be found in the org.owasp.Encode class methods, including CSS strings, CSS urls, XML contexts, URIs and URI components.

checkout and run "mvn package" (using maven 2.0 or 3.0)