Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update demo testing to include xml to yaml conversion #90

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -42,4 +42,10 @@ 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
diff /tmp/expected_file /tmp/actual_file || diff $expected_file $actual_file

eemcmullan marked this conversation as resolved.
Show resolved Hide resolved
- name: Fail if xml rule is not in analysis output as violation
run: |
actual_file=./output/output.yaml
grep violations -A 1 $actual_file | grep jni-native-code-00000-test -B 1

61 changes: 51 additions & 10 deletions test-data/analysis-output.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
64 changes: 64 additions & 0 deletions test-data/jni-native-code-test.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<ruleset id="jni-native-code-test"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<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.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final"/>
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final"/>
</dependencies>
<targetTechnology id="cloud-readiness"/>
<tag>jni</tag>
</metadata>
<rules>
<rule id="jni-native-code-00000-test">
<when>
<or>
<javaclass references="java.lang.System.load({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="java.lang.System.loadLibrary({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="java.lang.System.mapLibraryName({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="java.lang.Runtime.load({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="java.lang.Runtime.loadLibrary({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="com.sun.jna.{*}">
<location>CONSTRUCTOR_CALL</location>
<location>IMPORT</location>
<location>INHERITANCE</location>
<location>METHOD_CALL</location>
<location>VARIABLE_DECLARATION</location>
</javaclass>
</or>
</when>
<perform>
<hint title="Java native libraries (JNI, JNA)" effort="7" category-id="cloud-mandatory">
<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.
</message>
<link href="https://access.redhat.com/solutions/229443" title="How to load native libraries and access them via JNI in EAP (with or without a module)"/>
<link href="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 ?"/>
<tag>jni</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>
Loading