depsonar 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +313 -131
- package/bin/supervise.cjs +1 -1
- package/dashboard.html +606 -0
- package/dist/checker.js +7 -7
- package/dist/checker.js.map +1 -1
- package/dist/constants.d.ts +6 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +16 -2
- package/dist/constants.js.map +1 -1
- package/dist/dashboard.d.ts +23 -1
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +243 -94
- package/dist/dashboard.js.map +1 -1
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +75 -52
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +73 -57
- package/dist/schemas/index.js.map +1 -1
- package/dist/services/audit.d.ts +22 -2
- package/dist/services/audit.d.ts.map +1 -1
- package/dist/services/audit.js +264 -137
- package/dist/services/audit.js.map +1 -1
- package/dist/services/changelog.d.ts.map +1 -1
- package/dist/services/changelog.js +30 -3
- package/dist/services/changelog.js.map +1 -1
- package/dist/services/deprecated.d.ts.map +1 -1
- package/dist/services/deprecated.js +0 -14
- package/dist/services/deprecated.js.map +1 -1
- package/dist/services/envcheck.d.ts.map +1 -1
- package/dist/services/envcheck.js +9 -3
- package/dist/services/envcheck.js.map +1 -1
- package/dist/services/formatter.d.ts +2 -0
- package/dist/services/formatter.d.ts.map +1 -1
- package/dist/services/formatter.js +63 -28
- package/dist/services/formatter.js.map +1 -1
- package/dist/services/licenses.d.ts +2 -0
- package/dist/services/licenses.d.ts.map +1 -1
- package/dist/services/licenses.js +39 -34
- package/dist/services/licenses.js.map +1 -1
- package/dist/services/osv.d.ts +7 -0
- package/dist/services/osv.d.ts.map +1 -1
- package/dist/services/osv.js +109 -55
- package/dist/services/osv.js.map +1 -1
- package/dist/services/project.d.ts +58 -2
- package/dist/services/project.d.ts.map +1 -1
- package/dist/services/project.js +267 -113
- package/dist/services/project.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +157 -94
- package/dist/tools/index.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -5
package/dist/tools/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAyIzE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,QAwmC9C;AAID,wBAAgB,cAAc,IAAI,MAAM,CAOvC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { existsSync, writeFileSync, unlinkSync } from "fs";
|
|
2
2
|
import { join, resolve } from "path";
|
|
3
3
|
import { homedir, platform } from "os";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
4
5
|
import { CheckSchema, UpdateSchema, ScanSchema, UpdateAllSchema, HealthSchema, InstallSchema, ConfigSchema, AlertsSchema, SetupCronSchema, RuntimesSchema, ToolchainSchema, ActionsSchema, DockerSchema, EnvCheckSchema, AuditSchema, InfraSchema, CveSchema, DeprecatedSchema, SecretsSchema, LicensesSchema, LiveCveSchema, ChangelogSchema, MigrateSchema, DocsSchema, SearchPackageSchema, } from "../schemas/index.js";
|
|
5
6
|
import { LANGUAGE_MARKERS } from "../constants.js";
|
|
6
|
-
import { getProjectsDir, getProjectInfo, discoverProjects, getOutdated, isMajorUpdate, computeHealthReport,
|
|
7
|
+
import { getProjectsDir, getProjectInfo, discoverProjects, findProjectRoots, projectRootLabel, ROOT_SCAN_MAX_DEPTH, getOutdated, OutdatedCheckUnsupportedError, checkOutdated, isMajorUpdate, computeHealthReport, buildUpdatePlan, runSteps, getFrameworkVersion, run, readCache, getCacheStatus, loadConfig, saveConfig, } from "../services/project.js";
|
|
7
8
|
import { formatOutdated, formatScanSummary, formatHealthReport, formatUpdateResult, formatBatchResult, formatCacheAlerts, formatRuntimes, formatToolchain, formatActions, formatDocker, formatEnvCheck, formatAudit, formatInfraReport, formatCve, formatDeprecated, formatSecrets, formatLicenses, formatLiveCve, formatChangelog, formatMigration, } from "../services/formatter.js";
|
|
8
9
|
import { checkAllRuntimes, checkProjectVersionFiles } from "../services/runtimes.js";
|
|
9
10
|
import { checkAllTools } from "../services/toolchain.js";
|
|
@@ -11,11 +12,11 @@ import { scanWorkflows, scanAllProjectActions } from "../services/actions.js";
|
|
|
11
12
|
import { scanDockerfiles, scanAllProjectDocker } from "../services/docker.js";
|
|
12
13
|
import { checkProjectEnv, checkAllProjectEnvs } from "../services/envcheck.js";
|
|
13
14
|
import { auditProject, auditAllProjects } from "../services/audit.js";
|
|
14
|
-
import {
|
|
15
|
+
import { checkAllProjectCves, getCveDatabaseStats, getCveDatabase } from "../services/cve.js";
|
|
15
16
|
import { checkDeprecated, checkAllDeprecated } from "../services/deprecated.js";
|
|
16
17
|
import { scanProjectSecrets, scanAllProjectSecrets } from "../services/secrets.js";
|
|
17
18
|
import { checkProjectLicenses, checkAllProjectLicenses } from "../services/licenses.js";
|
|
18
|
-
import {
|
|
19
|
+
import { liveAuditAllProjects } from "../services/osv.js";
|
|
19
20
|
import { getProjectChangelog } from "../services/changelog.js";
|
|
20
21
|
import { detectMigration, detectAllMigrations } from "../services/migrate.js";
|
|
21
22
|
import { fetchLibraryDocs, searchPackage } from "../services/docs.js";
|
|
@@ -25,6 +26,13 @@ function text(content) {
|
|
|
25
26
|
function error(message) {
|
|
26
27
|
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
27
28
|
}
|
|
29
|
+
// A call that names nothing must not start a scan of every project: that takes minutes
|
|
30
|
+
// and answers a question nobody asked.
|
|
31
|
+
function assertScope(scope) {
|
|
32
|
+
if (scope.project || scope.directory || scope.all)
|
|
33
|
+
return;
|
|
34
|
+
throw new Error("No scope given. Pass `project` (name or absolute path) for one project, `directory` for a folder, or `all: true` to cover every project in the projects directory.");
|
|
35
|
+
}
|
|
28
36
|
function resolveProject(project) {
|
|
29
37
|
if (existsSync(project) && (existsSync(join(project, "package.json")) ||
|
|
30
38
|
existsSync(join(project, "Cargo.toml")) ||
|
|
@@ -82,7 +90,7 @@ Examples:
|
|
|
82
90
|
Groups results by ecosystem for Node projects. Flags major version updates.
|
|
83
91
|
|
|
84
92
|
Examples:
|
|
85
|
-
- "Check
|
|
93
|
+
- "Check my-app for outdated deps"
|
|
86
94
|
- "What needs updating in my Django project?"`,
|
|
87
95
|
inputSchema: CheckSchema,
|
|
88
96
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
@@ -92,19 +100,26 @@ Examples:
|
|
|
92
100
|
const info = getProjectInfo(projectPath);
|
|
93
101
|
if (!info)
|
|
94
102
|
return error(`Cannot read project at ${projectPath}`);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
// A repository can hold several projects (a Rust crate and its npm client, the apps of a
|
|
104
|
+
// monorepo): each folder with its own lockfile is checked, the root first.
|
|
105
|
+
const nested = findProjectRoots(projectPath, "lockfile").filter((root) => root.path !== info.path);
|
|
106
|
+
const targets = [info, ...nested];
|
|
107
|
+
const sections = targets.map((target) => {
|
|
108
|
+
const fwVer = getFrameworkVersion(target);
|
|
109
|
+
const langName = LANGUAGE_MARKERS[target.language]?.name || target.language;
|
|
110
|
+
const header = [
|
|
111
|
+
target === info ? `# ${target.name}` : `## ${projectRootLabel(projectPath, target)}`,
|
|
112
|
+
"",
|
|
113
|
+
`**Language**: ${langName}`,
|
|
114
|
+
`**Framework**: ${target.framework}${fwVer ? ` (${fwVer})` : ""}`,
|
|
115
|
+
`**Package Manager**: ${target.packageManager}`,
|
|
116
|
+
`**Path**: \`${target.path}\``,
|
|
117
|
+
"",
|
|
118
|
+
].join("\n");
|
|
119
|
+
const { outdated, error: checkError } = checkOutdated(target.path, target);
|
|
120
|
+
return header + (checkError ? `❌ Check failed: ${checkError}` : formatOutdated(outdated, target.language));
|
|
121
|
+
});
|
|
122
|
+
return text(sections.join("\n\n"));
|
|
108
123
|
}
|
|
109
124
|
catch (err) {
|
|
110
125
|
return error(err instanceof Error ? err.message : String(err));
|
|
@@ -121,8 +136,8 @@ Three safety levels:
|
|
|
121
136
|
- latest: Includes major breaking changes
|
|
122
137
|
|
|
123
138
|
Examples:
|
|
124
|
-
- "Update all deps in
|
|
125
|
-
- "Update svelte in
|
|
139
|
+
- "Update all deps in my-app"
|
|
140
|
+
- "Update svelte in my-app to latest"
|
|
126
141
|
- "Update my Python project dependencies"`,
|
|
127
142
|
inputSchema: UpdateSchema,
|
|
128
143
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
@@ -132,7 +147,22 @@ Examples:
|
|
|
132
147
|
const info = getProjectInfo(projectPath);
|
|
133
148
|
if (!info)
|
|
134
149
|
return error(`Cannot read project at ${projectPath}`);
|
|
135
|
-
|
|
150
|
+
// Before anything runs: a refused `packages` argument stops here.
|
|
151
|
+
const plan = buildUpdatePlan(info, packages, level);
|
|
152
|
+
let beforeOutdated;
|
|
153
|
+
try {
|
|
154
|
+
beforeOutdated = getOutdated(projectPath, info);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
// No outdated check for this ecosystem (Swift): the update still runs, without a count.
|
|
158
|
+
if (!(err instanceof OutdatedCheckUnsupportedError))
|
|
159
|
+
throw err;
|
|
160
|
+
if (dry_run) {
|
|
161
|
+
return text(`# Preview: ${info.name}\n\n${err.message}\n\nWould run: \`${plan.display}\``);
|
|
162
|
+
}
|
|
163
|
+
runSteps(plan.steps, projectPath);
|
|
164
|
+
return text(`# Updated: ${info.name}\n\n**Command**: \`${plan.display}\`\n\n${err.message} How many packages changed is not known.`);
|
|
165
|
+
}
|
|
136
166
|
const beforeCount = Object.keys(beforeOutdated).length;
|
|
137
167
|
if (beforeCount === 0) {
|
|
138
168
|
return text(`# ${info.name}\n\nAll dependencies are already up to date. ✅`);
|
|
@@ -140,11 +170,10 @@ Examples:
|
|
|
140
170
|
if (dry_run) {
|
|
141
171
|
return text(`# Preview: ${info.name}\n\n${formatOutdated(beforeOutdated, info.language)}`);
|
|
142
172
|
}
|
|
143
|
-
|
|
144
|
-
run(cmd, projectPath);
|
|
173
|
+
runSteps(plan.steps, projectPath);
|
|
145
174
|
const afterOutdated = getOutdated(projectPath, info);
|
|
146
175
|
const afterCount = Object.keys(afterOutdated).length;
|
|
147
|
-
return text(formatUpdateResult(info.name,
|
|
176
|
+
return text(formatUpdateResult(info.name, plan.display, beforeCount, afterCount, afterOutdated));
|
|
148
177
|
}
|
|
149
178
|
catch (err) {
|
|
150
179
|
return error(err instanceof Error ? err.message : String(err));
|
|
@@ -176,7 +205,7 @@ Examples:
|
|
|
176
205
|
projects = projects.filter((p) => p.language === language);
|
|
177
206
|
}
|
|
178
207
|
const results = projects.map((info) => {
|
|
179
|
-
const outdated =
|
|
208
|
+
const { outdated, error: checkError } = checkOutdated(info.path, info);
|
|
180
209
|
const hasMajor = Object.entries(outdated).some(([, pkg]) => isMajorUpdate(pkg.current, pkg.latest));
|
|
181
210
|
return {
|
|
182
211
|
name: info.name,
|
|
@@ -186,6 +215,7 @@ Examples:
|
|
|
186
215
|
fwVersion: getFrameworkVersion(info),
|
|
187
216
|
outdatedCount: Object.keys(outdated).length,
|
|
188
217
|
hasMajor,
|
|
218
|
+
error: checkError,
|
|
189
219
|
};
|
|
190
220
|
});
|
|
191
221
|
return text(formatScanSummary(results));
|
|
@@ -219,7 +249,11 @@ Examples:
|
|
|
219
249
|
projects = projects.filter((p) => p.language === language);
|
|
220
250
|
const results = [];
|
|
221
251
|
for (const info of projects) {
|
|
222
|
-
const beforeOutdated =
|
|
252
|
+
const { outdated: beforeOutdated, error: checkError } = checkOutdated(info.path, info);
|
|
253
|
+
if (checkError) {
|
|
254
|
+
results.push({ name: info.name, updated: 0, remaining: 0, error: checkError });
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
223
257
|
const beforeCount = Object.keys(beforeOutdated).length;
|
|
224
258
|
if (beforeCount === 0) {
|
|
225
259
|
results.push({ name: info.name, updated: 0, remaining: 0 });
|
|
@@ -230,8 +264,7 @@ Examples:
|
|
|
230
264
|
continue;
|
|
231
265
|
}
|
|
232
266
|
try {
|
|
233
|
-
|
|
234
|
-
run(cmd, info.path);
|
|
267
|
+
runSteps(buildUpdatePlan(info, undefined, level).steps, info.path);
|
|
235
268
|
const afterOutdated = getOutdated(info.path, info);
|
|
236
269
|
results.push({
|
|
237
270
|
name: info.name,
|
|
@@ -260,7 +293,7 @@ Examples:
|
|
|
260
293
|
description: `Score a project from 0-100. Checks outdated deps, security issues, lockfile.
|
|
261
294
|
|
|
262
295
|
Examples:
|
|
263
|
-
- "How healthy is
|
|
296
|
+
- "How healthy is my-app?"
|
|
264
297
|
- "Health report for my Rust project"`,
|
|
265
298
|
inputSchema: HealthSchema,
|
|
266
299
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
@@ -279,10 +312,10 @@ Examples:
|
|
|
279
312
|
// ─── depsonar_install ────────────────────────────────────────────────
|
|
280
313
|
server.registerTool("depsonar_install", {
|
|
281
314
|
title: "Install Dependencies",
|
|
282
|
-
description: `Fresh install. Use clean=true to
|
|
315
|
+
description: `Fresh install. Use clean=true to delete the project's own install folder first (node_modules, vendor, .dart_tool, build output). Go and Python have none: nothing is cleaned and the answer says so.
|
|
283
316
|
|
|
284
317
|
Examples:
|
|
285
|
-
- "Install deps for
|
|
318
|
+
- "Install deps for my-app"
|
|
286
319
|
- "Clean install my project"`,
|
|
287
320
|
inputSchema: InstallSchema,
|
|
288
321
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
@@ -293,15 +326,22 @@ Examples:
|
|
|
293
326
|
if (!info)
|
|
294
327
|
return error(`Cannot read project at ${projectPath}`);
|
|
295
328
|
const marker = LANGUAGE_MARKERS[info.language];
|
|
329
|
+
let cleanNote = "";
|
|
296
330
|
if (clean && marker?.cleanCmd) {
|
|
297
331
|
run(marker.cleanCmd, projectPath);
|
|
332
|
+
cleanNote = ` after \`${marker.cleanCmd}\``;
|
|
333
|
+
}
|
|
334
|
+
else if (clean) {
|
|
335
|
+
cleanNote = info.language === "go"
|
|
336
|
+
? "\n\n⚠️ Nothing was cleaned: Go keeps modules in a cache shared by every project on this machine, and depsonar does not empty it."
|
|
337
|
+
: `\n\n⚠️ Nothing was cleaned: ${marker?.name ?? info.language} projects have no install folder of their own to delete.`;
|
|
298
338
|
}
|
|
299
339
|
const installCmd = info.language === "node"
|
|
300
340
|
? `${info.packageManager} install`
|
|
301
341
|
: marker?.installCmd || "npm install";
|
|
302
342
|
const output = run(installCmd, projectPath);
|
|
303
343
|
const preview = output.length > 3000 ? output.slice(-3000) : output;
|
|
304
|
-
return text(`# ${info.name}\n\n\`${installCmd}
|
|
344
|
+
return text(`# ${info.name}\n\n\`${installCmd}\` done${cleanNote}${cleanNote.startsWith("\n") ? "" : "."}\n\n\`\`\`\n${preview}\n\`\`\``);
|
|
305
345
|
}
|
|
306
346
|
catch (err) {
|
|
307
347
|
return error(err instanceof Error ? err.message : String(err));
|
|
@@ -352,7 +392,7 @@ Examples:
|
|
|
352
392
|
const config = loadConfig();
|
|
353
393
|
const cacheStatus = getCacheStatus();
|
|
354
394
|
return text([
|
|
355
|
-
"#
|
|
395
|
+
"# Depsonar Configuration",
|
|
356
396
|
"",
|
|
357
397
|
`**Projects directory**: \`${config.projectsDir}\``,
|
|
358
398
|
`**Config file**: \`~/.depsonarrc.json\``,
|
|
@@ -384,25 +424,23 @@ CRITICAL: Run this after any CVE announcement (e.g. Svelte CVE-2026-22775, deval
|
|
|
384
424
|
|
|
385
425
|
Examples:
|
|
386
426
|
- "Audit all my projects for vulnerabilities"
|
|
387
|
-
- "Security scan
|
|
388
|
-
- "Any CVEs in my SvelteKit projects?"
|
|
427
|
+
- "Security scan my-app"
|
|
428
|
+
- "Any CVEs in my SvelteKit projects?"
|
|
429
|
+
|
|
430
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
389
431
|
inputSchema: AuditSchema,
|
|
390
432
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
391
|
-
}, async ({ project, directory }) => {
|
|
433
|
+
}, async ({ project, directory, all }) => {
|
|
392
434
|
try {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const result = auditProject(projectPath, info.name, info.language);
|
|
399
|
-
return text(formatAudit([result]));
|
|
435
|
+
assertScope({ project, directory, all });
|
|
436
|
+
const baseDir = project ? resolveProject(project) : directory || getProjectsDir();
|
|
437
|
+
const roots = findProjectRoots(baseDir, "lockfile");
|
|
438
|
+
if (roots.length === 0) {
|
|
439
|
+
return text(`No lockfile found in \`${baseDir}\` (searched ${ROOT_SCAN_MAX_DEPTH} levels deep).`);
|
|
400
440
|
}
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
const results = auditAllProjects(projects.map(p => ({ name: p.name, path: p.path, language: p.language })));
|
|
405
|
-
return text(formatAudit(results));
|
|
441
|
+
const results = roots.map(r => auditProject(r.path, projectRootLabel(baseDir, r), r.language));
|
|
442
|
+
// With a single project, show every root, clean ones included.
|
|
443
|
+
return text(formatAudit(project ? results : results.filter(r => r.totalVulnerabilities > 0 || r.error)));
|
|
406
444
|
}
|
|
407
445
|
catch (err) {
|
|
408
446
|
return error(err instanceof Error ? err.message : String(err));
|
|
@@ -468,11 +506,14 @@ Examples:
|
|
|
468
506
|
|
|
469
507
|
Examples:
|
|
470
508
|
- "Check my Docker images"
|
|
471
|
-
- "Any EOL images in my projects?"
|
|
509
|
+
- "Any EOL images in my projects?"
|
|
510
|
+
|
|
511
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
472
512
|
inputSchema: DockerSchema,
|
|
473
513
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
474
|
-
}, async ({ project, directory }) => {
|
|
514
|
+
}, async ({ project, directory, all }) => {
|
|
475
515
|
try {
|
|
516
|
+
assertScope({ project, directory, all });
|
|
476
517
|
if (project) {
|
|
477
518
|
const projectPath = resolveProject(project);
|
|
478
519
|
const info = getProjectInfo(projectPath);
|
|
@@ -496,11 +537,14 @@ Examples:
|
|
|
496
537
|
|
|
497
538
|
Examples:
|
|
498
539
|
- "Check my GitHub Actions versions"
|
|
499
|
-
- "Any deprecated actions in my workflows?"
|
|
540
|
+
- "Any deprecated actions in my workflows?"
|
|
541
|
+
|
|
542
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
500
543
|
inputSchema: ActionsSchema,
|
|
501
544
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
502
|
-
}, async ({ project, directory }) => {
|
|
545
|
+
}, async ({ project, directory, all }) => {
|
|
503
546
|
try {
|
|
547
|
+
assertScope({ project, directory, all });
|
|
504
548
|
if (project) {
|
|
505
549
|
const projectPath = resolveProject(project);
|
|
506
550
|
const info = getProjectInfo(projectPath);
|
|
@@ -524,12 +568,15 @@ Examples:
|
|
|
524
568
|
|
|
525
569
|
Examples:
|
|
526
570
|
- "Check my project environments"
|
|
527
|
-
- "Any env issues in
|
|
528
|
-
- "Validate all project configs"
|
|
571
|
+
- "Any env issues in my-app?"
|
|
572
|
+
- "Validate all project configs"
|
|
573
|
+
|
|
574
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
529
575
|
inputSchema: EnvCheckSchema,
|
|
530
576
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
531
|
-
}, async ({ project, directory }) => {
|
|
577
|
+
}, async ({ project, directory, all }) => {
|
|
532
578
|
try {
|
|
579
|
+
assertScope({ project, directory, all });
|
|
533
580
|
if (project) {
|
|
534
581
|
const projectPath = resolveProject(project);
|
|
535
582
|
const info = getProjectInfo(projectPath);
|
|
@@ -598,12 +645,12 @@ Examples:
|
|
|
598
645
|
let depsSection;
|
|
599
646
|
if (!skip_deps) {
|
|
600
647
|
const scanResults = projects.map(info => {
|
|
601
|
-
const outdated =
|
|
648
|
+
const { outdated, error: checkError } = checkOutdated(info.path, info);
|
|
602
649
|
const hasMajor = Object.entries(outdated).some(([, pkg]) => isMajorUpdate(pkg.current, pkg.latest));
|
|
603
650
|
return {
|
|
604
651
|
name: info.name, language: info.language, framework: info.framework,
|
|
605
652
|
pm: info.packageManager, fwVersion: getFrameworkVersion(info),
|
|
606
|
-
outdatedCount: Object.keys(outdated).length, hasMajor,
|
|
653
|
+
outdatedCount: Object.keys(outdated).length, hasMajor, error: checkError,
|
|
607
654
|
};
|
|
608
655
|
});
|
|
609
656
|
depsSection = formatScanSummary(scanResults);
|
|
@@ -636,10 +683,12 @@ CRITICAL after any CVE announcement. Run immediately when new CVEs are published
|
|
|
636
683
|
Examples:
|
|
637
684
|
- "Check my projects for known CVEs"
|
|
638
685
|
- "Any Svelte CVEs affecting my code?"
|
|
639
|
-
- "Show CVE database"
|
|
686
|
+
- "Show CVE database"
|
|
687
|
+
|
|
688
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
640
689
|
inputSchema: CveSchema,
|
|
641
690
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
642
|
-
}, async ({ project, directory, show_db }) => {
|
|
691
|
+
}, async ({ project, directory, all, show_db }) => {
|
|
643
692
|
try {
|
|
644
693
|
const dbStats = getCveDatabaseStats();
|
|
645
694
|
if (show_db) {
|
|
@@ -652,18 +701,13 @@ Examples:
|
|
|
652
701
|
}
|
|
653
702
|
return text(lines.join("\n"));
|
|
654
703
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const result = checkProjectCves(projectPath, info.name);
|
|
661
|
-
return text(formatCve(result.affected.length > 0 ? [result] : [], dbStats));
|
|
704
|
+
assertScope({ project, directory, all });
|
|
705
|
+
const baseDir = project ? resolveProject(project) : directory || getProjectsDir();
|
|
706
|
+
const roots = findProjectRoots(baseDir, "manifest");
|
|
707
|
+
if (roots.length === 0) {
|
|
708
|
+
return text(`No project found in \`${baseDir}\` (searched ${ROOT_SCAN_MAX_DEPTH} levels deep).`);
|
|
662
709
|
}
|
|
663
|
-
const
|
|
664
|
-
if (projects.length === 0)
|
|
665
|
-
return text("No projects found.");
|
|
666
|
-
const results = checkAllProjectCves(projects.map(p => ({ name: p.name, path: p.path })));
|
|
710
|
+
const results = checkAllProjectCves(roots.map(r => ({ name: projectRootLabel(baseDir, r), path: r.path })));
|
|
667
711
|
return text(formatCve(results, dbStats));
|
|
668
712
|
}
|
|
669
713
|
catch (err) {
|
|
@@ -677,12 +721,15 @@ Examples:
|
|
|
677
721
|
|
|
678
722
|
Examples:
|
|
679
723
|
- "Any deprecated packages in my projects?"
|
|
680
|
-
- "Check
|
|
681
|
-
- "Find packages that should be replaced"
|
|
724
|
+
- "Check my-app for deprecated deps"
|
|
725
|
+
- "Find packages that should be replaced"
|
|
726
|
+
|
|
727
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
682
728
|
inputSchema: DeprecatedSchema,
|
|
683
729
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
684
|
-
}, async ({ project, directory }) => {
|
|
730
|
+
}, async ({ project, directory, all }) => {
|
|
685
731
|
try {
|
|
732
|
+
assertScope({ project, directory, all });
|
|
686
733
|
if (project) {
|
|
687
734
|
const projectPath = resolveProject(project);
|
|
688
735
|
const info = getProjectInfo(projectPath);
|
|
@@ -710,12 +757,15 @@ Also checks that .env files are properly gitignored.
|
|
|
710
757
|
|
|
711
758
|
Examples:
|
|
712
759
|
- "Scan my projects for exposed secrets"
|
|
713
|
-
- "Any leaked API keys in
|
|
714
|
-
- "Secret scan all projects"
|
|
760
|
+
- "Any leaked API keys in my-app?"
|
|
761
|
+
- "Secret scan all projects"
|
|
762
|
+
|
|
763
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
715
764
|
inputSchema: SecretsSchema,
|
|
716
765
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
717
|
-
}, async ({ project, directory }) => {
|
|
766
|
+
}, async ({ project, directory, all }) => {
|
|
718
767
|
try {
|
|
768
|
+
assertScope({ project, directory, all });
|
|
719
769
|
if (project) {
|
|
720
770
|
const projectPath = resolveProject(project);
|
|
721
771
|
const info = getProjectInfo(projectPath);
|
|
@@ -742,20 +792,23 @@ Examples:
|
|
|
742
792
|
Important for SaaS products to avoid legal issues.
|
|
743
793
|
|
|
744
794
|
Examples:
|
|
745
|
-
- "Check license compliance for
|
|
795
|
+
- "Check license compliance for my-app"
|
|
746
796
|
- "Any GPL dependencies in my projects?"
|
|
747
|
-
- "License audit all projects"
|
|
797
|
+
- "License audit all projects"
|
|
798
|
+
|
|
799
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
748
800
|
inputSchema: LicensesSchema,
|
|
749
801
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
750
|
-
}, async ({ project, directory }) => {
|
|
802
|
+
}, async ({ project, directory, all }) => {
|
|
751
803
|
try {
|
|
804
|
+
assertScope({ project, directory, all });
|
|
752
805
|
if (project) {
|
|
753
806
|
const projectPath = resolveProject(project);
|
|
754
807
|
const info = getProjectInfo(projectPath);
|
|
755
808
|
if (!info)
|
|
756
809
|
return error(`Cannot read project at ${projectPath}`);
|
|
757
810
|
const result = checkProjectLicenses(projectPath, info.name);
|
|
758
|
-
return text(formatLicenses(
|
|
811
|
+
return text(formatLicenses([result]));
|
|
759
812
|
}
|
|
760
813
|
const projects = discoverProjects(directory);
|
|
761
814
|
if (projects.length === 0)
|
|
@@ -776,19 +829,27 @@ Unlike depsonar_audit (which uses local tools like npm audit), this queries the
|
|
|
776
829
|
|
|
777
830
|
Examples:
|
|
778
831
|
- "Live CVE scan all my projects"
|
|
779
|
-
- "Check
|
|
780
|
-
- "Real-time security scan"
|
|
832
|
+
- "Check my-app for vulnerabilities with osv.dev"
|
|
833
|
+
- "Real-time security scan"
|
|
834
|
+
|
|
835
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
781
836
|
inputSchema: LiveCveSchema,
|
|
782
837
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
783
|
-
}, async ({ project, directory }) => {
|
|
838
|
+
}, async ({ project, directory, all }) => {
|
|
784
839
|
try {
|
|
840
|
+
assertScope({ project, directory, all });
|
|
785
841
|
if (project) {
|
|
786
842
|
const projectPath = resolveProject(project);
|
|
787
843
|
const info = getProjectInfo(projectPath);
|
|
788
844
|
if (!info)
|
|
789
845
|
return error(`Cannot read project at ${projectPath}`);
|
|
790
|
-
|
|
791
|
-
|
|
846
|
+
// Every folder with its own lockfile (an npm client next to a Rust crate, monorepo apps).
|
|
847
|
+
const nested = findProjectRoots(projectPath, "lockfile").filter((root) => root.path !== info.path);
|
|
848
|
+
const results = await liveAuditAllProjects([
|
|
849
|
+
{ name: info.name, path: info.path, language: info.language },
|
|
850
|
+
...nested.map((root) => ({ name: projectRootLabel(projectPath, root), path: root.path, language: root.language })),
|
|
851
|
+
]);
|
|
852
|
+
return text(formatLiveCve(results));
|
|
792
853
|
}
|
|
793
854
|
const projects = discoverProjects(directory);
|
|
794
855
|
if (projects.length === 0)
|
|
@@ -808,7 +869,7 @@ Examples:
|
|
|
808
869
|
Run this BEFORE depsonar_update to understand what will change.
|
|
809
870
|
|
|
810
871
|
Examples:
|
|
811
|
-
- "Show changelog for
|
|
872
|
+
- "Show changelog for my-app before updating"
|
|
812
873
|
- "What breaking changes are pending in my project?"
|
|
813
874
|
- "Check what changed in latest versions"`,
|
|
814
875
|
inputSchema: ChangelogSchema,
|
|
@@ -836,11 +897,14 @@ Finds exact file locations of code that needs to change, with migration instruct
|
|
|
836
897
|
Examples:
|
|
837
898
|
- "Check if my projects need Svelte 5 migration"
|
|
838
899
|
- "Migration scan for all projects"
|
|
839
|
-
- "What Svelte 4 patterns are still in my code?"
|
|
900
|
+
- "What Svelte 4 patterns are still in my code?"
|
|
901
|
+
|
|
902
|
+
Scope (one is required): "project" for one project, "directory" for a folder, "all": true for every project.`,
|
|
840
903
|
inputSchema: MigrateSchema,
|
|
841
904
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
842
|
-
}, async ({ project, directory }) => {
|
|
905
|
+
}, async ({ project, directory, all }) => {
|
|
843
906
|
try {
|
|
907
|
+
assertScope({ project, directory, all });
|
|
844
908
|
if (project) {
|
|
845
909
|
const projectPath = resolveProject(project);
|
|
846
910
|
const info = getProjectInfo(projectPath);
|
|
@@ -955,10 +1019,9 @@ Examples:
|
|
|
955
1019
|
});
|
|
956
1020
|
}
|
|
957
1021
|
// ─── Scheduler Setup ───────────────────────────────────────────────────
|
|
958
|
-
function getCheckerPath() {
|
|
959
|
-
//
|
|
960
|
-
const
|
|
961
|
-
const checkerPath = join(thisDir, "checker.js");
|
|
1022
|
+
export function getCheckerPath() {
|
|
1023
|
+
// This file is dist/tools/index.js, the checker is dist/checker.js
|
|
1024
|
+
const checkerPath = fileURLToPath(new URL("../checker.js", import.meta.url));
|
|
962
1025
|
if (existsSync(checkerPath))
|
|
963
1026
|
return checkerPath;
|
|
964
1027
|
// Fallback: try npx
|
|
@@ -969,7 +1032,7 @@ function setupLaunchd(intervalHours, uninstall) {
|
|
|
969
1032
|
const plistPath = join(homedir(), "Library", "LaunchAgents", `${plistName}.plist`);
|
|
970
1033
|
if (uninstall) {
|
|
971
1034
|
try {
|
|
972
|
-
|
|
1035
|
+
runSteps([{ file: "launchctl", args: ["unload", plistPath] }], homedir());
|
|
973
1036
|
}
|
|
974
1037
|
catch { /* might not be loaded */ }
|
|
975
1038
|
if (existsSync(plistPath))
|
|
@@ -1007,10 +1070,10 @@ ${programArgs}
|
|
|
1007
1070
|
</plist>`;
|
|
1008
1071
|
writeFileSync(plistPath, plist, "utf-8");
|
|
1009
1072
|
try {
|
|
1010
|
-
|
|
1073
|
+
runSteps([{ file: "launchctl", args: ["unload", plistPath] }], homedir());
|
|
1011
1074
|
}
|
|
1012
1075
|
catch { /* might not exist yet */ }
|
|
1013
|
-
|
|
1076
|
+
runSteps([{ file: "launchctl", args: ["load", plistPath] }], homedir());
|
|
1014
1077
|
return [
|
|
1015
1078
|
"# Background Checker Installed ✅",
|
|
1016
1079
|
"",
|