diff --git a/rules/rules-reviewed/technology-usage/connect-technology-usage.windup.xml b/rules/rules-reviewed/technology-usage/connect-technology-usage.windup.xml index dacb829f3..6d3cc8b05 100644 --- a/rules/rules-reviewed/technology-usage/connect-technology-usage.windup.xml +++ b/rules/rules-reviewed/technology-usage/connect-technology-usage.windup.xml @@ -329,6 +329,19 @@ - + + + + Kafka Client + + + + + + + + + + diff --git a/rules/rules-reviewed/technology-usage/connect.windup.groovy b/rules/rules-reviewed/technology-usage/connect.windup.groovy new file mode 100644 index 000000000..7ace7a281 --- /dev/null +++ b/rules/rules-reviewed/technology-usage/connect.windup.groovy @@ -0,0 +1,195 @@ +import org.jboss.windup.config.GraphRewrite +import org.jboss.windup.config.operation.iteration.AbstractIterationOperation +import org.jboss.windup.graph.GraphContext +import org.jboss.windup.graph.model.FileLocationModel +import org.jboss.windup.graph.model.resource.FileModel +import org.jboss.windup.graph.service.WindupConfigurationService +import org.jboss.windup.reporting.category.IssueCategoryRegistry +import org.jboss.windup.reporting.config.Link +import org.jboss.windup.reporting.config.classification.Classification +import org.jboss.windup.reporting.model.TechnologyTagLevel +import org.jboss.windup.reporting.service.TechnologyTagService +import org.jboss.windup.rules.files.condition.File +import org.ocpsoft.rewrite.config.Or +import org.ocpsoft.rewrite.context.EvaluationContext + +static boolean hasAnalysisTargetEap(GraphContext graphContext) { + WindupConfigurationService.getConfigurationModel(graphContext) + .getTargetTechnologies() + .stream() + .anyMatch { ("eap" == it.technologyID) } +} + +static void perform(GraphRewrite event, EvaluationContext context, FileModel fileModel, String technology, boolean withLink) { + final IssueCategoryRegistry issueCategoryRegistry = IssueCategoryRegistry.instance(context) + final Classification classification = (Classification) Classification.as("Embedded library - $technology") + .withDescription("The application embeds an $technology library.") + .withEffort(0) + .withIssueCategory(issueCategoryRegistry.getByID(IssueCategoryRegistry.INFORMATION)) + if (withLink && hasAnalysisTargetEap(event.getGraphContext())) { + classification.with(Link.to("Red Hat JBoss Enterprise Application Platform (EAP) 7 Supported Configurations", "https://access.redhat.com/articles/2026253")) + } + classification.performParameterized(event, context, fileModel) + final TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext()) + technologyTagService.addTagToFileModel(fileModel, technology, TechnologyTagLevel.INFORMATIONAL) +} + +// this is inherited from previous version of these rules (i.e. XML rules) +// in order to keep consistency with tests already available +int id = 14; + +ruleSet("connect") + .addRule() + .when(File.inFileNamed("{*}.rar")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + final IssueCategoryRegistry issueCategoryRegistry = IssueCategoryRegistry.instance(context) + final Classification classification = (Classification) Classification.as("Embedded Resource Adapter") + .withDescription("The application embeds a resource adapter.") + .withEffort(0) + .withIssueCategory(issueCategoryRegistry.getByID(IssueCategoryRegistry.INFORMATION)) + classification.performParameterized(event, context, payload.getFile()) + final TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext()) + technologyTagService.addTagToFileModel(payload.getFile(), "Resource Adapter", TechnologyTagLevel.INFORMATIONAL) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}activemq{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "ActiveMQ", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}openws{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "OpenWS", false) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}wsdl{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "WSDL", false) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(Or.any( + File.inFileNamed("{*}amqp-client{*}"), + File.inFileNamed("{*}rabbitmq{*}"), + File.inFileNamed("{*}spring-rabbit{*}"), + File.inFileNamed("{*}lyra{*}"), + File.inFileNamed("{*}conduit{*}") + ) + ) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "RabbitMQ Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(Or.any( + File.inFileNamed("{*}spring-messaging{*}"), + File.inFileNamed("{*}spring-jms{*}") + ) + ) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Spring Messaging Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}camel-jms{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Camel Messaging Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}aws-java-sdk-sqs{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Amazon SQS Client", false) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}hornetq{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "HornetQ Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}amqp{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "AMQP Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}rocketmq-client{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "RocketMQ Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(Or.any( + File.inFileNamed("{*}jzmq{*}"), + File.inFileNamed("{*}jeromq{*}") + ) + ) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "0MQ Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}jbossmq-client{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "JBossMQ Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}zbus-client{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Zbus Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(File.inFileNamed("{*}qpid{*}")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Qpid Client", true) + } + }) + .withId(String.format("connect-0%d00", id++)) + .addRule() + .when(Or.any( + File.inFileNamed("{*}kafka-clients{*}"), + File.inFileNamed("{*}spring-kafka{*}") + ) + ) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + perform(event, context, payload.getFile(), "Kafka Client", false) + } + }) + .withId(String.format("connect-0%d00", id)) diff --git a/rules/rules-reviewed/technology-usage/connect.windup.xml b/rules/rules-reviewed/technology-usage/connect.windup.xml deleted file mode 100644 index 39265fe27..000000000 --- a/rules/rules-reviewed/technology-usage/connect.windup.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - This ruleset provides analysis of connectivity related libraries. - - - - - - - - - - - - - - The application embeds a resource adapter. - - Resource Adapter - - - - - - - - - The application embeds an ActiveMQ client library. - - - - ActiveMQ - - - - - - - - - The application embeds an OpenWS library. - - OpenWS - - - - - - - - - The application embeds a WSDL library. - - WSDL - - - - - - - - - - - - - - - The application embeds a RabbitMQ client library. - - - - RabbitMQ Client - - - - - - - - - - - - The application embeds a Spring Messaging client library. - - - - Spring Messaging Client - - - - - - - - - The application embeds a Camel Messaging client library. - - - - Camel Messaging Client - - - - - - - - - The application embeds a Amazon SQS client library. - - - - Amazon SQS Client - - - - - - - - - The application embeds a HornetQ client library. - - - - HornetQ Client - - - - - - - - - The application embeds an AMQP client library. - - - - AMQP Client - - - - - - - - - The application embeds a RocketMQ client library. - - - - RocketMQ Client - - - - - - - - - - - - The application embeds a 0MQ client library. - - - - 0MQ Client - - - - - - - - - The application embeds a JBossMQ client library. - - - - JBossMQ Client - - - - - - - - - The application embeds a Zbus client library. - - - - Zbus Client - - - - - - - - - The application embeds a Qpid client library. - - - - Qpid Client - - - - diff --git a/rules/rules-reviewed/technology-usage/tests/connect-spring-messaging.windup.test.xml b/rules/rules-reviewed/technology-usage/tests/connect-spring-messaging.windup.test.xml index 16b9f7097..ffe429f76 100644 --- a/rules/rules-reviewed/technology-usage/tests/connect-spring-messaging.windup.test.xml +++ b/rules/rules-reviewed/technology-usage/tests/connect-spring-messaging.windup.test.xml @@ -7,7 +7,7 @@ xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> data/connect/messaging - ../connect.windup.xml + ../connect.windup.groovy diff --git a/rules/rules-reviewed/technology-usage/tests/connect-technology-usage.windup.test.xml b/rules/rules-reviewed/technology-usage/tests/connect-technology-usage.windup.test.xml index add8560df..d78e2c4fe 100644 --- a/rules/rules-reviewed/technology-usage/tests/connect-technology-usage.windup.test.xml +++ b/rules/rules-reviewed/technology-usage/tests/connect-technology-usage.windup.test.xml @@ -7,7 +7,7 @@ xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> data/connect - ../connect.windup.xml + ../connect.windup.groovy ../connect-technology-usage.windup.xml @@ -291,6 +291,20 @@ + + + + + + + + + + + + + + diff --git a/rules/rules-reviewed/technology-usage/tests/connect.windup.test.xml b/rules/rules-reviewed/technology-usage/tests/connect.windup.test.xml index 2a2c225c7..0af581c61 100644 --- a/rules/rules-reviewed/technology-usage/tests/connect.windup.test.xml +++ b/rules/rules-reviewed/technology-usage/tests/connect.windup.test.xml @@ -7,7 +7,7 @@ xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> data/connect - ../connect.windup.xml + ../connect.windup.groovy @@ -175,6 +175,17 @@ + + + + + + + + + + + diff --git a/rules/rules-reviewed/technology-usage/tests/data/connect/kafka-clients b/rules/rules-reviewed/technology-usage/tests/data/connect/kafka-clients new file mode 100644 index 000000000..01d67e869 Binary files /dev/null and b/rules/rules-reviewed/technology-usage/tests/data/connect/kafka-clients differ diff --git a/rules/rules-reviewed/technology-usage/tests/data/connect/spring-kafka b/rules/rules-reviewed/technology-usage/tests/data/connect/spring-kafka new file mode 100644 index 000000000..01d67e869 Binary files /dev/null and b/rules/rules-reviewed/technology-usage/tests/data/connect/spring-kafka differ diff --git a/rules/rules-reviewed/technology-usage/tests/javaee-technology-tag.windup.test.xml b/rules/rules-reviewed/technology-usage/tests/javaee-technology-tag.windup.test.xml index 078c19064..0eac872c4 100644 --- a/rules/rules-reviewed/technology-usage/tests/javaee-technology-tag.windup.test.xml +++ b/rules/rules-reviewed/technology-usage/tests/javaee-technology-tag.windup.test.xml @@ -3,7 +3,7 @@ data/ ../ejb-technology-usage.windup.xml ../javaee-technology-tag.windup.groovy - ../connect.windup.xml + ../connect.windup.groovy ../connect-technology-usage.windup.xml ../database.windup.xml ../database-technology-usage.windup.xml