Skip to content

Commit 4bd2faa

Browse files
authored
feat(cli): add re-highlight (#754)
1 parent b70d636 commit 4bd2faa

18 files changed

Lines changed: 285 additions & 87 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ For complete details on each command, refer to the following documents:
113113
- [`cache`](./docs/cli/cache.md)
114114
- [`extract integrity`](./docs/cli/extract-integrity.md)
115115
- [`stats`](./docs/cli/stats.md)
116+
- [re-highlight](./docs/cli/re-highlight.md)
116117

117118
Each link provides access to the full documentation for the command, including additional details, options, and usage examples.
118119

bin/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,18 @@ prog
140140
.command("stats")
141141
.describe(i18n.getTokenSync("cli.commands.stats.desc"))
142142
.option("-m, --min", i18n.getTokenSync("cli.commands.stats.option_min"), undefined)
143+
.option("-o, --output", i18n.getTokenSync("cli.commands.option_output"), "nsecure-result")
143144
.example("nsecure stats")
144145
.action(commands.stats.main);
145146

147+
prog
148+
.command("re-highlight")
149+
.option("-o, --output", i18n.getTokenSync("cli.commands.option_output"), "nsecure-result")
150+
.option("-c, --contacts", i18n.getTokenSync("cli.commands.option_contacts"), [])
151+
.option("-p, --packages", i18n.getTokenSync("cli.commands.option_packages"), [])
152+
.example("nsecure re-highlight -c sindre [email protected] -c matteo -p lodash@^4.0.0 -p express@^4.18.0")
153+
.action(commands.reHighlight.main);
154+
146155
prog.parse(process.argv);
147156

148157
function defaultScannerCommand(name, options = {}) {

docs/cli/re-highlight.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## 📝 Command `re-highlight`
2+
3+
The `re-highlight` command re-highlights the specified contacts and packages of the previous analysis stored in the JSON file at the root of this project.
4+
5+
## 📜 Syntax
6+
7+
8+
```bash
9+
$ nsecure re-highlight -c sindre [email protected] -c matteo -p lodash@^4.0.0 -p express@^4.18.0
10+
```
11+
12+
13+
## ⚙️ Available Options
14+
15+
| Name | Shortcut | Default Value | Description |
16+
| ------------------------- | -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17+
| `--output` | `-o` | `nsecure-result` | Specify the output file to read from. |
18+
| `--contacts` | `-c` | `[]` | List of contacts to highlight. |
19+
| `--packages` | `-p` | `[]` | List of packages to highlight. |

docs/cli/stats.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ $ nsecure stats
2323
| Name | Shortcut | Default Value | Description |
2424
| ----- | -------- | ------------- | -------------------------------------------------------- |
2525
| `--min` | `-m` | `undefined` | Filter API calls with execution time above ceiling (ms) |
26+
| `--output` | `-o` | `nsecure-result` | Specify the output file to read from.

i18n/arabic.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ const cli = {
103103
option_min: "تصفية استدعاءات API ذات وقت التنفيذ أعلى من الحد المحدد (بالمللي ثانية)",
104104
minNotANumber: "خطأ: يجب أن يكون --min رقماً.",
105105
statsCeiling: tS`عدد استدعاءات API فوق ${0}: ${1}`
106+
},
107+
reHighlight: {
108+
error: "يجب إجراء فحص قبل إعادة تمييز جهات الاتصال والحزم."
106109
}
107110
},
108111
startHttp: {

i18n/english.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ const cli = {
109109
option_min: "Filter API calls with execution time above the specified ceiling (in ms)",
110110
minNotANumber: "Error: --min must be a number.",
111111
statsCeiling: tS`API calls count above ${0}: ${1}`
112+
},
113+
reHighlight: {
114+
error: "A scan must be performed before re-highlighting contacts and packages."
112115
}
113116
},
114117
startHttp: {

i18n/french.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ const cli = {
109109
option_min: "Filtrer les appels API avec un temps d'exécution supérieur au plafond spécifié (en ms)",
110110
minNotANumber: "Erreur: --min doit être un nombre.",
111111
statsCeiling: tS`Nombre d'appels API au-dessus de ${0}: ${1}`
112+
},
113+
reHighlight: {
114+
error: "Une analyse doit être effectuée avant de remettre en évidence les contacts et les packages."
112115
}
113116
},
114117
startHttp: {

i18n/turkish.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ const cli = {
105105
option_min: "Belirtilen tavan değerinin (ms cinsinden) üzerinde yürütme süresine sahip API çağrılarını filtrele",
106106
minNotANumber: "Hata: --min bir sayı olmalıdır.",
107107
statsCeiling: tS`${0} üzerindeki API çağrıları sayısı: ${1}`
108+
},
109+
reHighlight: {
110+
error: "Kişileri ve paketleri yeniden vurgulamadan önce bir tarama yapılmalıdır."
108111
}
109112
},
110113
startHttp: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"@nodesecure/ossf-scorecard-sdk": "4.0.1",
111111
"@nodesecure/rc": "5.6.0",
112112
"@nodesecure/report": "4.2.2",
113-
"@nodesecure/scanner": "10.11.0",
113+
"@nodesecure/scanner": "10.12.0",
114114
"@nodesecure/server": "1.0.0",
115115
"@nodesecure/utils": "^2.2.0",
116116
"@nodesecure/vulnera": "3.1.0",

src/commands/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export * as report from "./report.js";
99
export * as cache from "./cache.js";
1010
export * as extractIntegrity from "./extract-integrity.js";
1111
export * as stats from "./stats.js";
12+
export * as reHighlight from "./re-highlight.js";

0 commit comments

Comments
 (0)