Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 40ec848

Browse files
author
chrisisbeef
committed
Repackaging Source
1 parent c8be1d7 commit 40ec848

File tree

5 files changed

+106
-27
lines changed

5 files changed

+106
-27
lines changed

build-functions.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function get_files($root_dir, $allow_extensions = array( 'js' ), $ignore_files =
200200
$content_chunks = explode(".",$content);
201201
$ext = $content_chunks[count($content_chunks) - 1];
202202
// only include files with desired extensions
203-
if (in_array($ext, $allow_extensions))
203+
if ( ( is_array( $allow_extensions ) && in_array($ext, $allow_extensions) ) || ( is_string( $allow_extensions ) && $allow_extensions == '*' ) )
204204
{
205205
// save file name with path
206206
$all_data[] = $path;
@@ -222,31 +222,13 @@ function get_files($root_dir, $allow_extensions = array( 'js' ), $ignore_files =
222222
return $all_data;
223223
} // end get_files()
224224

225-
function getDirectoryTree( $outerDir, $filters = array() ){
226-
$dirs = array_diff( scandir( $outerDir ), array_merge( Array( ".", "..",".svn" ), $filters ) );
227-
$dir_array = Array();
228-
foreach( $dirs as $d )
229-
$dir_array[ $d ] = is_dir($outerDir."/".$d) ? getDirectoryTree( $outerDir."/".$d, $filters ) : $dir_array[ $d ] = $d;
230-
return $dir_array;
231-
}
232-
233-
function getRelativePath( $a ) {
234-
$o = "";
235-
if ( is_array($a) ) {
236-
foreach( $a as $e ) {
237-
$o .= getRelativePath( $e );
238-
}
239-
}
240-
return $o.$a;
241-
}
242-
243225
function microtime_float() {
244226
list($usec,$sec) = explode(" ",microtime());
245227
return ((float)$usec + (float)$sec);
246228
}
247229

248-
function copydir( $src, $dst ) {
249-
$filelist = get_files($src);
230+
function copydir( $src, $dst, $allow_extensions = array( 'js' ), $ignore_files = array( ), $ignore_regex = '/^_/', $ignore_dirs = array(".","..",".svn") ) {
231+
$filelist = get_files($src, $allow_extensions, $ignore_files, $ignore_regex, $ignore_dirs);
250232
foreach($filelist as $i=>$file) {
251233
$dir_name = substr( $file, 0, strrpos( $file, '/' ) );
252234
if ( !is_dir($dir_name) ) {

build-properties.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
* LICENSE before you use, modify, and/or redistribute this software.
1313
*/
1414

15-
$DOCUMENTATION_DIR = "documentation/";
15+
$DOCUMENTATION_DIR = "documentation";
1616
$SOURCE_DIR = "src/main/javascript";
1717
$RESOURCES_DIR = "src/main/resources";
18+
$LIB_DIR = "lib";
1819
$OUTPUT_DIR = "dist/";
1920
$OUTPUT_RESOURCES = "resources/";
2021
$OUTPUT_DOCUMENTATION = "docs/";
22+
$OUTPUT_LIBS = "lib/";
2123
$OUTPUT_FILE = "esapi.js";
2224
$OUTPUT_FILE_COMPRESSED = "esapi-compressed.js";
2325

build.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,19 @@
6363
fwrite( $fp, $compressed );
6464
fclose($fp);
6565

66-
echo("Finished building $OUTPUT_DIR$OUTPUT_FILE_COMPRESSED (".filesize($OUTPUT_DIR.$OUTPUT_FILE_COMPRESSED)." bytes): Took ".( microtime_float() - $time_start )."s\n\n" );
66+
echo("Finished building $OUTPUT_DIR$OUTPUT_FILE_COMPRESSED (".filesize($OUTPUT_DIR.$OUTPUT_FILE_COMPRESSED)." bytes): Took ".( microtime_float() - $time_start )."s\n" );
6767

68+
echo("\nCopying Resources to $OUTPUT_DIR$OUTPUT_RESOURCES\n");
6869
mkdir($OUTPUT_DIR.'resources');
69-
echo("Copying Resources to $OUTPUT_DIR$OUTPUT_RESOURCES\n");
70-
71-
$dir = dir($RESOURCES_DIR);
7270
copydir($RESOURCES_DIR,$OUTPUT_DIR.$OUTPUT_RESOURCES);
7371

72+
echo("\nCopying Documentation to $OUTPUT_DIR$OUTPUT_DOCUMENTATION\n");
7473
mkdir($OUTPUT_DIR.$OUTPUT_DOCUMENTATION);
75-
copydir($DOCUMENTATION_DIR,$OUTPUT_DIR.$OUTPUT_DOCUMENTATION);
74+
copydir($DOCUMENTATION_DIR,$OUTPUT_DIR.$OUTPUT_DOCUMENTATION, '*' );
7675

76+
echo("\nCopying Libraries to $OUTPUT_DIR$OUTPUT_LIBS\n");
77+
mkdir($OUTPUT_DIR.$OUTPUT_LIBS);
78+
copydir($LIB_DIR,$OUTPUT_DIR.$OUTPUT_LIBS);
7779
echo("\nCleaning Up\n\n");
7880
rmdir($TMP_DIR);
7981

documentation/README

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
======================================================================================
2+
OWASP Enterprise Security API (ESAPI)
3+
4+
This file is part of the Open Web Application Security Project (OWASP)
5+
Enterprise Security API (ESAPI) project. For details, please see
6+
http://www.owasp.org/index.php/ESAPI.
7+
8+
Copyright (c) 2008 - The OWASP Foundation
9+
10+
The ESAPI is published by OWASP under the BSD license. You should read and accept the
11+
LICENSE before you use, modify, and/or redistribute this software.
12+
======================================================================================
13+
14+
Installation:
15+
1. Download the distribution zip from http://owasp-esapi-js.googlecode.com
16+
2. Unzip the distribution zip
17+
3. Create a directory on your server, under the web root called esapi4js
18+
4. Copy either esapi.js or esapi-compressed.js from dist/ to your esapi4js directory
19+
5. Create a lib directory under the esapi4js called lib and copy the contents of dist/lib to that directory
20+
6. Create a resources directory under the esapi4js called resources and copy the contents of dist/resources to that directory
21+
22+
Quick Start:
23+
24+
<!-- esapi4js dependencies -->
25+
<script type="text/javascript" language="JavaScript" src="{your_installation_path}/esapi4js/lib/log4js.js"></script>
26+
<!-- esapi4js configuration -->
27+
<script type="text/javascript" language="JavaScript" src="{your_installation_path}/esapi4js/resources/Base.esapi.properties.js"></script>
28+
<!-- esapi4js core -->
29+
<script type="text/javascript" language="JavaScript" src="{your_installation_path}/esapi4js/esapi.js"></script>
30+
31+
<script type="text/javascript" language="JavaScript">
32+
// Set any custom configuration options here or in an external js file that gets sourced in above.
33+
Base.esapi.properties.logging['ApplicationLogger'] = {
34+
Level: org.owasp.esapi.Logger.ALL,
35+
Appenders: [ new Log4js.ConsoleAppender() ],
36+
LogUrl: true,
37+
LogApplicationName: true,
38+
EncodingRequired: true
39+
};
40+
41+
Base.esapi.properties.application.Name = "My Application v1.0";
42+
43+
// Initialize the api
44+
org.owasp.esapi.ESAPI.initialize();
45+
46+
// Using the logger
47+
$ESAPI.logger().getLogger('ApplicationLogger').info(org.owasp.esapi.Logger.EventType.EVENT_SUCCESS, 'This is a test message');
48+
49+
// Using the encoder
50+
document.writeln( $ESAPI.encoder().encodeForHTML( "<a href=\"http://owasp-esapi-js.googlecode.com\">Check out esapi4js</a>" ) );
51+
52+
// Using the validator
53+
var validateCreditCard = function() {
54+
return $ESAPI.validator().isValidCreditCard( $('CreditCard').value );
55+
}
56+
</script>
57+

jsunit.log

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Initializing...
2+
Done initializing
3+
Opening Test Page "file:///home/cschmidt/projects/esapi-js-tmp/src/test/javascript/testCore.html"
4+
Running test "testNamespace"
5+
Running test "testESAPIInstance"
6+
Running test "testStringEndswith"
7+
Running test "testEncoderEncodeForBase64"
8+
Running test "testHtmlEntityEncode"
9+
Running test "testHtmlEntityDecode"
10+
Running test "testEncoderCananocolize"
11+
Running test "testEncoderCananocolizeWithMultipleEncodings"
12+
Running test "testEncoderNormalize"
13+
Running test "testEncoderEncodeForHTML"
14+
Running test "testEncoderEncoderFormHTMLAttribute"
15+
Running test "testEncoderEncodeForCSS"
16+
Running test "testEncoderEncodeForJavascript"
17+
Running test "testEncoderEncodeForURL"
18+
Running test "testGetElementById"
19+
Running test "testArrayEach"
20+
Running test "testArrayContains"
21+
Running test "testPushbackString"
22+
Running test "testPreparedString"
23+
Running test "testJavascriptCodecEncode"
24+
Running test "testJavascriptCodecDecode"
25+
Running test "testCSSCodecEncode"
26+
Running test "testCSSCodecDecode"
27+
Running test "testPercentCodecEncode"
28+
Running test "testPercentCodecDecode"
29+
Running test "testStringCharCodeAt"
30+
Running test "testLoggingWithDefaultConfig"
31+
Running test "testLocale"
32+
Running test "testDefaultLocale"
33+
Running test "testDefaultResourceBundle"
34+
Running test "testCustomResourceBundle"
35+
Running test "testCreditCardValidationRule"
36+
Done (1.447 seconds)

0 commit comments

Comments
 (0)