vdbaan / owasp-java-validator

2 stars 13 forks source link

Doesnt work with jdk 8 #1

Open javabeanz opened 8 years ago

javabeanz commented 8 years ago

when i build with jdk 1.8.0-b66 some tests are failing :

Tests in error: ESAPIValidatorTest.testGetValidDate:72 ╗ Validation June 23, 1967 is not a dat ... ESAPIValidatorTest.testGetValidDirectoryPath:108 ╗ Validation Not a valid file ... ESAPIValidatorTest.testIsValidDouble:203 ╗ Validation value lower than max ESAPIValidatorTest.testIsValidInteger:324 ╗ Validation value lower than max ESAPIValidatorTest.testIsValidNumber:430 ╗ Validation value lower than max

vdbaan commented 8 years ago

Thank you for helping to improve this repo.

I've implemented some slight changes based on the issue. Of which the main one is related to the testGetValidDirectoryPath which now checks if the tests are run against a Windows machine or not.

Unfortunately I can't reproduce the other issues. Would it be possible to provide more detail regarding those.

Thanks in advance.

javabeanz commented 8 years ago

Full build output after git pull :

[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] OWASP Validators Parent [INFO] OWASP Validators [INFO] OWASP Validator ESAPI Thunk [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building OWASP Validators Parent 0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ validator-parent --- [INFO] [INFO] --- cobertura-maven-plugin:2.5.2:clean (default) @ validator-parent --- [INFO] Skipping cobertura mojo for project with packaging type 'pom' [INFO] [INFO] --- jacoco-maven-plugin:0.7.5.201505241946:prepare-agent (default) @ validator-parent --- [INFO] argLine set to -javaagent:D:\temp\m2\repo\org\jacoco\org.jacoco.agent\0.7.5.201505241946\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=D:\projects\owasp-java-validator\target\jacoco.exec [INFO] [INFO] --- jacoco-maven-plugin:0.7.5.201505241946:report (report) @ validator-parent --- [INFO] Skipping JaCoCo execution due to missing execution data file:D:\projects\owasp-java-validator\target\jacoco.exec [INFO] [INFO] >>> maven-source-plugin:2.4:jar (attach-sources) @ validator-parent >>> [INFO] [INFO] --- jacoco-maven-plugin:0.7.5.201505241946:prepare-agent (default) @ validator-parent --- [INFO] argLine set to -javaagent:D:\temp\m2\repo\org\jacoco\org.jacoco.agent\0.7.5.201505241946\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=D:\projects\owasp-java-validator\target\jacoco.exec [INFO] [INFO] <<< maven-source-plugin:2.4:jar (attach-sources) @ validator-parent <<< [INFO] [INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ validator-parent --- [INFO] [INFO] --- maven-javadoc-plugin:2.10.1:jar (attach-javadocs) @ validator-parent --- [INFO] Not executing Javadoc as the project is not a Java classpath-capable package [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ validator-parent --- [INFO] Installing D:\projects\owasp-java-validator\pom.xml to D:\temp\m2\repo\org\owasp\validator\validator-parent\0.1-SNAPSHOT\validator-parent-0.1-SNAPSHOT.pom [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building OWASP Validators 0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ validator --- [INFO] Deleting D:\projects\owasp-java-validator\core\target [INFO] [INFO] --- cobertura-maven-plugin:2.5.2:clean (default) @ validator --- [INFO] [INFO] --- jacoco-maven-plugin:0.7.5.201505241946:prepare-agent (default) @ validator --- [INFO] argLine set to -javaagent:D:\temp\m2\repo\org\jacoco\org.jacoco.agent\0.7.5.201505241946\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=D:\projects\owasp-java-validator\core\target\jacoco.exec [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ validator --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory D:\projects\owasp-java-validator\core\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ validator --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 28 source files to D:\projects\owasp-java-validator\core\target\classes [INFO] /D:/projects/owasp-java-validator/core/src/main/java/org/owasp/validator/ChainedValidators.java: D:\projects\owasp-java-validator\core\src\main\java\org\owasp\validator\ChainedValidators.java uses unchecked or unsafe operations. [INFO] /D:/projects/owasp-java-validator/core/src/main/java/org/owasp/validator/ChainedValidators.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ validator --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory D:\projects\owasp-java-validator\core\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ validator --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to D:\projects\owasp-java-validator\core\target\test-classes [INFO] /D:/projects/owasp-java-validator/core/src/test/java/org/owasp/validator/ValidatorTest.java: D:\projects\owasp-java-validator\core\src\test\java\org\owasp\validator\ValidatorTest.java uses unchecked or unsafe operations. [INFO] /D:/projects/owasp-java-validator/core/src/test/java/org/owasp/validator/ValidatorTest.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ validator --- [INFO] Surefire report directory: D:\projects\owasp-java-validator\core\target\surefire-reports


T E S T S

Running org.owasp.validator.ESAPIValidatorTest getValidDate getValidCreditCard Tests run: 11, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.034 sec <<< FAILURE! - in org.owasp.validator.ESAPIValidatorTest testIsValidDouble(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0.028 sec <<< ERROR! org.owasp.validator.ValidationException: value lower than max at org.owasp.validator.NumberValidator.validate(NumberValidator.java:161) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:84) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:110) at org.owasp.validator.ESAPIValidatorTest.testIsValidDouble(ESAPIValidatorTest.java:209)

testIsValidNumber(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0.001 sec <<< ERROR! org.owasp.validator.ValidationException: value lower than max at org.owasp.validator.NumberValidator.validate(NumberValidator.java:161) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:84) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:110) at org.owasp.validator.ESAPIValidatorTest.testIsValidNumber(ESAPIValidatorTest.java:436)

testIsValidInteger(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0 sec <<< ERROR! org.owasp.validator.ValidationException: value lower than max at org.owasp.validator.NumberValidator.validate(NumberValidator.java:161) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:84) at org.owasp.validator.NumberValidator.validate(NumberValidator.java:110) at org.owasp.validator.ESAPIValidatorTest.testIsValidInteger(ESAPIValidatorTest.java:330)

testIsValidDate(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0.001 sec <<< ERROR! org.owasp.validator.ValidationException: June 23, 1967 is not a date at org.owasp.validator.DateValidator.validate(DateValidator.java:76) at org.owasp.validator.ESAPIValidatorTest.testIsValidDate(ESAPIValidatorTest.java:72)

testIsValidDirectoryPath(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0 sec <<< ERROR! org.owasp.validator.ValidationException: Not a valid file path at org.owasp.validator.base.FilePathValidator.validate(FilePathValidator.java:57) at org.owasp.validator.ESAPIValidatorTest.testIsValidDirectoryPath(ESAPIValidatorTest.java:94)

Running org.owasp.validator.ValidatorTest test CC test CC2 Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.104 sec - in org.owasp.validator.ValidatorTest

Results :

Tests in error: ESAPIValidatorTest.testIsValidDate:72 » Validation June 23, 1967 is not a date ESAPIValidatorTest.testIsValidDirectoryPath:94 » Validation Not a valid file p... ESAPIValidatorTest.testIsValidDouble:209 » Validation value lower than max ESAPIValidatorTest.testIsValidInteger:330 » Validation value lower than max ESAPIValidatorTest.testIsValidNumber:436 » Validation value lower than max

Tests run: 27, Failures: 0, Errors: 5, Skipped: 0

[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] OWASP Validators Parent ........................... SUCCESS [ 1.150 s] [INFO] OWASP Validators .................................. FAILURE [ 1.721 s] [INFO] OWASP Validator ESAPI Thunk ....................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.948 s [INFO] Finished at: 2015-11-29T18:42:31+01:00 [INFO] Final Memory: 19M/47M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project validator: There are test failures. [ERROR] [ERROR] Please refer to D:\projects\owasp-java-validator\core\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :validator

vdbaan commented 8 years ago

I've made two changes, one related to the Windows filesystem and one related to Locales. Your errors were most likely relate to these two. Would you mind testing again and if you have no more errors, close the comment. Thanks in advance.

Cheers, Steven.

javabeanz commented 8 years ago

several tests have been fixed, but not all :

[INFO] /D:/projects/owasp-java-validator/core/src/test/java/org/owasp/validator/ ValidatorTest.java: D:\projects\owasp-java-validator\core\src\test\java\org\owas p\validator\ValidatorTest.java uses unchecked or unsafe operations. [INFO] /D:/projects/owasp-java-validator/core/src/test/java/org/owasp/validator/ ValidatorTest.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ validator --- [INFO] Surefire report directory: D:\projects\owasp-java-validator\core\target\s urefire-reports


T E S T S

Running org.owasp.validator.ESAPIValidatorTest getValidDate getValidCreditCard Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.048 sec <<< F AILURE! - in org.owasp.validator.ESAPIValidatorTest testIsValidDate(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0.022 sec <<< ERROR! org.owasp.validator.ValidationException: June 23, 1967 is not a date at org.owasp.validator.DateValidator.validate(DateValidator.java:76) at org.owasp.validator.ESAPIValidatorTest.testIsValidDate(ESAPIValidator Test.java:72)

Running org.owasp.validator.ValidatorTest test CC test CC2 Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.103 sec - in org.owasp.validator.ValidatorTest

Results :

Tests in error: ESAPIValidatorTest.testIsValidDate:72 ╗ Validation June 23, 1967 is not a date

Tests run: 27, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] OWASP Validators Parent ........................... SUCCESS [ 6.163 s] [INFO] OWASP Validators .................................. FAILURE [ 3.835 s] [INFO] OWASP Validator ESAPI Thunk ....................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE

javabeanz commented 8 years ago

this also failed on jdk 7.

vdbaan commented 8 years ago

I've fixed the pattern for the DateValidator, can you confirm that it passes the test. Thanks in advance.

javabeanz commented 8 years ago

jdk 7 :

Running org.owasp.validator.ESAPIValidatorTest getValidDate getValidCreditCard Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.048 sec <<< AILURE! - in org.owasp.validator.ESAPIValidatorTest testIsValidDate(org.owasp.validator.ESAPIValidatorTest) Time elapsed: 0.013 s <<< ERROR! org.owasp.validator.ValidationException: June 23, 1967 is not a date at org.owasp.validator.DateValidator.validate(DateValidator.java:76) at org.owasp.validator.ESAPIValidatorTest.testIsValidDate(ESAPIValidat Test.java:73)

Running org.owasp.validator.ValidatorTest test CC test CC2 Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.118 sec - i org.owasp.validator.ValidatorTest

Results :

Tests in error: ESAPIValidatorTest.testIsValidDate:73 ╗ Validation June 23, 1967 is not a da

Tests run: 27, Failures: 0, Errors: 1, Skipped: 0

[INFO] ----------------------------------------------------------------------- [INFO] Reactor Summary: [INFO] [INFO] OWASP Validators Parent ........................... SUCCESS [ 5.463 s] [INFO] OWASP Validators .................................. FAILURE [ 3.734 s] [INFO] OWASP Validator ESAPI Thunk ....................... SKIPPED [INFO] ----------------------------------------------------------------------- [INFO] BUILD FAILURE [INFO] ----------------------------------------------------------------------- [INFO] Total time: 9.355 s [INFO] Finished at: 2015-12-10T18:40:50+01:00 [INFO] Final Memory: 19M/46M [INFO] ----------------------------------------------------------------------- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin: 18.1:test (default-test) on project validator: There are test failures. [ERROR] [ERROR] Please refer to D:\projects\owasp-java-validator\core\target\surefire- ports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e sw ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please r d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureE eption [ERROR] [ERROR] After correcting the problems, you can resume the build with the comma

[ERROR] mvn -rf :validator D:\projects\owasp-java-validator>

Please adjust the travis build so it builds and checks your builds with jdk 7 and jdk 8 as they are supposed to.

vdbaan commented 8 years ago

I'm running test with both jdk7 and jdk8 locally. I'm starting to suspect that there is a locale issue here that has to be fixed (which were also the root causes for the other issues that you reported). Could you share your locale with me, so we can find a solution.

vdbaan commented 8 years ago

Hi javabeanz, could you please share your locale with me so I can find a solution. Thank you.

javabeanz commented 8 years ago

Hi vdbaan, it's doesn't fix all, but my pull request fixes the failing date test on my pc. Maybe it's useful for you.