diff --git a/static/js/src/cve/cve.js b/static/js/src/cve/cve.js index a7b685f0e92..e93c08b4233 100644 --- a/static/js/src/cve/cve.js +++ b/static/js/src/cve/cve.js @@ -9,10 +9,12 @@ import { const searchInput = document.querySelector("#q"); const searchForm = document.querySelector("#searchForm"); -const cveList = document.querySelector("#cve-list"); -const recentCves = document.querySelector("#recent-cves"); const url = new URL(window.location.href); const urlParams = new URLSearchParams(url.search); +const limitSelect = document.querySelector(".js-limit-select"); +const orderSelect = document.querySelector(".js-order-select"); +const exportLink = document.querySelector("#js-export-link"); +const apiBase = "https://ubuntu.com/security/cves.json"; function handleCveIdInput(value) { const packageInput = document.querySelector("#package"); @@ -153,11 +155,39 @@ tooltipIconList.forEach(function (tooltipIcon) { ); }); -function showCVEList() { - if (urlParams.has("status")) { - recentCves.classList.add("u-hide"); - cveList.classList.remove("u-hide"); +function handleLimitSelect() { + if (urlParams.has("limit")) { + limitSelect.value = urlParams.get("limit"); } + + limitSelect.onchange = function (event) { + limitSelect.value = event.target.value; + urlParams.set("limit", limitSelect.value); + url.search = urlParams.toString(); + window.location.href = url.href; + }; } +handleLimitSelect(); + +function handleOrderSelect() { + if (urlParams.has("order")) { + orderSelect.value = urlParams.get("order"); + } -showCVEList(); + orderSelect.onchange = function (event) { + orderSelect.value = event.target.value; + urlParams.set("order", orderSelect.value); + url.search = urlParams.toString(); + window.location.href = url.href; + }; +} +handleOrderSelect(); + +function exportToJSON() { + exportLink.onclick = function (event) { + event.preventDefault(); + let apiURL = new URL(url.search, apiBase); + window.location.href = apiURL.href; + }; +} +exportToJSON(); diff --git a/static/sass/_pattern_cve.scss b/static/sass/_pattern_cve.scss index 4b1d7d9609e..f9751c9d151 100644 --- a/static/sass/_pattern_cve.scss +++ b/static/sass/_pattern_cve.scss @@ -224,4 +224,82 @@ border-bottom-color: #66a61e; } + + .cve-landing { + .p-inline-list { + margin-top: 0.3rem; + } + } + + .cve-results { + display: flex; + justify-content: space-between; + + .p-text--small-caps { + display: inline-flex; + } + + .p-form { + display: flex; + gap: 2.5rem; + } + + .p-form__group { + margin-left: auto; + margin-right: 0; + } + + .p-form__control { + max-width: fit-content; + min-width: 0; + padding-right: 1rem; + } + } + + .cve-card-header { + margin-bottom: 1.1rem; + padding-top: 0.4rem; + + h2 { + display: inline; + padding-top: 0; + } + + #priority-icon { + float: inline-end; + } + } + + .cve-pagination-footer { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + } + + .cve-pagination-footer-links { + display: flex; + gap: inherit; + + a { + margin-top: 0.4rem; + } + + @media screen and (max-width: $breakpoint-small - 1) { + flex-direction: column; + gap: 1rem; + } + + .p-form__control { + max-width: fit-content; + min-width: 0; + padding-right: 1rem; + } + } + + #cve-search-button { + @media screen and (min-width: $breakpoint-small) { + margin-top: 2.6rem; + width: 100%; + } + } } diff --git a/templates/security/cve/_cve-card.html b/templates/security/cve/_cve-card.html new file mode 100644 index 00000000000..23e93a96dc0 --- /dev/null +++ b/templates/security/cve/_cve-card.html @@ -0,0 +1,80 @@ +{% for cve in cves %} +
Some fixes available {{ status.fixed_count }} of {{ status.total_count }}
+ {% elif status.name == "Needs evaluation" %} ++ Needs evaluation +
+ {% elif status.name == "Fixed" %} ++ Fixed +
+ {% elif status.name == "Vulnerable" %} ++ Vulnerable +
+ {% elif status.name == "DNE" %} ++ Not in release +
+ {% else %} + {{status}} + {% endif %} +{{ cve.description|truncate(235) }}
+{{ cve.packages | length}} affected packages
++ {% for package in cve.packages %} + {% if cve.packages | length > 6 %} + {% if loop.index < 5 %} + {{ package.name }}, + {% elif loop.index == 5 %} + {{ package.name }}... + {% endif %} + {% else %} + {% if loop.last %} + {{ package.name }} + {% else %} + {{ package.name }}, + {% endif %} + {% endif %} + {% endfor %} +
Filters
+10-year security coverage for Ubuntu
+ and 23,000 open-source applications and toolchains.Get Ubuntu Pro ++ {% if total_results > 1 %} + {{ offset + 1 }} + – + {% if offset + limit > total_results %} + {{ total_results }} + {% else %} + {{ offset + limit }} + {% endif %} + of + {% endif %} + {{ total_results }} result{% if total_results != 1 %}s{% endif %} +
+The Common Vulnerabilities and Exposures (CVE) system is used to identify, define, and catalog publicly disclosed cybersecurity vulnerabilities. Canonical keeps track of all CVEs affecting Ubuntu, and releases a security notice when an issue is fixed.
@@ -29,224 +32,11 @@- {{ cve.id }} - - {% if cve.priority == 'unknown' %} - - {% elif cve.priority == 'negligible' %} - - {% elif cve.priority == 'low' %} - - {% elif cve.priority == 'medium' %} - - {% elif cve.priority == 'high' %} - - {% elif cve.priority == 'critical' %} - - {% else %} - - {% endif %} - {{ cve.priority.split() | first | capitalize }} priority - -
-Some fixes available {{ status.fixed_count }} of {{ status.total_count }}
- {% elif status.name == "Needs evaluation" %} -- Needs evaluation -
- {% endif %} - -{{ cve.description }}
-{{ cve.packages | length}} affected packages
-- {% for package in cve.packages %} - {% if cve.packages | length > 6 %} - {% if loop.index < 6 %} - {{ package.name }}, - {% elif loop.index == 6 %} - and {{ cve.packages | length - 5 }} more - {% endif %} - {% else %} - {% if loop.last %} - {{ package.name }} - {% else %} - {{ package.name }}, - {% endif %} - {% endif %} - {% endfor %} -
10-year security coverage for Ubuntu
- and 23,000 open-source applications and toolchains.Get Ubuntu Pro -