Skip to content

Commit

Permalink
[WINDUPRULE-901] Add ruleset for legacy vault removal (#858)
Browse files Browse the repository at this point in the history
* [WINDUPRULE-901] Add ruleset for legacy vault removal

* [WINDUPRULE-901] Fix test paths

* [WINDUPRULE-901] Fix filecontent pattern

* [WINDUPRULE-901] Fix test id

* [WINDUPRULE-901] Escape characters

* [WINDUPRULE-901] Rewrite rules

---------

Co-authored-by: Carlos E. Feria Vila <carlosthe19916@gmail.com>
  • Loading branch information
jmle and carlosthe19916 committed Feb 22, 2023
1 parent 3bbf0be commit f1d18ca
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
40 changes: 40 additions & 0 deletions rules/rules-reviewed/eap8/eap7/legacy-vault.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="legacy-vault"
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 provides analysis of Java EE applications that need to remove their legacy vault configuration.
</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="eap" versionRange="[8,9)"/>
</metadata>
<rules>
<rule id="legacy-vault-00010">
<when>
<!-- TODO: try to fix javaclass condition -->
<filecontent pattern="$\{VAULT::" filename="{*}.{filetype}"/>
<!--
<javaclass references="org.x.Annotation">
<location>ANNOTATION</location>
<annotation-literal name="not-used" pattern="$\{VAULT::{*}"/>
</javaclass>
-->
</when>
<perform>
<hint title="Legacy Vault configuration must be removed" effort="1" category-id="mandatory">
<message>
Vault support has been removed in EAP8; migration to Elytron credential store is mandatory.
</message>
<!-- TODO: add migration guide link when is available -->
</hint>
</perform>
<where param="filetype">
<matches pattern="(xml|java)"/>
</where>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.x.Annotation;

public class LegacyVault {

@Annotation(value="${VAULT::someInfo}")
public String aMethod() {
return "Hello World!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
<jboss-app>
<security-domain>${VAULT::...}</security-domain>
<security-role>
<role-name>Administrator</role-name>
<principal-name>j2ee</principal-name>
</security-role>
<security-role>
<role-name>Manager</role-name>
<principal-name>javajoe</principal-name>
</security-role>
<security-role>
<role-name>Employee</role-name>
<principal-name>javajoe</principal-name>
<principal-name>j2ee</principal-name>
</security-role>
</jboss-app>
24 changes: 24 additions & 0 deletions rules/rules-reviewed/eap8/eap7/tests/legacy-vault.windup.test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruletest id="legacy-vault-tests"
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/legacy-vault</testDataPath>
<rulePath>../legacy-vault.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="legacy-vault-00010-test">
<when>
<not>
<iterable-filter size="2">
<hint-exists message="Vault support has been removed in EAP8; migration to Elytron credential store is mandatory."/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[legacy-vault-00010] The hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>

0 comments on commit f1d18ca

Please sign in to comment.