-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check localhost usage in config and code (#996)
* Add new runtime springboot and add JPA as supported * 1) Add Spring App and War 2) Add label for Springboot * Update the test jar file * use simple test data * Add more spring framework to runtime springboot change spring boot war to spring war * Divided 'Spring Boot Application' into 3 relevant technologies * Fixed 'technology-tag's cases * Changed consistently labels definitions * Changed 'SpringBootApplication' annotation technologies' placement * Rule '3rd-party-spring-03001': removed useless 'or' condition * Added new technologies to README * Check the localhost --------- Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> Co-authored-by: mrizzi <mrizzi@redhat.com>
- Loading branch information
1 parent
0d8e05f
commit 91e8302
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0"?> | ||
<ruleset id="localhost" 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 is a ruleset for check if localhost used in app | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-javaee,2.4.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,2.4.0.Final" /> | ||
</dependencies> | ||
<!-- version ranges applied to from and to technologies --> | ||
<targetTechnology id="cloud-readiness" /> | ||
<tag>localhost</tag> | ||
</metadata> | ||
<rules> | ||
<rule id="localhost-http-00001"> | ||
<when> | ||
<filecontent filename="{*}.{extensions}" pattern="{pattern}" /> | ||
</when> | ||
<perform> | ||
<hint title="Local HTTP Calls" effort="7" category-id="mandatory"> | ||
<message>The app is trying to access local resource by HTTP, please try to migrate the resource to cloud</message> | ||
<tag>localhost</tag> | ||
</hint> | ||
</perform> | ||
<where param="extensions"> | ||
<matches pattern="(java|properties|jsp|jspf|tag|xml|txt|yaml)" /> | ||
</where> | ||
<where param="pattern"> | ||
<matches pattern="http(s)?://((localhost)|(127\.0\.0\.1))+(:[0-9]+)?(/.*)?" /> | ||
</where> | ||
</rule> | ||
<rule id="localhost-http-00001"> | ||
<when> | ||
<filecontent filename="{*}.{extensions}" pattern="{pattern}" /> | ||
</when> | ||
<perform> | ||
<hint title="Local JDBC Calls" effort="7" category-id="mandatory"> | ||
<message>The app is trying to access local resource by JDBC, please try to migrate the resource to cloud</message> | ||
<tag>localhost</tag> | ||
</hint> | ||
</perform> | ||
<where param="extensions"> | ||
<matches pattern="(java|properties|jsp|jspf|tag|xml|txt|yaml)" /> | ||
</where> | ||
<where param="pattern"> | ||
<matches pattern="jdbc:([a-z0-9-]+)://(localhost|127\.0\.0\.1)(:[0-9]+)?" /> | ||
</where> | ||
</rule> | ||
</rules> | ||
</ruleset> |
4 changes: 4 additions & 0 deletions
4
rules/rules-reviewed/cloud-readiness/tests/data/localhost.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mysql=jdbc:sqlserver://127.0.0.1:3306/asdf | ||
sqlserver=jdbc:sqlserver://localhost;encrypt=true;user=MyUserName;password=***** | ||
http=http://localhost:8080 | ||
https=https://127.0.0.1:8080/ddd |
34 changes: 34 additions & 0 deletions
34
rules/rules-reviewed/cloud-readiness/tests/localhost.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="localhost-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"> | ||
<testDataPath>data</testDataPath> | ||
<rulePath>../localhost.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="localhost-http-test-00001"> | ||
<when> | ||
<not> | ||
<iterable-filter size="2"> | ||
<hint-exists message="The app is trying to access local resource by HTTP" /> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="localhost http usage was not found" /> | ||
</perform> | ||
</rule> | ||
<rule id="localhost-jdbc-test-00002"> | ||
<when> | ||
<not> | ||
<iterable-filter size="2"> | ||
<hint-exists message="The app is trying to access local resource by JDBC" /> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="localhost jdbc usage was not found" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |