Bug 47616

Summary: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource при запуске тестового приложения
Product: Branch p10 Reporter: Evgeny Shesteperov <alimektor>
Component: owasp-esapi-javaAssignee: viy <viy>
Status: NEW --- QA Contact: qa-p10 <qa-p10>
Severity: normal    
Priority: P5    
Version: не указана   
Hardware: x86_64   
OS: Linux   

Description Evgeny Shesteperov 2023-09-15 20:27:33 MSK
Версия

-   owasp-esapi-java-2.1.0-alt1_10jpp8

Шаги воспроизведения

Установленные пакеты:

    # apt-get install -y owasp-esapi-java owasp-esapi-java-doc owasp-esapi-java-javadoc java-17-openjdk-devel java-17-openjdk-headless junit

Согласно
https://github.com/ESAPI/esapi-java-legacy/wiki/Example:-Hello-World
создал тест JUnit:

    $ mkdir -p myPackage && \
    cat > myPackage/SimpleTest.java << '_EOF_'
    package myPackage;

    import org.junit.*;
    import static org.junit.Assert.*;
    import org.owasp.esapi.ESAPI;
    import org.owasp.esapi.Validator;
    import java.util.*;

    public class SimpleTest {
        @Test
        public void testIsValidEmail() {
          Validator instance = ESAPI.validator();
              assertTrue(instance.isValidInput("test", "jeff.williams@aspectsecurity.com", "Email",
              100,false));
        }
        public static void main(String args[]) {
             org.junit.runner.JUnitCore.main("myPackage.SimpleTest");
        }
    }
    _EOF_

Собрать тестовое приложение:

    $ javac -cp "$PWD:/usr/share/java/junit.jar:/usr/share/java/owasp-esapi-java/esapi.jar" myPackage/SimpleTest.java

Запустить тестовое приложение:

    $ java -cp "$PWD:/usr/share/java/junit.jar:/usr/share/java/hamcrest/core.jar:/usr/share/java/owasp-esapi-java/esapi.jar" myPackage/SimpleTest

Ожидаемый результат: пройденный тест JUnit.

Фактический результат: ошибки запуска: не находит ESAPI.properties

    .Attempting to load ESAPI.properties via file I/O.
    Attempting to load ESAPI.properties as resource file via file I/O.
    Not found in 'org.owasp.esapi.resources' directory or file not readable: /home/test/ESAPI.properties
    Not found in SystemResource Directory/resourceDirectory: .esapi/ESAPI.properties
    Not found in 'user.home' (/home/test) directory: /home/test/esapi/ESAPI.properties
    Loading ESAPI.properties via file I/O failed. Exception was: java.io.FileNotFoundException
    Attempting to load ESAPI.properties via the classpath.
    ESAPI.properties could not be loaded by any means. Fail. Exception was: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource.

Ссылки:

-   https://stackoverflow.com/questions/7696423/trying-to-use-esapi-but-getting-error