Introduce Documentation:searchfree_safe with local-only fonts
Gerrit documentation uses asciidoc webfonts [1] which can be flagged
as a security issue because of Content Security Policies [2].
[1] https://docs.asciidoctor.org/asciidoctor/latest/html-backend/default-stylesheet/#disable-or-modify-the-web-fonts
[2] https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
Release-Notes: Allow generating safe local-only documentation
Change-Id: Ide4369ca19473822fc5305aa0fc21665a2bc6f0c
diff --git a/Documentation/BUILD b/Documentation/BUILD
index af355ca..85ddbe7 100644
--- a/Documentation/BUILD
+++ b/Documentation/BUILD
@@ -126,3 +126,13 @@
directory = DOC_DIR,
searchbox = False,
)
+
+genasciidoc_zip(
+ name = "searchfree_safe",
+ srcs = SRCS,
+ attributes = documentation_attributes(),
+ backend = "html5",
+ directory = DOC_DIR,
+ searchbox = False,
+ webfonts = False,
+)
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index 08529df..a2bd6fc 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -225,6 +225,19 @@
bazel-bin/Documentation/searchfree.zip
----
+To use local fonts with the searchfree target:
+
+----
+ bazel build Documentation:searchfree_safe
+----
+
+The html files will be bundled into `searchfree.zip` or `searchfree_safe.zip` in this location:
+
+----
+ bazel-bin/Documentation/searchfree.zip
+ bazel-bin/Documentation/searchfree_safe.zip
+----
+
To generate HTML files skipping the zip archiving:
----
diff --git a/tools/bzl/asciidoc.bzl b/tools/bzl/asciidoc.bzl
index 7977cf0..d6b6d63 100644
--- a/tools/bzl/asciidoc.bzl
+++ b/tools/bzl/asciidoc.bzl
@@ -300,13 +300,14 @@
backend = None,
searchbox = True,
resources = True,
+ webfonts = True,
**kwargs):
SUFFIX = "_htmlonly"
_genasciidoc_htmlonly_zip(
name = name + SUFFIX if resources else name,
srcs = srcs,
- attributes = attributes,
+ attributes = attributes + [] if webfonts else ["webfonts!"],
backend = backend,
searchbox = searchbox,
**kwargs