From 75b05f54c1378270dbcf2035278cf6aefd0aea88 Mon Sep 17 00:00:00 2001 From: muratclk Date: Thu, 9 Apr 2026 03:43:06 +0300 Subject: [PATCH] feat: add rel=nofollow to external links on website Add rel="nofollow" to external-facing links to discourage search engine crawlers from promoting potentially malicious pages linked from vulnerability references. Changes: - vulnerability.html: Add nofollow to all data-driven links (source links, references, CVSS calculators, commit links, package links, credit contacts) - home.html: Add nofollow to third-party repository links - linter/index.html: Add nofollow to external tool link - blog: Add Hugo render hook to automatically apply nofollow to external links in blog post content Trusted domains (deps.dev, google.github.io, ossf.github.io, github.com/google/*, security.googleblog.com, osv.dev) are allowlisted and do not receive nofollow. Fixes #4644 --- .../layouts/_default/_markup/render-link.html | 22 +++++++++++++++++ gcp/website/frontend3/src/templates/home.html | 8 +++---- .../frontend3/src/templates/linter/index.html | 2 +- .../src/templates/vulnerability.html | 24 +++++++++---------- 4 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 gcp/website/blog/layouts/_default/_markup/render-link.html diff --git a/gcp/website/blog/layouts/_default/_markup/render-link.html b/gcp/website/blog/layouts/_default/_markup/render-link.html new file mode 100644 index 00000000000..be680a6dee2 --- /dev/null +++ b/gcp/website/blog/layouts/_default/_markup/render-link.html @@ -0,0 +1,22 @@ +{{- $url := .Destination -}} +{{- $isExternal := or (hasPrefix $url "http://") (hasPrefix $url "https://") -}} +{{- $isTrusted := false -}} +{{- if $isExternal -}} + {{- $isTrusted = or + (hasPrefix $url "https://google.github.io/") + (hasPrefix $url "https://ossf.github.io/") + (hasPrefix $url "https://deps.dev/") + (hasPrefix $url "https://security.googleblog.com/") + (hasPrefix $url "https://github.com/google/") + (hasPrefix $url "https://osv.dev/") + (hasPrefix $url "https://api.osv.dev/") + -}} +{{- end -}} +{{ .Text | safeHTML }} diff --git a/gcp/website/frontend3/src/templates/home.html b/gcp/website/frontend3/src/templates/home.html index 062a85564e9..85e0b588d8a 100644 --- a/gcp/website/frontend3/src/templates/home.html +++ b/gcp/website/frontend3/src/templates/home.html @@ -139,10 +139,10 @@

Data sources

This infrastructure serves as an aggregator of vulnerability databases that have adopted the OSV schema, including - GitHub Security Advisories, - PyPA, - RustSec, and - Global Security Database, and + GitHub Security Advisories, + PyPA, + RustSec, and + Global Security Database, and more.

diff --git a/gcp/website/frontend3/src/templates/linter/index.html b/gcp/website/frontend3/src/templates/linter/index.html index 903b89ef09b..da68812b2a1 100644 --- a/gcp/website/frontend3/src/templates/linter/index.html +++ b/gcp/website/frontend3/src/templates/linter/index.html @@ -25,7 +25,7 @@

Open Source Vulnerabilities

- Run OSV-Linter + Run OSV-Linter
diff --git a/gcp/website/frontend3/src/templates/vulnerability.html b/gcp/website/frontend3/src/templates/vulnerability.html index 3a37f434249..d1faee2eecb 100644 --- a/gcp/website/frontend3/src/templates/vulnerability.html +++ b/gcp/website/frontend3/src/templates/vulnerability.html @@ -14,7 +14,7 @@

{{ vulnerability.id }}

{% if vulnerability.human_source_link and vulnerability.human_source_link.startswith("https://github.com/advisories/") -%} - + Suggest an improvement {% elif vulnerability.human_source_link and not vulnerability.id.startswith("openSUSE-") -%} @@ -23,7 +23,7 @@

See a problem?
- Please try reporting it to the source first. + Please try reporting it to the source first. {% else -%} @@ -35,12 +35,12 @@

{%- if vulnerability.human_source_link and not vulnerability.id.startswith("openSUSE-") -%}
Source
-
{{ +
{{ vulnerability.human_source_link }}
{%- endif -%}
Import Source
-
{{ +
{{ vulnerability.source }}
JSON Data
@@ -107,7 +107,7 @@

{% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} - + CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} @@ -141,7 +141,7 @@

@@ -157,7 +157,7 @@

  • @@ -227,7 +227,7 @@

    Severity

    {% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} - + CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} @@ -257,7 +257,7 @@

    Affected ranges {% set link = event | event_link -%} {% if link -%} - {{ event | event_value -}} + {{ event | event_value -}} {% elif event | event_type == 'Introduced' and event | event_value == '0' -%}
    {{ event | event_value -}} {% if range.type == 'GIT' %} @@ -364,7 +364,7 @@

    Name
    {%- if affected.package | package_in_ecosystem -%} -
    {{ +
    {{ affected.package.name }}
    {%- else -%}
    {{ affected.package.name }}
    @@ -393,7 +393,7 @@

    {% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} - + CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} @@ -430,7 +430,7 @@

    {% set link = event | event_link -%} {% if link -%} - + {{ event | event_value -}} {% elif event | event_type == 'Introduced' and event | event_value == '0' -%}