Code Monkey home page Code Monkey logo

aem-dispatcher-optimizer-tool's Introduction

AEM Dispatcher Optimizer Tool

Analyze an AEM dispatcher module for violations of best practices, and report a list of actionable optimizations.

Goals

The dispatcher is a critical component of a secure, stable, and lightning fast AEM implementation. Unfortunately it is often an afterthought, and its large array of configurations can be overwhelming and easily misconfigured.

This repository offers a tool (implemented as both a Maven Plugin and standalone app) which performs static analysis of the dispatcher module of an AEM archetype based project. It can identify:

  • Syntax issues such as misplaced tokens, unmatched quotes, or missing files referenced from Include directives
  • Violations of best practices including checks for /filter deny rules, /statfileslevel, /gracePeriod and more

Don't agree with one of the rules? Wish there was a check for /propertyX? Use the extensible rules engine to augment (or completely replace) the core set of rules to meet your exact needs.

Non-Goals

This repository does not attempt to suggest or prescribe a one-size-fits-all configuration for the dispatcher. Due to the myriad use cases that AEM supports, it would be impossible to do so. Instead, we attempt to identify syntax issues and known violations of best practices that can, when corrected, make your AEM environment more resilient and performant.

Modules

  • core - Core code shared between the Plugin and App
  • app - Spring Boot app implementation and Dockerfile
  • plugin - Maven plugin implementation
  • plugin-it - Maven plugin integration tests

Build

mvn clean install

Use the Maven plugin

Refer to the Plugin README.

Use the standalone app

Refer to the App README.

Reading the code

Rules

  • The "core rules" can be found here: core-rules.json
  • The spec of the Rules file can be found here: Rules

Plugin

  • Entry point for the Maven plugin implementation: AnalyzerMojo

App

Core

IDE Support

Releasing with Maven

Releasing only the parent pom

From the project root:

mvn -N -Darguments=-N release:prepare
mvn -N -Darguments=-N release:perform

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

aem-dispatcher-optimizer-tool's People

Contributors

atopper avatar blefebvre avatar ckkovac avatar dependabot[bot] avatar mgoszczynski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aem-dispatcher-optimizer-tool's Issues

Number of violations reported for a project built from latest AEM archetype

Expected Behaviour

Project built from latest AEM archetype doesn't report any issues.

Actual Behaviour

12 violations are reported

Steps to Reproduce

  1. Generate AEM project using archetype with following arguments

mvn -B archetype:generate
-D archetypeGroupId=com.adobe.aem
-D archetypeArtifactId=aem-project-archetype
-D archetypeVersion=32
-D appTitle="My Site"
-D appId="mysite"
-D groupId="com.mysite"
-D aemVersion=6.5.7

  1. Add dispatcher-optimizer-tool to dispatcher/pom.xml as per instructions in this repository
  2. Set verbosity to FULL
  3. Run mvn dispatcher-optimizer:analyze in dispatcher folder

Platform and Version

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /Applications/apache-maven-3.8.3
Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Logs taken while reproducing problem

[INFO] [Dispatcher Optimizer] Violations detected: 12
[INFO] [Dispatcher Optimizer] Details:
[INFO] Violation { severity=MAJOR, description='Include directive must include existing files. Check path, or use IncludeOptional.', context='Include directive must include existing files. Check path, or use IncludeOptional.' }
[INFO] Violation { severity=MAJOR, description='Include directive must include existing files. Check path, or use IncludeOptional.', context='Include directive must include existing files. Check path, or use IncludeOptional.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm cache should have its ignoreUrlParams rules configured in an allow list manner.', context='Farm "publishfarm" has its farm.cache.ignoreUrlParams misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm gracePeriod property should be >= 2.', context='Farm "publishfarm" has its farm.cache.gracePeriod misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm filters should specify the allowed Sling suffix patterns in an allow list manner.', context='Farm "publishfarm" has its farm.filter misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm filters should specify the allowed Sling selectors in an allow list manner.', context='Farm "publishfarm" has its farm.filter misconfigured.' }
[INFO] Violation { severity=MAJOR, description='Include directive must include existing files. Check path, or use IncludeOptional.', context='Include directive must include existing files. Check path, or use IncludeOptional.' }
[INFO] Violation { severity=MAJOR, description='Include directive must include existing files. Check path, or use IncludeOptional.', context='Include directive must include existing files. Check path, or use IncludeOptional.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm cache should have its ignoreUrlParams rules configured in an allow list manner.', context='Farm "publishfarm" has its farm.cache.ignoreUrlParams misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm gracePeriod property should be >= 2.', context='Farm "publishfarm" has its farm.cache.gracePeriod misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm filters should specify the allowed Sling suffix patterns in an allow list manner.', context='Farm "publishfarm" has its farm.filter misconfigured.' }
[INFO] Violation { severity=MAJOR, description='The Dispatcher publish farm filters should specify the allowed Sling selectors in an allow list manner.', context='Farm "publishfarm" has its farm.filter misconfigured.' }

Optionally break the build if a certain quality gate is missed

Please allow to configure a quality gate in the Maven plugin. The quality gate should consist out of one or more severities (https://github.com/adobe/aem-dispatcher-optimizer-tool/blob/main/core/src/main/java/com/adobe/aem/dot/common/analyzer/Severity.java) connected with a threshold (number of issues in that severity which are still acceptable).
That allows to enforce some best practices without someone manually looking at the report. Particularly useful for CI builds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.