From 9509908445c61d36ed91c7ef371761fe58f8c87f Mon Sep 17 00:00:00 2001 From: Emily McMullan Date: Mon, 23 Oct 2023 11:17:44 -0400 Subject: [PATCH] update demo testing to include xml to yaml conversion (#90) * update demo testing to include xml to yaml conversion Signed-off-by: Emily McMullan * include cloud-readiness as target for test Signed-off-by: Emily McMullan * remove gh task Signed-off-by: Emily McMullan --------- Signed-off-by: Emily McMullan --- .github/workflows/testing.yaml | 4 +- test-data/analysis-output.yaml | 61 +++++++++++++++++---- test-data/jni-native-code-test.windup.xml | 64 +++++++++++++++++++++++ 3 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 test-data/jni-native-code-test.windup.xml diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 01cadf3..526057f 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -20,7 +20,7 @@ jobs: - name: Run analysis test and copy output run: | - RUNNER_IMG=localhost/kantra:latest ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --target cloud-readiness + RUNNER_IMG=localhost/kantra:latest ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --rules ./test-data/jni-native-code-test.windup.xml --target cloud-readiness - name: Fail if analysis output does not match expected run: | @@ -42,4 +42,4 @@ jobs: actual_file=./output/dependencies.yaml sed 's/^[ \t-]*//' $expected_file | sort -s > /tmp/expected_file sed 's/^[ \t-]*//' $actual_file | sort -s > /tmp/actual_file - diff /tmp/expected_file /tmp/actual_file || diff $expected_file $actual_file \ No newline at end of file + diff /tmp/expected_file /tmp/actual_file || diff $expected_file $actual_file diff --git a/test-data/analysis-output.yaml b/test-data/analysis-output.yaml index 8943433..029478f 100644 --- a/test-data/analysis-output.yaml +++ b/test-data/analysis-output.yaml @@ -1,3 +1,38 @@ +- description: This ruleset detects Java Native Interface (JNI) and Java Native Access (JNA) code, which may be problematic when migrating an application to a cloud environment. + violations: + jni-native-code-00000-test: + description: |- + Java native libraries (JNI, JNA) + Java native libraries might not run in a cloud or container environment.. Recommendations. * Review the purpose of the native library in your application.. * Check whether the native library is compatible with a cloud environment.. * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module.. * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. + category: mandatory + labels: + - konveyor.io/target=cloud-readiness + - konveyor.io/source + - jni + - "" + incidents: + - uri: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java + message: Java native libraries might not run in a cloud or container environment.. Recommendations. * Review the purpose of the native library in your application.. * Check whether the native library is compatible with a cloud environment.. * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module.. * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. + codeSnip: " 1 package io.konveyor.demo.config;\n 2 \n 3 import java.io.FileInputStream;\n 4 import java.io.InputStream;\n 5 import java.util.Properties;\n 6 \n 7 public class ApplicationConfiguration {\n 8 \n 9 \tprivate Properties config;\n 10 \n 11 \tpublic ApplicationConfiguration() {\n 12 \t\tsuper();\n 13 \t\tthis.config = loadProperties();\n 14 \n 15 \t}\n 16 \n 17 \tprivate Properties loadProperties() {\n 18 \t\tProperties properties = new Properties();\n 19 \n 20 \t\ttry (InputStream inputStream = new FileInputStream(\"/opt/config/persistence.properties\")) {\n 21 \n 22 \t\t\tproperties.load(inputStream);\n 23 \n 24 \t\t} catch (Exception e) {\n 25 \t\t\tSystem.out.println(\"Exception: \" + e);\n 26 \t\t}\n 27 \n 28 \t\treturn properties;\n 29 \t}\n 30 \n 31 \tpublic String getProperty (String name) {\n 32 \t\treturn config.getProperty(name);\n 33 \t}\n 34 \n 35 \n 36 \n 37 }\n" + lineNumber: 13 + variables: + file: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java + kind: Constructor + name: ApplicationConfiguration + - uri: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java + message: Java native libraries might not run in a cloud or container environment.. Recommendations. * Review the purpose of the native library in your application.. * Check whether the native library is compatible with a cloud environment.. * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module.. * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. + codeSnip: " 1 package io.konveyor.demo.config;\n 2 \n 3 import java.io.FileInputStream;\n 4 import java.io.InputStream;\n 5 import java.util.Properties;\n 6 \n 7 public class ApplicationConfiguration {\n 8 \n 9 \tprivate Properties config;\n 10 \n 11 \tpublic ApplicationConfiguration() {\n 12 \t\tsuper();\n 13 \t\tthis.config = loadProperties();\n 14 \n 15 \t}\n 16 \n 17 \tprivate Properties loadProperties() {\n 18 \t\tProperties properties = new Properties();\n 19 \n 20 \t\ttry (InputStream inputStream = new FileInputStream(\"/opt/config/persistence.properties\")) {\n 21 \n 22 \t\t\tproperties.load(inputStream);\n 23 \n 24 \t\t} catch (Exception e) {\n 25 \t\t\tSystem.out.println(\"Exception: \" + e);\n 26 \t\t}\n 27 \n 28 \t\treturn properties;\n 29 \t}\n 30 \n 31 \tpublic String getProperty (String name) {\n 32 \t\treturn config.getProperty(name);\n 33 \t}\n 34 \n 35 \n 36 \n 37 }\n" + lineNumber: 22 + variables: + file: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java + kind: Method + name: loadProperties + links: + - url: https://access.redhat.com/solutions/229443 + title: How to load native libraries and access them via JNI in EAP (with or without a module) + - url: https://access.redhat.com/solutions/1444643 + title: Is it supported to compile the JNI code as 32-bit shared libraries and use it in 64-bit compiled Java code ? + effort: 7 - name: azure/springboot description: Identify Zipkin dependencies. skipped: @@ -208,6 +243,12 @@ - windup-discover-spring-configuration - windup-discover-jpa-configuration - windup-discover-web-configuration + - discover-license + - discover-manifest-file + - windup-discover-spring-configuration + - windup-discover-jpa-configuration + - windup-discover-web-configuration + - windup-discover-jpa-configuration - name: droolsjbpm description: This ruleset provides help for migrating to a unified KIE (Knowledge Is Everything) API in the upgrade from version 5 to 6. skipped: @@ -1580,17 +1621,17 @@ - jca-00000 - local-storage-00003 - local-storage-00004 - - session-00000 - java-rmi-00000 + - session-00000 - logging-0001 + - local-storage-00002 - socket-communication-00001 - - local-storage-00005 - - mail-00000 - - logging-0000 - session-00001 + - logging-0000 + - mail-00000 - java-rpc-00000 - - local-storage-00002 - socket-communication-00000 + - local-storage-00005 - name: os/windows description: This is a ruleset for Windows operating system specific rules while migrating to Linux operating system. skipped: @@ -1779,8 +1820,8 @@ - Sustain=Properties - Embedded=Properties - Other=Properties - - Spring configuration properties annotation detected - Spring Properties + - Spring configuration properties annotation detected - Spring Scheduled - Embedded framework - Spring Scheduled - Java Threads @@ -1794,9 +1835,9 @@ - Inversion of Control=CDI - Java EE=CDI - Java EE JSON-P - - Execute=Java EE JSON-P - Processing=Java EE JSON-P - Java EE=Java EE JSON-P + - Execute=Java EE JSON-P - Servlet - Java Servlet - HTTP=Servlet @@ -1812,17 +1853,17 @@ - Connect=JNI - Other=JNI - Java EE=JNI + - Java EE=Mail - Mail usage - Connect=Mail - Other=Mail - - Java EE=Mail - - JCA usage - Connect=JCA - Other=JCA - Java EE=JCA + - JCA usage + - Configuration Management=Spring Properties - Embedded=Spring Properties - Sustain=Spring Properties - - Configuration Management=Spring Properties unmatched: - technology-usage-web-01000 - technology-usage-web-01100 diff --git a/test-data/jni-native-code-test.windup.xml b/test-data/jni-native-code-test.windup.xml new file mode 100644 index 0000000..815a7c5 --- /dev/null +++ b/test-data/jni-native-code-test.windup.xml @@ -0,0 +1,64 @@ + + + + + This ruleset detects Java Native Interface (JNI) and Java Native Access (JNA) code, which may be problematic when migrating an application to a cloud environment. + + + + + + + jni + + + + + + + METHOD_CALL + + + METHOD_CALL + + + METHOD_CALL + + + METHOD_CALL + + + METHOD_CALL + + + CONSTRUCTOR_CALL + IMPORT + INHERITANCE + METHOD_CALL + VARIABLE_DECLARATION + + + + + + + Java native libraries might not run in a cloud or container environment. + + Recommendations + + * Review the purpose of the native library in your application. + * Check whether the native library is compatible with a cloud environment. + * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module. + * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. + + + + jni + + + + + \ No newline at end of file