public class HostileExtensionDetector extends Object
Browsers use Content-Type headers and file extensions to decide whether to attempt to execute a file in a client context. Examples include javascript in html and ActionScript in .swf (Flash) binaries. Since these runtimes have access to the client-side state of the browser, they represent a potential means to steal session cookie contents and other XSS attacks.
| Constructor and Description |
|---|
HostileExtensionDetector()
Loads the configuration of what are executable file extensions and content types from the given properties
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isExecutableContent(String fileName,
String contentType)
Determines if the file is executable given its file name and content type.
|
boolean |
isExecutableContentType(String contentType)
Determines if the given String contains a substring of a MIME Content Type denoting client-executable active content such that if the
browser opens the file, its execution could have access to the browser DOM etc.
|
boolean |
isExecutableFileExtension(String name)
Determines if the given String has an extension denoting a client-executable active content type such that if the
browser opens the file, its execution could have access to the browser DOM etc.
|
boolean |
isTextContent(String fileName,
String contentType) |
boolean |
isTextContentType(String contentType) |
boolean |
isTextExtension(String fileName) |
public HostileExtensionDetector()
public boolean isExecutableFileExtension(String name)
name - the file name.public boolean isExecutableContentType(String contentType)
contentType - the MIME Content Type string.public boolean isTextExtension(String fileName)
fileName - can be null or empty.public boolean isTextContentType(String contentType)
contentType - the content typepublic boolean isExecutableContent(String fileName, String contentType)
KEY_EXECUTABLE_IF_NO_EXT_NO_MIME
property was set to true (true by default)fileName - the name of the filecontentType - the content typeCopyright © 2018 Atlassian. All rights reserved.