Bug 47616 - java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource при запуске тестового приложения
Summary: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a clas...
Status: NEW
Alias: None
Product: Branch p10
Classification: Unclassified
Component: owasp-esapi-java (show other bugs)
Version: не указана
Hardware: x86_64 Linux
: P5 normal
Assignee: viy
QA Contact: qa-p10@altlinux.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-15 20:27 MSK by Evgeny Shesteperov
Modified: 2023-09-16 09:38 MSK (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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