Skip to content

Commit

Permalink
Add corporate-framework-config rule for TestApp
Browse files Browse the repository at this point in the history
Adding TestApp analysis test with custom rule
corporate-framework-config.

Related to konveyor/tackle2-addon-analyzer#52
and konveyor#39

Signed-off-by: Marek Aufart <maufart@redhat.com>
  • Loading branch information
aufi committed Nov 3, 2023
1 parent 85d9ad9 commit 2ea86df
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 0 deletions.
65 changes: 65 additions & 0 deletions analysis/data/corporate-framework-config.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0"?>
<ruleset id="corporate-configuration"
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 provides rules related to the corporate configuration frameworks.
</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>
<sourceTechnology id="java"/>
<sourceTechnology id="java-ee"/>
<targetTechnology id="cloud-readiness"/>
<tag>configuration</tag>
</metadata>
<rules>
<rule id="corporate-config-01000" xmlns="http://windup.jboss.org/schema/jboss-ruleset">
<when>
<javaclass references="io.konveyor.demo.config.ApplicationConfiguration">
<location>VARIABLE_DECLARATION</location>
</javaclass>
</when>
<perform>
<hint title="Legacy configuration with io.konveyor.demo.config.ApplicationConfiguration" effort="1" category-id="cloud-mandatory">
<message>
The legacy ApplicationConfiguration class is being used in this application. This is discouraged by the migration
guidelines, and should be replaced by a more standard approach using Spring's @PropertySource annotation and Environment class:


```java
@PropertySource("classpath:persistence.properties")
public class PersistenceConfig {
@Autowired
private Environment env;

@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.user"));
dataSource.setPassword(env.getProperty("jdbc.password"));

return dataSource;
}
}
```



This allows externalizing the configuration in Kubernetes by injecting it as a ConfigMap or a Secret in the lib directory from the
container running the Tomcat instance.
</message>
<link title="Spring Documentation - PropertySource javadoc" href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html"/>
<link title="Mkyong - Spring @PropertySource example" href="https://mkyong.com/spring/spring-propertysources-example/"/>
<link title="Baeldung - Properties with Spring and Spring Boot" href="https://www.baeldung.com/properties-with-spring" />
<tag>configuration</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>
174 changes: 174 additions & 0 deletions analysis/tc_tackle_testapp_public_corporateframeworkconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package analysis

import (
"github.com/konveyor/go-konveyor-tests/hack/addon"
"github.com/konveyor/tackle2-hub/api"
)

var TackleTestappPublicCorpFrameworkConfig = TC{
Name: "Tackle Testapp public corporate-framework-config",
Application: TackleTestApp,
Task: Analyze,
WithDeps: true,
Labels: addon.Labels{
Included: []string{
"konveyor.io/target=linux",
"konveyor.io/target=cloud-readiness",
"konveyor.io/source=java",
},
},
Analysis: api.Analysis{
Effort: 2,
Issues: []api.Issue{
{
Category: "mandatory",
Description: "Hardcoded IP Address\nWhen migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
Effort: 1,
RuleSet: "discovery-rules",
Rule: "hardcoded-ip-address",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/src/main/resources/persistence.properties",
Line: 2,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
},
{
File: "/addon/source/tackle-testapp-public/target/classes/persistence.properties",
Line: 2,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
},
},
},
{
Category: "potential",
Description: "JBoss API reference",
Effort: 0,
RuleSet: "eap6/resin",
Rule: "generic-catchall-00700",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/controller/CustomerController.java",
Line: 3,
Message: "`org.jboss..logging.Logger;import io` reference found. No specific details available.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/exception/handler/ExceptionHandlingController.java",
Line: 4,
Message: "`org.jboss..logging.Logger;import io` reference found. No specific details available.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/service/CustomerService.java",
Line: 4,
Message: "`org.jboss..logging.Logger;import io` reference found. No specific details available.",
},
},
},
},
Dependencies: []api.TechDependency{
{
Name: "com.fasterxml.jackson.jackson-bom",
Version: "${jackson.version}",
Provider: "",
},
{
Name: "org.springframework.data.spring-data-bom",
Version: "${spring-data.version}",
Provider: "",
},
{
Name: "org.apache.tomcat.tomcat-servlet-api",
Version: "${tomcat.version}",
Provider: "",
},
{
Name: "com.fasterxml.jackson.core.jackson-core",
Version: "",
Provider: "",
},
{
Name: "com.fasterxml.jackson.core.jackson-databind",
Version: "",
Provider: "",
},
{
Name: "org.springframework.data.spring-data-jpa",
Version: "",
Provider: "",
},
{
Name: "org.springframework.spring-jdbc",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.spring-webmvc",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.spring-web",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.boot.spring-boot-starter-actuator",
Version: "2.5.0",
Provider: "",
},
{
Name: "org.apache.tomcat.tomcat-jdbc",
Version: "${tomcat.version}",
Provider: "",
},
{
Name: "org.hibernate.hibernate-entitymanager",
Version: "${hibernate.version}",
Provider: "",
},
{
Name: "org.hibernate.validator.hibernate-validator",
Version: "${hibernate-validator.version}",
Provider: "",
},
{
Name: "ch.qos.logback.logback-classic",
Version: "1.1.7",
Provider: "",
},
{
Name: "com.oracle.database.jdbc.ojdbc11",
Version: "21.1.0.0",
Provider: "",
},
{
Name: "org.postgresql.postgresql",
Version: "42.2.23",
Provider: "",
},
{
Name: "com.h2database.h2",
Version: "2.1.214",
Provider: "",
},
{
Name: "io.konveyor.demo.configuration-utils",
Version: "1.0.0",
Provider: "",
},
},
},
AnalysisTags: []api.Tag{
{Name: "EJB XML", Category: api.Ref{Name: "Bean"}},
{Name: "Servlet", Category: api.Ref{Name: "HTTP"}},
{Name: "Properties", Category: api.Ref{Name: "Other"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Processing"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Java EE"}},
{Name: "Servlet", Category: api.Ref{Name: "Java EE"}},
{Name: "EJB XML", Category: api.Ref{Name: "Java EE"}},
{Name: "Properties", Category: api.Ref{Name: "Sustain"}},
{Name: "Properties", Category: api.Ref{Name: "Embedded"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Execute"}},
{Name: "EJB XML", Category: api.Ref{Name: "Connect"}},
{Name: "Servlet", Category: api.Ref{Name: "Connect"}},
},
}
1 change: 1 addition & 0 deletions analysis/test_cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var Tier1TestCases = []TC{
// List of applications with expected analysis outputs.
var Tier2TestCases = []TC{
TackleTestappPublicWithDeps,
TackleTestappPublicCorpFrameworkConfig, // Move to tier0 or tier1 once confirmed with Ramon&Pranav
Tomcat,
Daytrader,
PetclinicHazelcast,
Expand Down

0 comments on commit 2ea86df

Please sign in to comment.