From ad0840bc0f549252b554788d11e0de9543395d41 Mon Sep 17 00:00:00 2001 From: fraxken Date: Thu, 30 Nov 2023 04:47:34 +0100 Subject: [PATCH 1/6] fix(SecureDataSet): properly reset state --- public/js/master.js | 5 ++++- views/index.html | 4 ++-- workspaces/vis-network/src/dataset.js | 21 +++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/public/js/master.js b/public/js/master.js index 19acef14..18c3b9e6 100644 --- a/public/js/master.js +++ b/public/js/master.js @@ -51,7 +51,10 @@ document.addEventListener("DOMContentLoaded", async () => { window.settings.config.ignore.warnings = warningsToIgnore; window.settings.config.ignore.flags = flagsToIgnore; - await secureDataSet.init(secureDataSet.data); + await secureDataSet.init( + secureDataSet.data, + secureDataSet.FLAGS + ); const { nodes } = secureDataSet.build(); nsn.nodes.update(nodes.get()); diff --git a/views/index.html b/views/index.html index 6aafe4d7..6ab00e6c 100644 --- a/views/index.html +++ b/views/index.html @@ -201,8 +201,8 @@

General

weak crypto

- -

invalid semver (0.x.x)

+ +

zero semver (0.x.x)

diff --git a/workspaces/vis-network/src/dataset.js b/workspaces/vis-network/src/dataset.js index 289c67a2..383c3fa2 100644 --- a/workspaces/vis-network/src/dataset.js +++ b/workspaces/vis-network/src/dataset.js @@ -18,6 +18,14 @@ export default class NodeSecureDataSet extends EventTarget { this.flagsToIgnore = new Set(flagsToIgnore); this.warningsToIgnore = new Set(warningsToIgnore); + this.reset(); + } + + get prettySize() { + return prettyBytes(this.size); + } + + reset() { this.warnings = []; this.packages = []; this.linker = new Map(); @@ -34,13 +42,14 @@ export default class NodeSecureDataSet extends EventTarget { this.indirectDependencies = 0; } - get prettySize() { - return prettyBytes(this.size); - } - - async init(initialPayload = null, initialFlags = {}) { + async init( + initialPayload = null, + initialFlags = {} + ) { console.log("[NodeSecureDataSet] Initialization started..."); - let FLAGS; let data; + let FLAGS; + let data; + this.reset(); if (initialPayload) { data = initialPayload; From 3faed9903703f742ce11f4af21b7dc2ca560bbbb Mon Sep 17 00:00:00 2001 From: fraxken Date: Thu, 30 Nov 2023 04:49:37 +0100 Subject: [PATCH 2/6] fix(flags): dont hide ul if there is no flags --- public/js/components/package/header.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/public/js/components/package/header.js b/public/js/components/package/header.js index d1c78b09..00c95c5c 100644 --- a/public/js/components/package/header.js +++ b/public/js/components/package/header.js @@ -112,9 +112,6 @@ export class PackageHeader { if (flagFragment) { flagsDomElement.appendChild(flagFragment); } - else { - flagsDomElement.style.display = "none"; - } return links; } From cc5742289f323ae09cbd6369b56c3c5d0b7139c9 Mon Sep 17 00:00:00 2001 From: fraxken Date: Thu, 30 Nov 2023 04:53:01 +0100 Subject: [PATCH 3/6] fix(warnings): hasNoInspection with || instead of && --- public/js/components/package/pannels/warnings.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js/components/package/pannels/warnings.js b/public/js/components/package/pannels/warnings.js index 993baa9a..4dcd289b 100644 --- a/public/js/components/package/pannels/warnings.js +++ b/public/js/components/package/pannels/warnings.js @@ -58,9 +58,10 @@ export class Warnings { const id = Math.random().toString(36).slice(2); const hasNoInspection = - warning.file.includes(".min") && - warning.kind === "short-identifiers" && - warning.kind === "obfuscated-code"; + warning.file.includes(".min") || + warning.kind === "short-identifiers" || + warning.kind === "obfuscated-code" || + warning.kind === "zero-semver"; const viewMoreElement = utils.createDOMElement("div", { className: "view-more", From 4e5dfd929d77f632be639207b27b8f15c725cf7e Mon Sep 17 00:00:00 2001 From: fraxken Date: Thu, 30 Nov 2023 04:56:34 +0100 Subject: [PATCH 4/6] fix(scripts): hide if there is none --- public/js/components/package/pannels/scripts.js | 14 ++++++++++++-- views/index.html | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/js/components/package/pannels/scripts.js b/public/js/components/package/pannels/scripts.js index bcf2d994..dc56772e 100644 --- a/public/js/components/package/pannels/scripts.js +++ b/public/js/components/package/pannels/scripts.js @@ -23,8 +23,15 @@ export class Scripts { generate(clone) { this.setupSignal(clone); - clone.querySelector(".package-scripts") - .appendChild(this.renderScripts()); + const fragment = this.renderScripts(); + const packageScriptsElement = clone.querySelector(".package-scripts"); + if (fragment === null) { + clone.getElementById("script-title").style.display = "none"; + packageScriptsElement.style.display = "none"; + } + else { + packageScriptsElement.appendChild(this.renderScripts()); + } this.renderDependencies(clone); this.showHideDependenciesInTree(clone); } @@ -48,6 +55,9 @@ export class Scripts { const createPElement = (className, text) => utils.createDOMElement("p", { className, text }); const scripts = Object.entries(this.package.dependencyVersion.scripts); + if (scripts.length === 0) { + return null; + } const hideItemsLength = 4; const hideItems = scripts.length > hideItemsLength; diff --git a/views/index.html b/views/index.html index 6ab00e6c..330aff26 100644 --- a/views/index.html +++ b/views/index.html @@ -383,7 +383,7 @@

General