feat(s3-publishing): Add S3 static publishing support for vanity URLs#35808
feat(s3-publishing): Add S3 static publishing support for vanity URLs#35808dsilvam wants to merge 1 commit into
Conversation
- Add STATIC_PUSH_S3_VANITY_ALIAS_ENABLED feature flag - Add S3VanityAliasService and supporting classes for vanity URL handling - Add s3_vanity_alias table migration (Task260408CreateS3VanityAliasTable) - Update AWSS3Publisher and AWSS3EndPointPublisher to resolve vanity aliases - Opt-in behavior: no impact unless feature flag is enabled Closes #35663
|
Claude finished @dsilvam's task in 4m 40s —— View job ✅ dotCMS Backend Review Complete
Summary
Findings (full detail in the review comment):
No 🔴 Critical or 🟠 High issues — nothing here blocks merging on backend-review grounds. |
|
Semgrep found 16
The method identified is susceptible to injection. The input should be validated and properly If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
🔍 dotCMS Backend Review[🟡 Medium]
private static final String UNSUPPORTED_CHARS = "*?[](){}|^$\\+";
...
if (!normalized.startsWith(StringPool.FORWARD_SLASH) || containsUnsupportedChars(normalized)) {
return Optional.empty();
}
return Optional.of(normalized.replaceAll("/{2,}", "/"));💡 After normalization, split on [🟡 Medium]
final List<Contentlet> contentlets = contentletAPI.search("+identifier:" + asset.getAsset() + " +live:true",
0, 0, null, APILocator.getUserAPI().getSystemUser(), false);💡 Either Lucene-escape the identifier ( Next steps
|
| final User systemUser = APILocator.getUserAPI().getSystemUser(); | ||
| final Optional<String> canonicalPath = aliasSupport.normalizeCanonicalPath( | ||
| aliasSupport.getForwardTo(vanityContentlet)); | ||
| final Optional<S3VanityResolvedTarget> target = resolveTarget(context, canonicalPath.get(), systemUser); |
There was a problem hiding this comment.
canonicalPath.get() without isPresent might result in a NPE
|
|
||
| private static final String CREATED_BUCKETS = "createdBuckets"; | ||
| private static final Lazy<Boolean> STATIC_PUSH_S3_VANITY_ALIAS_ENABLED = | ||
| Lazy.of(() -> Config.getBooleanProperty("STATIC_PUSH_S3_VANITY_ALIAS_ENABLED", false)); |
There was a problem hiding this comment.
This does not allow changes on the fly.
If you cache in a lazy wrapper, you will have to restart to see it take effect
| Logger.info(this, "Sleeping before next push try, seconds: " + secondsToSleep); | ||
| Thread.sleep(secondsToSleep * 1000); | ||
| } catch (InterruptedException ie) { | ||
| Logger.error(this, "Can't Sleep before retry file: " + file.getAbsolutePath()); |
There was a problem hiding this comment.
we're missing a Thread.currentThread().interrupt(); here
| * @param context publishing context | ||
| * @param aliases aliases to remove | ||
| */ | ||
| private void rollbackAliases(final S3VanityAliasContext context, final List<S3VanityAlias> aliases) { |
There was a problem hiding this comment.
This is never called.
its dead code
| } | ||
|
|
||
| /** | ||
| * Indica se il file viene gestito dal publisher S3. |
There was a problem hiding this comment.
italian - must be English
Summary
This PR carries the same changes as #35643 (originally authored by @riccardoruocco), opened under a different account so CI checks can run.
Proposed Changes
STATIC_PUSH_S3_VANITY_ALIAS_ENABLED, to enable Vanity URL handling for AWS S3 static publishing. When the flag isfalse, dotCMS behaves exactly as it does today and no Vanity URL alias is generated.true, publishing a Vanity URL to a static S3 endpoint makes dotCMS resolve the target content, identify the live resource, render or copy it, and write the static clone to the S3 path represented by the Vanity URL.s3_vanity_aliastable, which acts as an operational snapshot of the Vanity URL state on S3 and stores the aliases that have actually been materialized.Additional Info
The goal of this change is to make Vanity URLs work on static S3 publishing in the same way they already work at runtime on live dotCMS.
The implementation is intentionally opt-in and does not affect existing installations unless
STATIC_PUSH_S3_VANITY_ALIAS_ENABLED=trueis set.The
s3_vanity_aliastable is used as the source of truth for what was actually written to S3, so publish, republish, unpublish, and delete can all behave consistently without depending only on the current live content state.Closes #35663