Skip to content

Commit b063756

Browse files
committed
Add validator for embedded bundles
This closes #5
1 parent a9966f9 commit b063756

File tree

11 files changed

+279
-29
lines changed

11 files changed

+279
-29
lines changed

README.md

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ There are several validators included in this artifact, all relate to namespacin
1919
1. [OSGi Configuration][osgi-installer-configurations]
2020
1. [Sling Resource Type and Resource Super Type][sling-resource-type] (`sling:resourceType` and `sling:resourceSuperType` properties)
2121
1. [AEM Client Library][aem-clientlibrary] (`categories` property)
22+
1. [Embedded Bundles][embedded] (the `Bundle-SymbolicName` of embedded bundles)
2223

2324
Namespacing has been explicitly mentioned in [Achim Koch's Blog: Hosting Multiple Tenants on AEM](https://blog.developer.adobe.com/hosting-multiple-tenants-on-aem-815c8ed0c9f9) but obviously namespacing is just one of multiple aspects to consider for multi-tenant AEM environments.
2425

@@ -33,21 +34,22 @@ The following options are supported apart from the default settings mentioned in
3334
Leaving the validators with the default options will not emit validation issues at all, i.e. none of the options are mandatory.
3435

3536

36-
Validator ID | Option | Description
37-
--- | --- | ---
38-
`netcentric-filter-namespace` | `allowedPathPatterns` | Comma-separated list of regular expression patterns. Each package filter `root` must match at least one of the given patterns.
39-
`netcentric-packageid-namespace` | `allowedGroupPatterns` | Comma-separated list of regular expression patterns. The package's group must match at least one of the given patterns.
40-
`netcentric-packageid-namespace` | `allowedNamePatterns` | Comma-separated list of regular expression patterns. The package's name must match at least one of the given patterns.
41-
`netcentric-authorizable-namespace` | `allowedPrincipalNamePatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:principalName` must match at least one of the given patterns.
42-
`netcentric-authorizable-namespace` | `allowedAuthorizableIdPatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:authorizableId` or its node name (if the property does not exist( must match at least one of the given patterns.
43-
`netcentric-authorizable-namespace` | `allowedAuthorizableIdPatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:authorizableId` or its node name (if the property does not exist) must match at least one of the given patterns.
44-
`netcentric-oakindex-namespace` | `allowedPathPatterns` | Comma-separated list of regular expression patterns. Each Oak index definition's path restriction ([for `lucene` index types][oakindex-lucene-pathrestrictions] or [`property` index types][oakindex-property-pathrestrictions]) must match at least one of the given patterns.
45-
`netcentric-osgiconfig-namespace` | `allowedPidPatterns` | Comma-separated list of regular expression patterns. Each (non-factory) configuration name given via the [OSGi Installer][osgi-installer-configurations] must have a PID matching at least one of the given patterns.
46-
`netcentric-osgiconfig-namespace` | `allowedFactoryPidNames` | Comma-separated list of regular expression patterns. Each factory configuration name given via the [OSGi Installer][osgi-installer-configurations] must have a name matching at least one of the given patterns.
47-
`netcentric-osgiconfig-namespace` | `restrictFactoryConfigurationsToAllowedPidPatterns` | Boolean flag, `false` by default. If set to `true` each factory configuration PID given via the [OSGi Installer][osgi-installer-configurations] must also matching at least one of the given patterns from `allowedPidPatterns`.
48-
`netcentric-resourcetype-namespace` | `allowedTypePatterns` | Comma-separated list of regular expression patterns. Each `sling:resourceType` property of arbitrary JCR nodes must match at least one of the given patterns.
49-
`netcentric-resourcetype-namespace` | `allowedSuperTypePatterns` | Comma-separated list of regular expression patterns. Each `sling:resourceSuperType` property of arbitrary JCR nodes must match at least one of the given patterns.
50-
`netcentric-clientlibrary-namespace` | `allowedCategoryPatterns` | Comma-separated list of regular expression patterns. Each [client library's `categories` value][aem-clientlibrary] must match at least one of the given patterns.
37+
Validator ID | Option | Description | Since
38+
--- | --- | --- | ---
39+
`netcentric-filter-namespace` | `allowedPathPatterns` | Comma-separated list of regular expression patterns. Each package filter `root` must match at least one of the given patterns. | 1.0.0
40+
`netcentric-packageid-namespace` | `allowedGroupPatterns` | Comma-separated list of regular expression patterns. The package's group must match at least one of the given patterns. | 1.0.0
41+
`netcentric-packageid-namespace` | `allowedNamePatterns` | Comma-separated list of regular expression patterns. The package's name must match at least one of the given patterns. | 1.0.0
42+
`netcentric-authorizable-namespace` | `allowedPrincipalNamePatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:principalName` must match at least one of the given patterns. | 1.0.0
43+
`netcentric-authorizable-namespace` | `allowedAuthorizableIdPatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:authorizableId` or its node name (if the property does not exist( must match at least one of the given patterns. | 1.0.0
44+
`netcentric-authorizable-namespace` | `allowedAuthorizableIdPatterns` | Comma-separated list of regular expression patterns. The authorizable's `rep:authorizableId` or its node name (if the property does not exist) must match at least one of the given patterns. | 1.0.0
45+
`netcentric-oakindex-namespace` | `allowedPathPatterns` | Comma-separated list of regular expression patterns. Each Oak index definition's path restriction ([for `lucene` index types][oakindex-lucene-pathrestrictions] or [`property` index types][oakindex-property-pathrestrictions]) must match at least one of the given patterns. | 1.0.0
46+
`netcentric-osgiconfig-namespace` | `allowedPidPatterns` | Comma-separated list of regular expression patterns. Each (non-factory) configuration name given via the [OSGi Installer][osgi-installer-configurations] must have a PID matching at least one of the given patterns. | 1.0.0
47+
`netcentric-osgiconfig-namespace` | `allowedFactoryPidNames` | Comma-separated list of regular expression patterns. Each factory configuration name given via the [OSGi Installer][osgi-installer-configurations] must have a name matching at least one of the given patterns. | 1.0.0
48+
`netcentric-osgiconfig-namespace` | `restrictFactoryConfigurationsToAllowedPidPatterns` | Boolean flag, `false` by default. If set to `true` each factory configuration PID given via the [OSGi Installer][osgi-installer-configurations] must also matching at least one of the given patterns from `allowedPidPatterns`. | 1.0.0
49+
`netcentric-resourcetype-namespace` | `allowedTypePatterns` | Comma-separated list of regular expression patterns. Each `sling:resourceType` property of arbitrary JCR nodes must match at least one of the given patterns. | 1.0.0
50+
`netcentric-resourcetype-namespace` | `allowedSuperTypePatterns` | Comma-separated list of regular expression patterns. Each `sling:resourceSuperType` property of arbitrary JCR nodes must match at least one of the given patterns. | 1.0.0
51+
`netcentric-clientlibrary-namespace` | `allowedCategoryPatterns` | Comma-separated list of regular expression patterns. Each [client library's `categories` value][aem-clientlibrary] must match at least one of the given patterns. | 1.0.0
52+
`netcentric-embedded-namespace` | `allowedBundleSymbolicNamePatterns` | Comma-separated list of regular expression patterns. Each [embedded bundle in the package][embedded] must have a `Bundle-SymbolicName` in its manifest which matches at least one of the given patterns. | 1.1.0
5153

5254
*Due to the use of comma-separated strings it is not possible to use a comma within the regular expressions. However, as those are matched against names/paths (which don't allow a comma anyhow) using the comma inside the regular expressions shouldn't be necessary anyhow.*
5355

@@ -67,44 +69,49 @@ You can use this validator with the [FileVault Package Maven Plugin][filevault-p
6769
<validatorsSettings>
6870
<netcentric-authorizable-namespace>
6971
<options>
70-
<allowedPrincipalNamePatterns>mytenant-.*</allowedPrincipalNamePatterns>
71-
<allowedAuthorizableIdPatterns>mytenant-.*</allowedAuthorizableIdPatterns>
72+
<allowedPrincipalNamePatterns>mytenant-.*</allowedPrincipalNamePatterns>
73+
<allowedAuthorizableIdPatterns>mytenant-.*</allowedAuthorizableIdPatterns>
7274
</options>
7375
</netcentric-authorizable-namespace>
7476
<netcentric-clientlibrary-namespace>
7577
<options>
76-
<allowedCategoryPatterns>mytenant-.*</allowedCategoryPatterns>
78+
<allowedCategoryPatterns>mytenant-.*</allowedCategoryPatterns>
7779
</options>
7880
</netcentric-clientlibrary-namespace>
7981
<netcentric-filter-namespace>
8082
<options>
81-
<allowedFilterRootPatterns>/apps/mytenant(/.*)?,/conf/mytenant(/.*)?,/home/users/mytenant(/.*)?,/oak:index/mytenant-(.*)</allowedFilterRootPatterns>
83+
<allowedFilterRootPatterns>/apps/mytenant(/.*)?,/conf/mytenant(/.*)?,/home/users/mytenant(/.*)?,/oak:index/mytenant-(.*)</allowedFilterRootPatterns>
8284
</options>
8385
</netcentric-filter-namespace>
8486
<netcentric-oakindex-namespace>
8587
<options>
86-
<allowedPathPatterns>/content/mytenant(/.*)?</allowedPathPatterns>
88+
<allowedPathPatterns>/content/mytenant(/.*)?</allowedPathPatterns>
8789
</options>
8890
</netcentric-oakindex-namespace>
8991
<netcentric-osgiconfig-namespace>
9092
<options>
91-
<allowedPidPatterns>com\.example\.mytenant\..*</allowedPidPatterns>
92-
<allowedFactoryPidNames>name.*</allowedFactoryPidNames>
93-
<restrictFactoryConfigurationsToAllowedPidPatterns>true</restrictFactoryConfigurationsToAllowedPidPatterns>
93+
<allowedPidPatterns>com\.example\.mytenant\..*</allowedPidPatterns>
94+
<allowedFactoryPidNames>name.*</allowedFactoryPidNames>
95+
<restrictFactoryConfigurationsToAllowedPidPatterns>true</restrictFactoryConfigurationsToAllowedPidPatterns>
9496
</options>
9597
</netcentric-osgiconfig-namespace>
9698
<netcentric-packageid-namespace>
9799
<options>
98-
<allowedGroupPatterns>biz\.netcentric\.filevault\.validator\.aem\.namespace\.it</allowedGroupPatterns>
99-
<allowedNamePatterns>.*-package</allowedNamePatterns>
100+
<allowedGroupPatterns>biz\.netcentric\.filevault\.validator\.aem\.namespace\.it</allowedGroupPatterns>
101+
<allowedNamePatterns>.*-package</allowedNamePatterns>
100102
</options>
101103
</netcentric-packageid-namespace>
102104
<netcentric-resourcetype-namespace>
103105
<options>
104-
<allowedSuperTypePatterns>/apps/mytenant2/components/.*</allowedSuperTypePatterns>
105-
<allowedTypePatterns>/apps/mytenant2/components/.*</allowedTypePatterns>
106+
<allowedSuperTypePatterns>/apps/mytenant2/components/.*</allowedSuperTypePatterns>
107+
<allowedTypePatterns>/apps/mytenant2/components/.*</allowedTypePatterns>
106108
</options>
107109
</netcentric-resourcetype-namespace>
110+
<netcentric-embedded-namespace>
111+
<options>
112+
<allowedBundleSymbolicNamePatterns>mytenant-.*<allowedBundleSymbolicNamePatterns>
113+
</options>
114+
</netcentric-embedded-namespace>
108115
</validatorsSettings>
109116
</configuration>
110117
<dependencies>
@@ -131,4 +138,5 @@ Adobe, and AEM are either registered trademarks or trademarks of Adobe in the Un
131138
[filevault-package-id]: https://jackrabbit.apache.org/filevault/properties.html
132139
[sling-resource-type]: https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-types
133140
[oak-authorizables]: https://jackrabbit.apache.org/oak/docs/security/user/default.html#representation-in-the-repository
141+
[embedded]: https://jackrabbit.apache.org/filevault-package-maven-plugin/osgi.html#bundles-and-configurations
134142

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>biz.netcentric.filevault.validator</groupId>
55
<artifactId>aem-content-package-namespace-validators</artifactId>
6-
<version>1.0.2-SNAPSHOT</version>
6+
<version>1.1.0-SNAPSHOT</version>
77

88
<name>AEM FileVault Content Package Namespace Validators</name>
99
<description>FileVault validators which verify that content packages comply with certain namespacing rules.</description>

src/it/inside-namespace/container-package/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616
<artifactId>filevault-package-maven-plugin</artifactId>
1717
<configuration>
1818
<packageType>container</packageType>
19+
<embeddeds>
20+
<embedded>
21+
<artifactId>commons-lang3</artifactId>
22+
<filter>true</filter>
23+
</embedded>
24+
</embeddeds>
25+
<embeddedTarget>/apps/mytenant/install</embeddedTarget>
1926
</configuration>
2027
</plugin>
2128
</plugins>
2229
</build>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.commons</groupId>
34+
<artifactId>commons-lang3</artifactId>
35+
<version>3.17.0</version>
36+
</dependency>
37+
</dependencies>
2338
</project>

src/it/inside-namespace/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
<allowedTypePatterns>/apps/mytenant2/components/.*</allowedTypePatterns>
9595
</options>
9696
</netcentric-resourcetype-namespace>
97+
<netcentric-embedded-namespace>
98+
<options>
99+
<allowedBundleSymbolicNamePatterns>org.apache.commons.lang3</allowedBundleSymbolicNamePatterns>
100+
</options>
101+
</netcentric-embedded-namespace>
97102
</validatorsSettings>
98103
</configuration>
99104
<dependencies>

src/it/no-config/container-package/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616
<artifactId>filevault-package-maven-plugin</artifactId>
1717
<configuration>
1818
<packageType>container</packageType>
19+
<embeddeds>
20+
<embedded>
21+
<artifactId>commons-lang3</artifactId>
22+
<filter>true</filter>
23+
</embedded>
24+
</embeddeds>
25+
<embeddedTarget>/apps/mytenant/install</embeddedTarget>
1926
</configuration>
2027
</plugin>
2128
</plugins>
2229
</build>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.commons</groupId>
34+
<artifactId>commons-lang3</artifactId>
35+
<version>3.17.0</version>
36+
</dependency>
37+
</dependencies>
2338
</project>

src/it/outside-namespace/container-package/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616
<artifactId>filevault-package-maven-plugin</artifactId>
1717
<configuration>
1818
<packageType>container</packageType>
19+
<embeddeds>
20+
<embedded>
21+
<artifactId>commons-lang3</artifactId>
22+
<filter>true</filter>
23+
</embedded>
24+
</embeddeds>
25+
<embeddedTarget>/apps/mytenant/install</embeddedTarget>
1926
</configuration>
2027
</plugin>
2128
</plugins>
2229
</build>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.commons</groupId>
34+
<artifactId>commons-lang3</artifactId>
35+
<version>3.17.0</version>
36+
</dependency>
37+
</dependencies>
2338
</project>

src/it/outside-namespace/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@
100100
<allowedTypePatterns>/apps/mytenant2/components/.*</allowedTypePatterns>
101101
</options>
102102
</netcentric-resourcetype-namespace>
103+
<netcentric-embedded-namespace>
104+
<options>
105+
<allowedBundleSymbolicNamePatterns>some-unused-prefix</allowedBundleSymbolicNamePatterns>
106+
</options>
107+
</netcentric-embedded-namespace>
103108
</validatorsSettings>
104109
</configuration>
105110
<dependencies>

src/it/outside-namespace/verify.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ assert buildLog.contains("""[ERROR] ValidationViolation: Filter root '/home/user
2323

2424
// container-package
2525
assert buildLog.contains("""[ERROR] ValidationViolation: Filter root '/apps/mytenant/config' is not allowed (does not match any of the allowed patterns [/apps/mytenant2(/.*)?,/conf/mytenant2(/.*)?,/home/users/mytenant2(/.*)?,/oak:index/mytenant2-(.*)]) @ META-INF${File.separator}vault${File.separator}filter.xml, validator: netcentric-filter-namespace
26+
[ERROR] ValidationViolation: Filter root '/apps/mytenant/install/commons-lang3-3.17.0.jar' is not allowed (does not match any of the allowed patterns [/apps/mytenant2(/.*)?,/conf/mytenant2(/.*)?,/home/users/mytenant2(/.*)?,/oak:index/mytenant2-(.*)]) @ META-INF${File.separator}vault${File.separator}filter.xml, validator: netcentric-filter-namespace
2627
[ERROR] ValidationViolation: Package group 'biz.netcentric.filevault.validator.aem.namespace.it' is not allowed (does not match any of the group patterns [invalid-group]) @ META-INF${File.separator}vault${File.separator}properties.xml, validator: netcentric-packageid-namespace
2728
[ERROR] ValidationViolation: Package name 'container-package' is not allowed (does not match any of the name patterns [invalid-name]) @ META-INF${File.separator}vault${File.separator}properties.xml, validator: netcentric-packageid-namespace
2829
[ERROR] ValidationViolation: OSGi configuration PID 'com.example.mytenant.MyComponent2' is not allowed to be configured (does not match any of the allowed patterns [com\\.example\\.mytenant2\\..*]) @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}config${File.separator}com.example.mytenant.MyComponent2.cfg.json, validator: jackrabbit-osgiconfigparser
2930
[ERROR] ValidationViolation: OSGi configuration PID 'com.example.mytenant.MyComponent' is not allowed to be configured (does not match any of the allowed patterns [com\\.example\\.mytenant2\\..*]) @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}config${File.separator}com.example.mytenant.MyComponent~name.cfg.json, validator: jackrabbit-osgiconfigparser
30-
[ERROR] ValidationViolation: OSGi factory configuration PID 'com.example.mytenant.MyComponent' is not allowed with the given subname 'name' (does not match any of the allowed patterns [othername.*]) @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}config${File.separator}com.example.mytenant.MyComponent~name.cfg.json, validator: jackrabbit-osgiconfigparser""") : 'container-package'
31+
[ERROR] ValidationViolation: OSGi factory configuration PID 'com.example.mytenant.MyComponent' is not allowed with the given subname 'name' (does not match any of the allowed patterns [othername.*]) @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}config${File.separator}com.example.mytenant.MyComponent~name.cfg.json, validator: jackrabbit-osgiconfigparser
32+
[ERROR] ValidationViolation: Bundle-SymbolicName 'org.apache.commons.lang3' does not match any of the allowed patterns [some-unused-prefix] @ jcr_root${File.separator}apps${File.separator}mytenant${File.separator}install${File.separator}commons-lang3-3.17.0.jar, validator: netcentric-embedded-namespace""") : 'container-package'
3133

3234
return true

0 commit comments

Comments
 (0)