Skip to content

Commit

Permalink
use .Site.Params.cveFeedBucket
Browse files Browse the repository at this point in the history
Signed-off-by: David Ahmadov <[email protected]>
  • Loading branch information
ahmedavid committed Nov 27, 2023
1 parent 84eae82 commit 4baf7b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions layouts/shortcodes/cve-feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ warnf "CVE feed shortcode. KEP-3203: CVE feed does not comply with JSON feed v1.1." }}
{{ end }}

<table class="security-cves">
<table class="security-cves" data-cve-feed-bucket="{{ .Site.Params.cveFeedBucket }}">
<caption style="caption-side: top;">{{ T "cve_table" }} {{ printf (T "cve_table_date_format_string") ($feed._kubernetes_io.updated_at | time.Format (T "cve_table_date_format")) }}</caption>
<thead>
<tr>
Expand All @@ -26,6 +26,7 @@
<script>
window.addEventListener("DOMContentLoaded", () => {
const table = document.querySelector("table.security-cves")
const cveFeedBucket = table.getAttribute("data-cve-feed-bucket")
const tbody = table.querySelector("tbody")
const cachedInnerHTML = tbody.innerHTML

Expand All @@ -42,15 +43,15 @@
}

setInterval(() => {
fetch(`${window.location.origin}/docs/reference/issues-security/official-cve-feed/index.json`)
fetch(cveFeedBucket)
.then(resp => resp.json())
.then(content => {
tbody.innerHTML = renderCVEs(content.items)
}).catch(() => {
// If cannot fetch cves, show cached cves
tbody.innerHTML = cachedInnerHTML
})
}, 60 * 1000) // 60 seconds
}, 10 * 60 * 1000) // 10 mins

})
</script>
</script>

0 comments on commit 4baf7b5

Please sign in to comment.