Skip to content

HBASE-29115 Fix website cannot load some resources because of CSP - #6668

Merged
NihalJain merged 4 commits into
apache:masterfrom
PDavid:HBASE-29115-website-csp-blocks-resources
Feb 28, 2025
Merged

HBASE-29115 Fix website cannot load some resources because of CSP#6668
NihalJain merged 4 commits into
apache:masterfrom
PDavid:HBASE-29115-website-csp-blocks-resources

Conversation

@PDavid

@PDavidPDavid commented Feb 7, 2025

Copy link
Copy Markdown
Contributor
  • Self-host Bootstrap CSS, highlight.js (CSS and JS) for the website instead of trying load it from CDN-s. Because of the new CSP, loading these from CDN-s is blocked.
  • Switch to local fontawesome (used for icons) in Reference Guide (book.html) instead of using CDN as per this guide: https://docs.asciidoctor.org/asciidoctor/latest/html-backend/local-font-awesome/.
    • Set stylesdir so that book.html will include /css/font-awesome.css (where the file is) and not /font-awesome.css.
  • Replace MathJax CDN URI with local one in book.html

@PDavid

Copy link
Copy Markdown
ContributorAuthor

I'm not sure if this is the most efficient way to download and extract the CSS and JS files with Maven, so any feedback is appreciated.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

Would be great to upgrade from Bootstrap 2.3.2 as it contains 6 CVE-s and it is end of life since 11 years...

@PDavid

Copy link
Copy Markdown
ContributorAuthor

Tested this locally by building the website with mvn site and serving it with python3 -m http.server 8000:

image

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
PDavidforce-pushed the HBASE-29115-website-csp-blocks-resources branch from 3b3a7fa to 8b4549cCompareFebruary 10, 2025 10:20
@PDavid

Copy link
Copy Markdown
ContributorAuthor

Still looking into the last problem: The Reference Guide HTML page tries to load the MathJax.js library from cdnjs.cloudflare.com (which is also blocked by CSP).

@PDavid

Copy link
Copy Markdown
ContributorAuthor

Still looking into the last problem: The Reference Guide HTML page tries to load the MathJax.js library from cdnjs.cloudflare.com (which is also blocked by CSP).

Unfortunately it seems that right now there is no way to influence from where the Reference Guide Asciidoc includes the MathJax.js library.

@Apache9

Copy link
Copy Markdown
Contributor

Is it possible to replace the location string in the generated HTML when committing the changes to our site repo?

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
PDavidforce-pushed the HBASE-29115-website-csp-blocks-resources branch from 8b4549c to 512dba7CompareFebruary 24, 2025 17:17
@PDavid

PDavid commented Feb 24, 2025

Copy link
Copy Markdown
ContributorAuthor

Tested this locally, now even the mathematical formulas are rendered:
image

Also I used the ModHeader Chrome extension to set the Content-Security-Policy header on the page.

@PDavid
PDavidforce-pushed the HBASE-29115-website-csp-blocks-resources branch from 512dba7 to 52fba14CompareFebruary 24, 2025 17:24
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@PDavid
PDavid marked this pull request as ready for review February 25, 2025 07:19
@PDavid

Copy link
Copy Markdown
ContributorAuthor

Hi @Apache9, @ndimiduk, @NihalJain,

Can you please have a look on this?

As far as I understand, the new Content Security Policy (CSP) will be turned on March 1st, 2025. While the website seemed to be functional, the reference guide (book.html) had some smaller issues (missing icons, not rendered mathematical formulas, etc).

The PR build failed but as I saw it was unrelated.

Comment threadpom.xml Outdated
Comment threadpom.xml
Comment threadpom.xml
Comment threadsrc/site/site.xml
Comment threadpom.xml Outdated
Comment threadpom.xml
@Apache-HBase

This comment has been minimized.

@ndimidukndimiduk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have nothing to add here, @NihalJain has got you. Thanks for picking this up, @PDavid !

Comment threaddev-support/jenkins-scripts/generate-hbase-website.sh
Comment threadpom.xml
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, Today I Learn

@Apache-HBase

This comment has been minimized.

@NihalJain

Copy link
Copy Markdown
Contributor

@PDavid Please let me know if I can go ahead and merge this now.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

@PDavid Please let me know if I can go ahead and merge this now.

Many thanks @NihalJain. 👍 I now added a comment and links to the MathJax workaround in the shell script. I'd wait until the PR build is done and then I think this is ready to be merged.

@Apache-HBase

This comment has been minimized.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

BTW the PR site build is failing because of checkstyle is not able to parse ReplicaKey.java (because of instanceOf pattern match):

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.0:site (default-site) on project hbase: Error generating maven-checkstyle-plugin:3.1.0:checkstyle-aggregate report: Failed during checkstyle configuration: Exception was thrown while processing /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java: IllegalStateException occurred while parsing file /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java. /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java:43:35: expecting RPAREN, found 'other' -> [Help 1]

Probably checktyle needs to be updated. @petersomogyi is already mentioned that he is looking into this issue.

@Apache9

Copy link
Copy Markdown
Contributor

BTW the PR site build is failing because of checkstyle is not able to parse ReplicaKey.java (because of instanceOf pattern match):

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.0:site (default-site) on project hbase: Error generating maven-checkstyle-plugin:3.1.0:checkstyle-aggregate report: Failed during checkstyle configuration: Exception was thrown while processing /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java: IllegalStateException occurred while parsing file /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java. /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java:43:35: expecting RPAREN, found 'other' -> [Help 1]

Probably checktyle needs to be updated. @petersomogyi is already mentioned that he is looking into this issue.

Please file an issue to use java 8 style instanceof to fix the problem, to align the code between branch-3+ and branch-2.x? @rmdmattingly ?

@PDavid

Copy link
Copy Markdown
ContributorAuthor

BTW the PR site build is failing because of checkstyle is not able to parse ReplicaKey.java (because of instanceOf pattern match):

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.0:site (default-site) on project hbase: Error generating maven-checkstyle-plugin:3.1.0:checkstyle-aggregate report: Failed during checkstyle configuration: Exception was thrown while processing /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java: IllegalStateException occurred while parsing file /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java. /home/jenkins/jenkins-home/workspace/Base-PreCommit-GitHub-PR_PR-6724/yetus-general-check/src/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKey.java:43:35: expecting RPAREN, found 'other' -> [Help 1]

Probably checktyle needs to be updated. @petersomogyi is already mentioned that he is looking into this issue.

Please file an issue to use java 8 style instanceof to fix the problem, to align the code between branch-3+ and branch-2.x? @rmdmattingly ?

@Apache9 proposed a fix here (upgrade checkstyle): #6727

@Apache-HBase

This comment has been minimized.

…f CSP
Self-host Boostrap CSS, highlight.js (CSS and JS) instead of trying load it from CDN-s.
Because of the new CSP, loading these from CDN-s is blocked.
@PDavid
PDavidforce-pushed the HBASE-29115-website-csp-blocks-resources branch from d04d898 to 6d93675CompareFebruary 28, 2025 09:07
@PDavid

Copy link
Copy Markdown
ContributorAuthor

The website build is now fixed on master, so rebased this PR on master to have a better PR build.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 30sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+0 🆗shelldocs0m 1sShelldocs was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ master Compile Tests _
+1 💚mvninstall3m 22smaster passed
+1 💚compile8m 18smaster passed
+1 💚mvnsite6m 55smaster passed
+1 💚spotless0m 49sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚mvninstall3m 49sthe patch passed
+1 💚compile9m 47sthe patch passed
+1 💚javac9m 47sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
+1 💚mvnsite8m 6sthe patch passed
+1 💚shellcheck0m 2sNo new issues.
+1 💚xmllint0m 0sNo new issues.
+1 💚hadoopcheck14m 13sPatch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚spotless0m 51spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 14sThe patch does not generate ASF License warnings.
65m 14s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6668/7/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#6668
Optional Testsdupname asflicense codespell detsecrets shellcheck shelldocs spotless javac xmllint hadoopcheck compile mvnsite
unameLinux be8248429fbf 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 6d93675
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count188 (vs. ulimit of 30000)
modulesC: . U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6668/7/console
versionsgit=2.34.1 maven=3.9.8 shellcheck=0.8.0 xmllint=20913
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 27sDocker mode activated.
-0 ⚠️yetus0m 2sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall3m 44smaster passed
+1 💚compile2m 8smaster passed
+1 💚javadoc1m 54smaster passed
+1 💚shadedjars5m 58sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚mvninstall2m 59sthe patch passed
+1 💚compile2m 7sthe patch passed
+1 💚javac2m 7sthe patch passed
+1 💚javadoc1m 53sthe patch passed
+1 💚shadedjars5m 47spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit290m 36sroot in the patch passed.
325m 15s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6668/7/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#6668
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 99ab6ac46df9 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 6d93675
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6668/7/testReport/
Max. process+thread count8208 (vs. ulimit of 30000)
modulesC: . U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6668/7/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@PDavid

Copy link
Copy Markdown
ContributorAuthor

@NihalJain The PR build looks good to me, I think this PR is now ready to be merged.

@NihalJain
NihalJain merged commit 984f127 into apache:masterFeb 28, 2025
@NihalJain

NihalJain commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

Merged this to master. Thanks @PDavid .

I am away from my laptop. Could you raise backports for all affected branches.? Although I am not sure if these changes are needed by other branches at all.

@PDavid
PDavid deleted the HBASE-29115-website-csp-blocks-resources branch March 3, 2025 07:39
@PDavid

Copy link
Copy Markdown
ContributorAuthor

Merged this to master. Thanks @PDavid .

Thank you very much @NihalJain! 🎉

I am away from my laptop. Could you raise backports for all affected branches.? Although I am not sure if these changes are needed by other branches at all.

In this PR we changed how we include static resources in the website and in the Reference Guide (book.html).
Do we generate the website or the Reference Guide (book.html) in other branches? I think we only build the website on master branch and there was a community decision to also only build the reference guide on master. 🤔

Maybe I can raise the backports, so that we could regenerate the old reference guides (if possible) and the code in pom.xml and site.xml does not get too different between branches.

What do you think?

@ndimiduk

Copy link
Copy Markdown
Member

I believe that we only generate the site and book content from master, so there shouldn't be anything to backport.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@PDavid@Apache-HBase@Apache9@NihalJain@ndimiduk