Skip to content

Commit 537e998

Browse files
feat(interface): download report (#349)
1 parent d8e73d1 commit 537e998

File tree

21 files changed

+447
-11
lines changed

21 files changed

+447
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ nsecure-result.json
6464
vuln.json
6565
tmp/
6666
dist/
67+
reports

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- Link vulnerabilities from the multiple sources like GitHub Advisory, Sonatype or Snyk using [Vulnera](https://github.com/NodeSecure/vulnera).
3838
- Add flags (emojis) to each packages versions to identify well known patterns and potential security threats easily.
3939
- First-class support of open source security initiatives like [OpenSSF Scorecard](https://github.com/ossf/scorecard).
40+
- Generate security report (PDF).
4041

4142
## 🚧 Requirements
4243

i18n/english.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ const ui = {
129129
popup: {
130130
maintainer: {
131131
intree: "packages in the dependency tree"
132+
},
133+
report: {
134+
title: "Generate a report",
135+
form: {
136+
title: "Report title",
137+
includesAllDeps: "Include all dependencies",
138+
submit: "Generate"
139+
}
132140
}
133141
},
134142
home: {
@@ -138,7 +146,8 @@ const ui = {
138146
totalSize: "total size",
139147
directDeps: "direct deps",
140148
transitiveDeps: "transitive deps",
141-
downloadsLastWeek: "downloads last week"
149+
downloadsLastWeek: "downloads last week",
150+
generateReport: "Generate a report"
142151
},
143152
watch: "Packages in the dependency tree requiring greater attention",
144153
criticalWarnings: "Critical Warnings",

i18n/french.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ const ui = {
129129
popup: {
130130
maintainer: {
131131
intree: "packages dans l'abre de dépendances"
132+
},
133+
report: {
134+
title: "Générer un rapport",
135+
form: {
136+
title: "Titre du rapport",
137+
includesAllDeps: "Inclure toutes les dépendances",
138+
submit: "Générer"
139+
}
132140
}
133141
},
134142
home: {
@@ -138,7 +146,8 @@ const ui = {
138146
totalSize: "poids total",
139147
directDeps: "dépendances directes",
140148
transitiveDeps: "dépendances transitives",
141-
downloadsLastWeek: "téléchargements la semaine dernière"
149+
downloadsLastWeek: "téléchargements la semaine dernière",
150+
generateReport: "Générer un rapport"
142151
},
143152
watch: "Packages dans l'arbre de dépendance nécessitant une plus grande attention",
144153
criticalWarnings: "Avertissements critiques",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"@nodesecure/npm-registry-sdk": "^2.1.0",
8787
"@nodesecure/ossf-scorecard-sdk": "^3.1.0",
8888
"@nodesecure/rc": "^1.5.0",
89+
"@nodesecure/report": "^1.1.1",
8990
"@nodesecure/scanner": "^5.3.0",
9091
"@nodesecure/utils": "^1.2.0",
9192
"@nodesecure/vuln": "^1.7.0",
@@ -95,6 +96,7 @@
9596
"@topcli/prompts": "^1.9.0",
9697
"@topcli/spinner": "^2.1.2",
9798
"cacache": "^18.0.2",
99+
"co-body": "^6.1.0",
98100
"dotenv": "^16.4.4",
99101
"filenamify": "^6.0.0",
100102
"highlightjs-line-numbers.js": "^2.8.0",

public/components/locker/locker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export class Locker {
1111
this.renderUnlock();
1212

1313
document.addEventListener("keydown", (event) => {
14+
if (window.disableShortcuts) {
15+
return;
16+
}
17+
1418
const hotkeys = JSON.parse(localStorage.getItem("hotkeys"));
1519
switch (event.key.toUpperCase()) {
1620
case hotkeys.lock: {

public/components/navigation/navigation.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export class ViewNavigation {
2929
}
3030

3131
document.addEventListener("keydown", (event) => {
32+
if (window.disableShortcuts) {
33+
return;
34+
}
35+
3236
if (window.searchbar.background.classList.contains("show")) {
3337
return;
3438
}

public/components/popup/popup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export class Popup {
2525
return;
2626
}
2727

28+
window.disableShortcuts = true;
29+
2830
this.templateName = template.name;
2931
this.dom.popup.appendChild(template.HTMLElement);
3032
// TODO: apply additional css customization
@@ -59,6 +61,7 @@ export class Popup {
5961
return;
6062
}
6163

64+
window.disableShortcuts = false;
6265
this.dom.popup.innerHTML = "";
6366
this.templateName = null;
6467
this.#cleanupClickOutside();

public/components/views/home/home.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import url("./maintainers/maintainers.css");
2+
@import url("./report/report.css");
23

34
#home--view {
45
z-index: 10;
@@ -13,6 +14,12 @@
1314
display: flex;
1415
}
1516

17+
.home--header--aside {
18+
display: flex;
19+
flex-direction: column;
20+
align-items: end;
21+
}
22+
1623
.home--header--scorecard {
1724
display: none;
1825
flex-shrink: 0;
@@ -67,6 +74,18 @@
6774
background-color: rgb(39 144 252);
6875
}
6976

77+
.home--header--report {
78+
margin-top: 8px;
79+
border: none;
80+
padding: 10px;
81+
color: #fffde4;
82+
background: #1f9ad7;
83+
font-weight: bold;
84+
cursor: pointer;
85+
border-radius: 4px;
86+
text-shadow: 1px 1px 10px #0000007d;
87+
}
88+
7089
.home--header--title {
7190
display: flex;
7291
flex-direction: column;

public/components/views/home/home.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { fetchScorecardData, getScoreColor, getScorecardLink } from "../../../co
1010

1111
// Import Components
1212
import { Maintainers } from "./maintainers/maintainers.js";
13+
import { PopupReport } from "./report/report.js";
1314

1415
// CONSTANTS
1516
const kFlagsToWatch = new Set([
@@ -46,6 +47,7 @@ export class HomeView {
4647
this.generateExtensions();
4748
this.generateLicenses();
4849
this.generateMaintainers();
50+
this.handleReport();
4951
}
5052

5153
generateScorecard() {
@@ -301,4 +303,12 @@ export class HomeView {
301303
new Maintainers(this.secureDataSet, this.nsn)
302304
.render();
303305
}
306+
307+
handleReport() {
308+
document.querySelector(".home--header--report").addEventListener("click", async() => {
309+
window.popup.open(
310+
new PopupReport(this.secureDataSet.data.rootDependencyName).render()
311+
);
312+
});
313+
}
304314
}

0 commit comments

Comments
 (0)