You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@struts.apache.org by "lukaszlenart (via GitHub)" <gi...@apache.org> on 2026/07/01 10:19:16 UTC

[PR] WW-5640 Add WebJars support to Struts core [struts]

lukaszlenart opened a new pull request, #1765:
URL: https://github.com/apache/struts/pull/1765

   Fixes [WW-5640](https://issues.apache.org/jira/browse/WW-5640)
   
   ## What
   
   Adds first-class **WebJars** support to Struts core: client-side libraries packaged as WebJars (`org.webjars:*`, shipped under `META-INF/resources/webjars/<name>/<version>/…`) can be referenced by a **version-less logical path** and are resolved + served through Struts' existing static-content pipeline.
   
   Example: a template references `bootstrap/css/bootstrap.min.css` → Struts serves `META-INF/resources/webjars/bootstrap/5.3.8/css/bootstrap.min.css` at `<ctx>/static/webjars/bootstrap/5.3.8/css/bootstrap.min.css`.
   
   ## Why
   
   Plugins/apps currently vendor client-side assets on the classpath and re-commit them each release (the struts2-bootstrap plugin commits ~2000 files by hand). WebJars replace this with a dependency bump (auto-updatable via Renovate/Dependabot). First intended consumer: the struts2-bootstrap plugin (separate work).
   
   ## Changes
   
   - **Dependency:** `org.webjars:webjars-locator-lite:1.1.3` (MIT; single Apache-2.0 transitive dep `jspecify`; no Jackson/classpath-scanner — the variant Spring Framework 6.2 adopted).
   - **`WebJarUrlProvider`** (container bean, the public seam for plugins) + `DefaultWebJarUrlProvider` wrapping a singleton `WebJarVersionLocator`.
   - **Serving:** a `/webjars/**` branch in `DefaultStaticContentLoader` reusing existing caching; content-type map extended for fonts/svg/source-maps/json/ico.
   - **`<s:webjar>` tag + `<@s.webjar>` macro** emitting the resolved URL string (composes with `<s:script>`/`<s:link>`; supports `var`).
   - **Config:** `struts.webjars.enabled` (default `true`), `struts.webjars.allowlist` (comma-separated; empty = all).
   
   ## Security
   
   Resolution is hard-constrained to the `META-INF/resources/webjars/` root: per-segment `..`/`.` rejection and backslash rejection before the locator is called, a containment re-check on the resolved path, locator-backed resolution only (unknown webjar → null), plus the optional allowlist. Unresolved / disabled / traversal / allowlist-blocked all **fail closed** (404 when serving, empty output when building URLs). This is hardening for the new endpoint, not a fix to existing shipped behavior.
   
   ## Testing
   
   - Unit: resolution (known → versioned path/URL; unknown → empty), traversal rejection (both `resolveResourcePath` and `resolveUrl`), allowlist, disabled; content-type mappings.
   - Serving: 200 + content-type for a known asset, 404 for unknown, 404 when disabled (servlet-mocked).
   - Tag/macro: renders the resolved URL; `var` storage; empty on unresolved.
   - Full `core` suite: **2985 tests, 0 failures**. No regression to existing static-content serving.
   
   Backward compatible: `enabled=true` only activates the new `<staticContentPath>/webjars/**` namespace; existing `/static/**` serving is untouched.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5640 Add WebJars support to Struts core [struts]

Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart merged PR #1765:
URL: https://github.com/apache/struts/pull/1765


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5640 Add WebJars support to Struts core [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1765:
URL: https://github.com/apache/struts/pull/1765#issuecomment-4853342468

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1765) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [12 New issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1765&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1765&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=1765&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [85.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1765&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1765&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1765)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5640 Add WebJars support to Struts core [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1765:
URL: https://github.com/apache/struts/pull/1765#issuecomment-4853610657

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1765) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1765&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1765&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=1765&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [83.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1765&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1765&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1765)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org