Giter Club home page Giter Club logo

netcentric / aem-cloud-validator Goto Github PK

View Code? Open in Web Editor NEW
4.0 7.0 2.0 102 KB

Jackrabbit FileVault validator which verifies that a package complies with the AEM as a Cloud Service deployment restrictions outlined at https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-as-a-cloud-service/build-and-deployment.html

License: Eclipse Public License 1.0

Java 89.75% Groovy 10.25%
filevault jackrabbit jackrabbit-oak aem aemaacs

aem-cloud-validator's Introduction

Build Status License Maven Central SonarCloud Quality Gate Status SonarCloud Coverage

Overview

Validates content packages to prevent invalid usage patterns for AEM as a Cloud Service (AEMaaCS) described in Debugging AEM as a Cloud Service build and deployments as those might lead to Build or Deployment errors in CloudManager. It is a validator implementation for the FileVault Validation Module and can be used for example with the filevault-package-maven-plugin.

This validator only includes checks which are not covered by the aemanalyser-maven-plugin so it is strongly recommended to also enable the aemanalyser-maven-plugin in your build.

Settings

The following options are supported apart from the default settings mentioned in FileVault validation.

Option Mandatory Description Default Value Since Version
allowReadOnlyMutablePaths (or allowVarNodeOutsideContainer deprecated) no true means read-only paths (i.e. paths to which the service session used for mutable package installation on publish does not have write permission) should be allowed. Otherwise those will only be allowed in author-only packages included in a container package. false 1.2.0
allowLibsNode no true means that libs nodes are allowed in content packages. Only set this to true when building packages which are part of the AEM product. false 1.2.0
allowHooksInMutableContent no true means that JCR Install Hooks are allowed in content packages. Only set this to true when building packages for local AEM SDK development or when explicitly allowed via OSGi configuration (details below in check description for install hooks). false 1.3.0

Included Checks

Prevent using certain paths in mutable content packages

Including /var, /tmp and some other paths in content packages being deployed to publish instances must be prevented, as it causes deployment failures. The system session which takes care of installing the packages on publish does not have jcr:write permission to those locations. Further details at https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-as-a-cloud-service/build-and-deployment.html?lang=en#including-%2Fvar-in-content-package.

As this restriction technically only affects publish instances it is still valid to have those nodes in author-only containers. As a temporary workaround you can also extend the privileges of the sling-distribution-importer user via a custom repoinit configuration. Here is the full list of default permissions of the system session extracted from AEM 2021.2.4887.20210204T154817Z. All the following principals are mapped via the service user mapping for org.apache.sling.distribution.journal:importer on publish

Principal Permissions
sling-distribution-importer allow jcr:modifyAccessControl,jcr:readAccessControl on /content
allow jcr:modifyAccessControl,jcr:readAccessControl on /conf
allow jcr:modifyAccessControl,jcr:readAccessControl on /etc
allow jcr:nodeTypeDefinitionManagement,rep:privilegeManagement on :repository
sling-distribution allow jcr:read,rep:write on /var/sling/distribution
content-writer-service allow jcr:read,rep:write,jcr:versionManagement on /content
repository-reader-service allow jcr:read on /
version-manager-service allow jcr:read,rep:write,jcr:versionManagement on /conf
allow jcr:read,rep:write,jcr:versionManagement on /etc
group-administration-service allow jcr:all on /home/groups
user-administration-service allow jcr:all on /home/users
namespace-mgmt-service allow jcr:namespaceManagement on :repository

Prevent using /libs in content package

Changes below /libs may be overwritten by AEM product upgrades (applied regularly). Further details at https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/developing/full-stack/overlays.html?lang=en#developing. Instead put overlays in /apps.

Prevent using install hooks in mutable content packages

The usage of install hooks is not allowed to the system user which is installing the package on the AEMaaCS publish instances (named sling-distribution-importer) and leads to a PackageException. The code for that can be found in ContentPackageExtractor. Subsequently the deployment will fail as the exception on publish will block the replication queue on author. Further details at JCRVLT-427. Although AEMaaCS since version 2023.1.10675 ships with FileVault > 3.5.0 you need to add explicit OSGi configuration to lift this limitation. Adobe has not yet allowed this by default (tracked in ticket #SKYOPS-13098). In order to do that just include the following org.apache.jackrabbit.vault.packaging.impl.PackagingImpl.cfg.json file as OSGi configuration in your container package:

{
  "authIdsForHookExecution":[
    "sling-distribution-importer"
  ]
}

Usage of install hooks in immutable content packages is supported in Cloud Manager Build since end of May 2021 due to the update of the converter fixing SLING-10205.

Install hooks have no limitations when being used with the AEMaaCS SDK Quickstart Jar.

Prevent using mutable content in "mixed" content packages

Content packages of type mixed are allowed to have both mutable and immutable nodes. AEMaaCS will only ever install the immutable part of it. The mutable part won't be installed as that cannot be successful (due to missing write access at the time of installation). Further details at https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#deploying-content-packages-via-cloud-manager-and-package-manager.

Enforce Oak index definitions of type lucene

Currently only Oak index definitions of type lucene are supported in AEMaaCS. Further details in https://experienceleague.adobe.com/docs/experience-manager-cloud-service/operations/indexing.html?lang=en#changes-in-aem-as-a-cloud-service.

Follow naming policy for Oak index definition node names

There is a mandatory naming policy for Oak index definition node names which enforces them to end with -custom-<version-as-integer>. The format is used in IndexName and allows for upgrades of existing index definitions in blue/green deployments.

Further details in https://experienceleague.adobe.com/docs/experience-manager-cloud-service/operations/indexing.html?lang=en#changes-in-aem-as-a-cloud-service.

Usage with Maven

You can use this validator with the FileVault Package Maven Plugin in version 1.1.0 or higher like this

<plugin>
  <groupId>org.apache.jackrabbit</groupId>
  <artifactId>filevault-package-maven-plugin</artifactId>
  <configuration>
    <validatorsSettings>
      <netcentric-aem-cloud>
        <options>
          <allowReadOnlyMutablePaths>true</allowReadOnlyMutablePaths><!-- default value is false  -->
        </options>
      </netcentric-aem-cloud>
    </validatorsSettings>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>biz.netcentric.filevault.validator</groupId>
      <artifactId>aem-cloud-validator</artifactId>
      <version><latestversion></version>
    </dependency>
  </dependencies>
</plugin>

aem-cloud-validator's People

Contributors

kwin avatar santiagozky avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aem-cloud-validator's Issues

Extend rule what may be included in mutable content packages

According to Adobe-Consulting-Services/acs-aem-commons#2523 (comment) the system user which is installing packages on the publish has very limited privileges.

Currently this is

"# GRANITE-23007 - [RTC] Configure service user mapping for Pipeline replication",
    "create service user sling-distribution-importer with path system/cq:services/internal",
    "set principal ACL for sling-distribution-importer",
    "  allow jcr:modifyAccessControl,jcr:readAccessControl on /content",
    "  allow jcr:modifyAccessControl,jcr:readAccessControl on /conf",
    "  allow jcr:modifyAccessControl,jcr:readAccessControl on /etc",
    "  allow jcr:nodeTypeDefinitionManagement,rep:privilegeManagement on :repository ",
    "end",

(https://repo1.maven.org/maven2/com/adobe/aem/aem-sdk-api/2021.1.4830.20210128T075814Z-210128/aem-sdk-api-2021.1.4830.20210128T075814Z-210128-aem-publish-sdk.slingosgifeature)

It is unclear though why authorizables and ACLs below /home don't lead to exception on publish....

Also detect external install hooks

Currently only internal install hooks are detected and prevented in mutable content packages. External hooks should be detected as well.

Add rule to check for nodes below /libs

Packages containing nodes below /libs are not allowed to be deployed in Cloud Manager.
A rule enforcing this should be added.
It needs to be configurable though, to be also usable e.g. for Core WCM Components which is part of the product (i.e. is allowed in /libs).

You must not make changes in the /libs branch
Any changes you do make may be lost, because this branch is liable to changes whenever upgrades are applied to your instance.

(https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/developing/full-stack/overlays.html?lang=en#developing)

Add integration test

Next to the Unit test we should have a proper IT. Probably using maven-invoker-plugin is the easiest way to check in the context of a Maven build with filevault-package-maven-plugin.

Make sure that "mixed" packages don't contain mutable content

Content packages of type "mixed" are only installed during the Cloud Manager "Build Images" step. That means, that all mutable content being installed through these packages is lost, as those packages are never reinstalled once the kubernetes pod is started with the live content!

Currently this doesn't lead to any error in Cloud Manager despite what is stated in https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#deploying-content-packages-via-cloud-manager-and-package-manager

Content packages written for AEM as a Cloud Service applications must have a clean separation between immutable and > mutable content and Cloud Manager will enforce it by failing the build, outputting a message like:

Generated content-package <PACKAGE_ID> located in file is of MIXED type

Add rule for preventing install hooks in mutable content packages

Mutable content packages are deployed to publish via replication from author in AEMaaCS.
In case they contain an install hook the replication fails, as the replication-receiver system user does neither have admin privileges and nor is configured as allowed user for install hooks (compare with https://issues.apache.org/jira/browse/JCRVLT-427). This limitation is currently not documented at https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-as-a-cloud-service/build-and-deployment.html?lang=en#debugging but having a mutable package with an install hook leads to a failed deployment.

Add option to allow mutable install hooks for local AEM SDK development

When developing with the AEM SDK, a common approach is to use InstallHook's to trigger actions when a mutable content package is installed. This is for example done by the Netcentric accesscontroltool. To make it possible to leverage this capability, there should be an option to disable the error for install hooks in mutable content for local development

the allowReadOnlyMutablePaths option does not work

The option allowReadOnlyMutablePaths does not work since the validator emits the error disregarding its value when the package is not an author-only package.
A small change in the condition is needed for this option to work correctly.

to reproduce:
set the option allowReadOnlyMutablePaths in a project that contains content in a mutable path (e.g. /var). the validator will still fail because of the mutable path.

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.