Skip to content

Commit

Permalink
Rule that checks Tomcat external resources for Azure migration (#932)
Browse files Browse the repository at this point in the history
* Lombok <1.18.22 is not compatible with JDK 17

* Rule that checks Tomcat external resources for Azure migration

* Update rules/rules-reviewed/azure/tomcat/tests/tomcat-to-azure-external-resources.windup.test.xml

Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com>

---------

Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com>
Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com>
  • Loading branch information
3 people authored May 22, 2023
1 parent a163d71 commit 0a238ac
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>

<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<Resource name="jdbc/postgres1" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432"
username="postgres" password="yes" maxActive="20" maxIdle="10"
maxWait="-1" />

<Resource name="jdbc/postgres2" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432"
username="postgres" password="yes" maxActive="20" maxIdle="10"
maxWait="-1" />

<NoResource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432"
username="postgres" password="yes" maxActive="20" maxIdle="10"
maxWait="-1" />
</Context>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>

<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432"
username="postgres" password="yes" maxActive="20" maxIdle="10"
maxWait="-1" />
</Context>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<ruletest id="tomcat-to-azure-external-resources-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">
<testDataPath>data/tomcat-to-azure-external-resources</testDataPath>
<rulePath>../tomcat-to-azure-external-resources.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="tomcat-to-azure-external-resources-test-01000">
<when>
<not>
<iterable-filter size="2">
<hint-exists message="External resources, such as data sources, JMS message brokers, and others are injected via Java Naming and Directory Interface \(JNDI\)"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="External resources found in configuration file hint was not found!"/>
</perform>
</rule>
</rules>
</ruleset>
</ruletest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<ruleset id="tomcat-to-azure-external-resources"
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>
Identify external resources in a Tomcat configuration file.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" />
</dependencies>
<targetTechnology id="azure-spring-apps"/>
<targetTechnology id="azure-appservice"/>
<targetTechnology id="azure-aks"/>
<targetTechnology id="azure-container-apps"/>
<tag>tomcat</tag>
</metadata>
<rules>
<rule id="tomcat-to-azure-external-resources-01000">
<when>
<xmlfile matches="/Context/Resource" in="context.xml"/>
</when>
<perform>
<hint title="External resources found in configuration file" category-id="cloud-mandatory" effort="5">
<message>
<![CDATA[
External resources, such as data sources, JMS message brokers, and others are injected via Java Naming and Directory Interface (JNDI).
Some such resources may require migration or reconfiguration.
]]>
</message>
<link title="Inventory external resources" href="https://learn.microsoft.com/azure/developer/java/migration/migrate-tomcat-to-azure-spring-apps"/>
<tag>tomcat</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>

0 comments on commit 0a238ac

Please # to comment.