Scanners Integration (#18)

* Research scanning

* Move files around

* Reports the list

* Scanner happens

* Commit

* Work on alternative

* refactorings

* Progress

* Save the state

* Commit

* Display trivy Results

* Checkov also reports

* Better display

* Correct trivy numbers

* Scan pre-install manifest

* Readme items

* Static checks
This commit is contained in:
Andrey Pokhilko
2022-10-17 13:41:08 +01:00
committed by GitHub
parent 5cae4b5adf
commit f86a4a93a7
22 changed files with 995 additions and 439 deletions

View File

@@ -4,7 +4,7 @@ $("#btnUpgradeCheck").click(function () {
self.find(".spinner-border").show()
const repoName = self.data("repo")
$("#btnUpgrade span").text("Checking...")
$("#btnUpgrade .icon").removeClass("bi-arrow-up bi-pencil").addClass("bi-hourglass")
$("#btnUpgrade .icon").removeClass("bi-arrow-up bi-pencil").addClass("bi-hourglass-split")
$.post("/api/helm/repo/update?name=" + repoName).fail(function (xhr) {
reportError("Failed to update chart repo", xhr)
}).done(function () {
@@ -63,8 +63,9 @@ function checkUpgradeable(name) {
function popUpUpgrade(self, verCur, elm) {
const name = getHashParam("chart");
let url = "/api/helm/charts/install?namespace=" + getHashParam("namespace") + "&name=" + name + "&chart=" + elm.name;
$('#upgradeModal select').data("url", url).data("chart", elm.name)
const qstr = "?namespace=" + getHashParam("namespace") + "&name=" + name + "&chart=" + elm.name;
let url = "/api/helm/charts/install" + qstr
$('#upgradeModal select').data("qstr", qstr).data("url", url).data("chart", elm.name)
$("#upgradeModalLabel .name").text(name)
$("#upgradeModal .ver-old").text(verCur)
@@ -84,7 +85,6 @@ function popUpUpgrade(self, verCur, elm) {
}).fail(function (xhr) {
reportError("Failed to upgrade the chart", xhr)
}).done(function (data) {
console.log(data)
if (data.version) {
setHashParam("revision", data.version)
window.location.reload()
@@ -130,6 +130,40 @@ $('#upgradeModal select').change(function () {
})
})
$('#upgradeModal .btn-scan').click(function () {
const self = $(this)
self.prop("disabled", true).prepend('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>')
const qstr = $('#upgradeModal select').data("qstr")
$.ajax({
type: "POST",
url: "/api/scanners/manifests" + qstr + "&version=" + $('#upgradeModal select').val(),
data: $("#upgradeModal form").serialize(),
}).fail(function (xhr) {
reportError("Failed to scan the manifest", xhr)
}).done(function (data) {
self.prop("disabled", false).find(".spinner-border").hide()
const container = $("<div></div>")
for (let name in data) {
const res = data[name]
if (!res) {
continue
}
const pre = $("<pre></pre>").text(res.OrigReport)
container.append("<h2>" + name + " Scan Results</h2>")
container.append(pre)
}
const tab = window.open('about:blank', '_blank');
tab.document.write(container.prop('outerHTML')); // where 'html' is a variable containing your HTML
tab.document.close(); // to finish loading the page
})
})
function requestChangeDiff() {
const self = $('#upgradeModal select');
const diffBody = $("#upgradeModalBody");
@@ -140,11 +174,11 @@ function requestChangeDiff() {
if ($("#upgradeModal textarea").data("dirty")) {
$("#upgradeModal .invalid-feedback").hide()
values = $("#upgradeModal form").serialize()
try {
jsyaml.load($("#upgradeModal textarea").val())
} catch (e) {
$("#upgradeModal .invalid-feedback").text("YAML parse error: "+e.message).show()
$("#upgradeModal .invalid-feedback").text("YAML parse error: " + e.message).show()
$("#upgradeModalBody").html("Invalid values YAML")
return
}
@@ -155,7 +189,7 @@ function requestChangeDiff() {
url: self.data("url") + "&version=" + self.val(),
data: values,
}).fail(function (xhr) {
$("#upgradeModalBody").html("<p class='text-danger'>Failed to get upgrade info: "+ xhr.responseText+"</p>")
$("#upgradeModalBody").html("<p class='text-danger'>Failed to get upgrade info: " + xhr.responseText + "</p>")
}).done(function (data) {
diffBody.empty();
$("#upgradeModal .btn-confirm").prop("disabled", false)