Repository: Azure/appcat-konveyor-rulesets
Pull request #77: Update java version upgrade rules
Author: login: haoozhang
Created: 2025-05-09T08:17:51Z | Merged: 2025-05-13T02:55:51Z



Diff:
diff --git a/default/generated/azure/05-azure-java-version.yaml b/default/generated/azure/05-azure-java-version.yaml
index 49e3a392..935d607f 100644
--- a/default/generated/azure/05-azure-java-version.yaml
+++ b/default/generated/azure/05-azure-java-version.yaml
@@ -1,6 +1,6 @@
 - category: mandatory
   customVariables: []
-  description: Non-LTS version Java
+  description: Non-LTS Java version
   effort: 3
   labels:
   - konveyor.io/target=azure-appservice
@@ -12,17 +12,8 @@
   - version
   links: []
   message: |-
-    The application is using non-LTS version Java. JDK on LTS version is recommended, i.e. **Java 8**, **Java 11** or **Java 17**.
-
-     * Choose a **supported Java version**: Determine the most suitable supported Java version provided by Azure. As of now, Azure supports Java 8, Java 11, and Java 17.
-
-     * **Update Java Development Kit** (JDK): Update the JDK in your development environment and build pipelines to the chosen supported version. This ensures that your application is built and packaged using the compatible Java version.
-
-     * Address **code compatibility**: Review your application's codebase for any potential compatibility issues with the target Java version. Update deprecated APIs or features, address any language or library changes, and ensure that your code follows best practices and standards.
-
-     * **Test thoroughly**: Execute a comprehensive testing process to verify the compatibility and functionality of your application with the new Java version. Perform unit tests, integration tests, and system tests to validate that all components and dependencies work as expected.
-
-     * **Monitor performance**: Once migrated to the supported Java version, closely monitor the performance of your application in the Azure environment. Utilize Azure Monitoring tools and logging mechanisms to identify any performance bottlenecks or issues that may arise due to the Java version change.
+    The application is using non-LTS Java version. It is strongly recommended to plan and execute a migration strategy to upgrade your application to a LTS Java version.
+    Long-term supported Java versions receive long-term support (LTS) from the Java community, including bug fixes and updates. Migrating to a supported version provides you with a stable and well-maintained platform for your application.
   ruleID: azure-java-version-01000
   when:
     as: result
@@ -31,10 +22,11 @@
       - pom.xml
       namespaces:
         m: http://maven.apache.org/POM/4.0.0
+      # match: 9, 10, 12, 13, 14, 15, 16, 19, 20, optional any suffix
       xpath: //m:java.version[matches(text(), '(9|10|12|13|14|15|16|19|20).*')]
 - category: mandatory
   customVariables: []
-  description: Java version found to be lower than JAVA_8
+  description: Legacy Java version
   effort: 3
   labels:
   - konveyor.io/target=azure-appservice
@@ -46,14 +38,8 @@
   - version
   links: []
   message: |-
-    The application is using a Java version lower than Java 8. JDK on LTS version is recommended, i.e. **Java 8**, **Java 11** or **Java 17**.
-     It is strongly recommended to plan and execute a migration strategy to upgrade your application to a newer supported Java version.
-
-     * **Unsupported Java versions**: Azure supports Java 8, Java 11, and Java 17. Versions of Java older than Java 8 are not supported, which means you may encounter compatibility issues and security vulnerabilities.
-
-     * **Security risks**: Older Java versions may have known security vulnerabilities that can expose your application and infrastructure to potential attacks. Migrating to a supported version ensures that you benefit from the latest security patches and updates.
-
-     * **Long-term support**: Supported Java versions receive long-term support (LTS) from the Java community, including bug fixes and updates. Migrating to a supported version provides you with a stable and well-maintained platform for your application.
+    The application is using an old Java version. It is strongly recommended to plan and execute a migration strategy to upgrade your application to a newer supported Java version.
+    Older Java versions may have known security vulnerabilities that can expose your application and infrastructure to potential attacks. Migrating to a supported version ensures that you benefit from the latest security patches and updates.
   ruleID: azure-java-version-02000
   when:
     as: result
@@ -62,4 +48,5 @@
       - pom.xml
       namespaces:
         m: http://maven.apache.org/POM/4.0.0
-      xpath: //m:java.version[matches(text(), '1\.[0-7]')]
+      # match: 1.0 to 1.10, 1 to 8, 11
+      xpath: //m:java.version[matches(text(), '^(1(\.([0-9]|10))?|[2-8]|11)$')]
diff --git a/default/generated/azure/tests/05-azure-java-version.test.yaml b/default/generated/azure/tests/05-azure-java-version.test.yaml
index 9d0c3e23..c65825c4 100644
--- a/default/generated/azure/tests/05-azure-java-version.test.yaml
+++ b/default/generated/azure/tests/05-azure-java-version.test.yaml
@@ -9,11 +9,11 @@ tests:
   testCases:
   - name: tc-1
     hasIncidents:
-      atLeast: 1
-      messageMatches: The application is using non-LTS version Java.
+      exactly: 1
+      messageMatches: The application is using non-LTS Java version.
 - ruleID: azure-java-version-02000
   testCases:
   - name: tc-1
     hasIncidents:
-      atLeast: 1
-      messageMatches: The application is using a Java version lower than Java 8.
+      exactly: 2
+      messageMatches: The application is using an old Java version.
diff --git a/default/generated/azure/tests/data/05-azure-java-version/java-7/pom.xml b/default/generated/azure/tests/data/05-azure-java-version/java-1.7/pom.xml
similarity index 100%
rename from default/generated/azure/tests/data/05-azure-java-version/java-7/pom.xml
rename to default/generated/azure/tests/data/05-azure-java-version/java-1.7/pom.xml
diff --git a/default/generated/azure/tests/data/05-azure-java-version/java-11/pom.xml b/default/generated/azure/tests/data/05-azure-java-version/java-11/pom.xml
new file mode 100644
index 00000000..80922d50
--- /dev/null
+++ b/default/generated/azure/tests/data/05-azure-java-version/java-11/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.springframework.boot</groupId>
+    <artifactId>spring-boot-starter-parent</artifactId>
+    <version>2.5.12</version>
+    <relativePath/> <!-- lookup parent from repository -->
+  </parent>
+  <groupId>com.example</groupId>
+  <artifactId>demo</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>demo</name>
+  <description>Demo project for Spring Boot</description>
+  <properties>
+    <java.version>11</java.version>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>


Reviews:
user: login: zhoufenqin
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-12T23:36:13Z
user: login: haoozhang
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-13T01:48:32Z
user: login: haoozhang
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-13T02:28:49Z
user: login: zhoufenqin
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-13T02:32:48Z

Review comments:
diff_hunk: @@ -62,4 +48,5 @@
       - pom.xml
       namespaces:
         m: http://maven.apache.org/POM/4.0.0
-      xpath: //m:java.version[matches(text(), '1\.[0-7]')]
+      # match: 1.0 to 1.10, and 1 to 11
+      xpath: //m:java.version[matches(text(), '^(1(\.([0-9]|10))?|[2-9]|10|11)$')]
path: default/generated/azure/05-azure-java-version.yaml
user: login: zhoufenqin
body: does 1.0 -1.10 both in azure-java-version-01000 and azure-java-version-02000? it will raise 2 issues for same versioin line?
created_at: 2025-05-12T23:36:13Z
author_association: MEMBER
diff_hunk: @@ -62,4 +48,5 @@
       - pom.xml
       namespaces:
         m: http://maven.apache.org/POM/4.0.0
-      xpath: //m:java.version[matches(text(), '1\.[0-7]')]
+      # match: 1.0 to 1.10, and 1 to 11
+      xpath: //m:java.version[matches(text(), '^(1(\.([0-9]|10))?|[2-9]|10|11)$')]
path: default/generated/azure/05-azure-java-version.yaml
user: login: haoozhang
body: Yes, both two rules detect it, but they are from different perspectives: non-LTS, and legacy version.
What do you think about it?
created_at: 2025-05-13T01:48:32Z
author_association: CONTRIBUTOR
diff_hunk: @@ -62,4 +48,5 @@
       - pom.xml
       namespaces:
         m: http://maven.apache.org/POM/4.0.0
-      xpath: //m:java.version[matches(text(), '1\.[0-7]')]
+      # match: 1.0 to 1.10, and 1 to 11
+      xpath: //m:java.version[matches(text(), '^(1(\.([0-9]|10))?|[2-9]|10|11)$')]
path: default/generated/azure/05-azure-java-version.yaml
user: login: haoozhang
body: Per synced offline, we make the rule matching exclusive.
created_at: 2025-05-13T02:28:49Z
author_association: CONTRIBUTOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-05-13T02:53:07Z
body: Rules Summary: 448/448 (100.00%) PASSED Test Cases Summary: 728/728 (100.00%) PASSED
author_association: NONE