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/checker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.js","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,aAAa,EAEb,UAAU,EAEV,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"checker.js","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,aAAa,EAEb,UAAU,EAEV,UAAU,EACV,eAAe,EACf,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAG/B,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IAEpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,cAAc,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,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|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare const SERVER_NAME = "depsonar";
|
|
2
|
-
export declare const SERVER_VERSION = "4.0
|
|
2
|
+
export declare const SERVER_VERSION = "4.2.0";
|
|
3
|
+
/**
|
|
4
|
+
* Sent to every MCP client in the initialize result, so any agent knows how to use the server
|
|
5
|
+
* without extra setup.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
3
8
|
export declare const CHARACTER_LIMIT = 25000;
|
|
4
9
|
export declare const COMMAND_TIMEOUT = 120000;
|
|
5
10
|
export declare const ECOSYSTEM_GROUPS: Record<string, RegExp>;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,eAAO,MAAM,eAAe,SAAU,CAAC;AAIvC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWnD,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAYxD,CAAC;AAIF,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;CACjG;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAOpB,CAAC;AAEb,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,eAAO,MAAM,eAAe,SAAU,CAAC;AAIvC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWnD,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAYxD,CAAC;AAIF,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;CACjG;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAsG3D,CAAC;AAIF,eAAO,MAAM,cAAc,yBAAyB,CAAC;AACrD,eAAO,MAAM,gBAAgB,QAAqB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export const SERVER_NAME = "depsonar";
|
|
2
|
-
export const SERVER_VERSION = "4.0
|
|
2
|
+
export const SERVER_VERSION = "4.2.0";
|
|
3
|
+
/**
|
|
4
|
+
* Sent to every MCP client in the initialize result, so any agent knows how to use the server
|
|
5
|
+
* without extra setup.
|
|
6
|
+
*/
|
|
7
|
+
export const SERVER_INSTRUCTIONS = [
|
|
8
|
+
"depsonar audits and updates the dependencies of local code projects (Node, Python, Rust, Go, PHP, Ruby, Dart, Swift, Kotlin): outdated packages, CVEs, deprecated packages, secrets, licenses, runtimes, Docker images, GitHub Actions. It does not build, deploy or publish anything.",
|
|
9
|
+
"Start with depsonar_alerts (instant, reads the last background scan), then depsonar_check on the project, then depsonar_audit or depsonar_live_cve, depsonar_secrets and depsonar_licenses. Before a major update, read depsonar_changelog and depsonar_migrate.",
|
|
10
|
+
"Most scan tools require a scope: ask the user which project (name or absolute path) unless the current folder makes it obvious; use all: true only when they ask for every project. depsonar_scan lists the projects.",
|
|
11
|
+
"depsonar_update writes to the project as soon as it is called (dry_run defaults to false): call it with dry_run: true first, show the preview, and apply only after the user agrees. depsonar_update_all defaults to a preview: never set dry_run: false without the user's go-ahead. Ask before depsonar_install with clean: true (it deletes node_modules or vendor) and before changing depsonar_setup_checker or depsonar_config.",
|
|
12
|
+
"depsonar_secrets returns masked previews: never try to print a full secret value, report the file and line instead.",
|
|
13
|
+
"A failed call returns isError with a message starting with \"Error:\": quote it, fix the argument it names (scope, project name), and do not retry the same call unchanged.",
|
|
14
|
+
].join("\n");
|
|
3
15
|
export const CHARACTER_LIMIT = 25_000;
|
|
4
16
|
export const COMMAND_TIMEOUT = 120_000;
|
|
5
17
|
// ─── Ecosystem Grouping (for display) ──────────────────────────────────
|
|
@@ -70,7 +82,9 @@ export const LANGUAGE_MARKERS = {
|
|
|
70
82
|
updateCmd: "go get -u ./...",
|
|
71
83
|
updateLatestCmd: "go get -u ./...",
|
|
72
84
|
installCmd: "go mod download",
|
|
73
|
-
|
|
85
|
+
// Go keeps modules in one cache shared by every project of the machine (`go clean -modcache`
|
|
86
|
+
// empties all of it): there is nothing of the project's own to delete.
|
|
87
|
+
cleanCmd: "",
|
|
74
88
|
auditCmd: "govulncheck -json ./...",
|
|
75
89
|
parseOutdated: "go",
|
|
76
90
|
},
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,0EAA0E;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,MAAM,EAAE,sDAAsD;IAC9D,KAAK,EAAE,+CAA+C;IACtD,GAAG,EAAE,4CAA4C;IACjD,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,oDAAoD;IAC9D,IAAI,EAAE,oCAAoC;IAC1C,UAAU,EAAE,0CAA0C;IACtD,MAAM,EAAE,mDAAmD;IAC3D,MAAM,EAAE,qBAAqB;IAC7B,OAAO,EAAE,uDAAuD;CACjE,CAAC;AAEF,0EAA0E;AAE1E,MAAM,CAAC,MAAM,mBAAmB,GAA6B;IAC3D,SAAS,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IACnD,SAAS,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC;IAClE,IAAI,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC1C,KAAK,EAAE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;IAC9C,KAAK,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC7C,UAAU,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;IAC9C,MAAM,EAAE,CAAC,WAAW,CAAC;IACrB,KAAK,EAAE,CAAC,SAAS,CAAC;IAClB,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB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aAAa;QACnB,WAAW,EAAE,wEAAwE;QACrF,SAAS,EAAE,6BAA6B;QACxC,eAAe,EAAE,gDAAgD;QACjE,UAAU,EAAE,iBAAiB;QAC7B,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,QAAQ;KACxB;CACF,CAAC;AAEF,0EAA0E;AAE1E,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,UAAU"}
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* depsonar dashboard v3: Full dependency management interface
|
|
4
|
+
* http://127.0.0.1:24681
|
|
5
|
+
*
|
|
6
|
+
* The API can run commands in the user's projects, so every request is checked: loopback
|
|
7
|
+
* listener, exact Host header (DNS rebinding), same-origin Origin, and a random token that
|
|
8
|
+
* only the address printed at startup carries.
|
|
9
|
+
*/
|
|
10
|
+
import { Server } from "node:http";
|
|
11
|
+
export declare const TOKEN_HEADER = "x-depsonar-token";
|
|
12
|
+
/** The HTTP server, not yet listening, and the token its API requires (new at every launch). */
|
|
13
|
+
export declare function createDashboardServer(): {
|
|
14
|
+
server: Server;
|
|
15
|
+
token: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Listens on the loopback address only. `schedule: false` leaves out the background scans
|
|
19
|
+
* and auto-updates (tests).
|
|
20
|
+
*/
|
|
21
|
+
export declare function startDashboard(port?: number, schedule?: boolean): {
|
|
22
|
+
server: Server;
|
|
23
|
+
token: string;
|
|
24
|
+
};
|
|
3
25
|
//# sourceMappingURL=dashboard.d.ts.map
|
package/dist/dashboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AACH,OAAO,EAAiC,MAAM,EAAkB,MAAM,WAAW,CAAC;AA4BlF,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAoS/C,gGAAgG;AAChG,wBAAgB,qBAAqB,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAWzE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAO,EAAE,QAAQ,UAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAuD9F"}
|
package/dist/dashboard.js
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* depsonar dashboard v3: Full dependency management interface
|
|
4
4
|
* http://127.0.0.1:24681
|
|
5
|
+
*
|
|
6
|
+
* The API can run commands in the user's projects, so every request is checked: loopback
|
|
7
|
+
* listener, exact Host header (DNS rebinding), same-origin Origin, and a random token that
|
|
8
|
+
* only the address printed at startup carries.
|
|
5
9
|
*/
|
|
6
10
|
import { createServer } from "node:http";
|
|
7
|
-
import {
|
|
11
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
12
|
+
import { readFileSync, existsSync, realpathSync } from "node:fs";
|
|
8
13
|
import { homedir } from "node:os";
|
|
9
14
|
import { join, dirname } from "node:path";
|
|
10
15
|
import { fileURLToPath } from "node:url";
|
|
11
|
-
import { discoverProjects, getOutdated, isMajorUpdate, groupByEcosystem,
|
|
16
|
+
import { discoverProjects, getOutdated, isMajorUpdate, groupByEcosystem, buildUpdatePlan, computeHealthReport, runSteps, loadConfig, saveConfig, writeCache, } from "./services/project.js";
|
|
12
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
18
|
const PORT = 24681;
|
|
14
19
|
const CACHE_PATH = join(homedir(), ".depsonar-cache.json");
|
|
@@ -25,32 +30,106 @@ function readCacheFile() {
|
|
|
25
30
|
return null;
|
|
26
31
|
}
|
|
27
32
|
}
|
|
33
|
+
export const TOKEN_HEADER = "x-depsonar-token";
|
|
34
|
+
const MAX_BODY_BYTES = 64 * 1024;
|
|
35
|
+
const UPDATE_LEVELS = ["patch", "minor", "latest"];
|
|
36
|
+
/** A request refused with a status and a message, instead of a crash or a silent default. */
|
|
37
|
+
class HttpError extends Error {
|
|
38
|
+
status;
|
|
39
|
+
constructor(status, message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.status = status;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// No Access-Control-Allow-* header anywhere: another origin can neither read a response nor pass a preflight.
|
|
28
45
|
function jsonRes(res, data, status = 200) {
|
|
29
46
|
res.writeHead(status, {
|
|
30
47
|
"Content-Type": "application/json",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
48
|
+
"Cache-Control": "no-store",
|
|
49
|
+
"X-Content-Type-Options": "nosniff",
|
|
50
|
+
// An oversized body is left unread: the connection must not be reused.
|
|
51
|
+
...(status === 413 ? { Connection: "close" } : {}),
|
|
34
52
|
});
|
|
35
53
|
res.end(JSON.stringify(data));
|
|
36
54
|
}
|
|
37
55
|
function readBody(req) {
|
|
38
|
-
return new Promise((resolve) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
req.on("
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const chunks = [];
|
|
58
|
+
let size = 0;
|
|
59
|
+
req.on("data", (c) => {
|
|
60
|
+
size += c.length;
|
|
61
|
+
if (size > MAX_BODY_BYTES) {
|
|
62
|
+
// Stop reading without cutting the socket, so the 413 answer reaches the client.
|
|
63
|
+
req.removeAllListeners("data");
|
|
64
|
+
req.pause();
|
|
65
|
+
reject(new HttpError(413, `Request body larger than ${MAX_BODY_BYTES} bytes.`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
chunks.push(c);
|
|
69
|
+
});
|
|
70
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
|
|
71
|
+
req.on("error", reject);
|
|
42
72
|
});
|
|
43
73
|
}
|
|
74
|
+
async function readJsonBody(req) {
|
|
75
|
+
const raw = await readBody(req);
|
|
76
|
+
let parsed;
|
|
77
|
+
try {
|
|
78
|
+
parsed = JSON.parse(raw);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new HttpError(400, "Request body is not valid JSON.");
|
|
82
|
+
}
|
|
83
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
84
|
+
throw new HttpError(400, "Request body must be a JSON object.");
|
|
85
|
+
}
|
|
86
|
+
return parsed;
|
|
87
|
+
}
|
|
88
|
+
function header(req, name) {
|
|
89
|
+
const value = req.headers[name];
|
|
90
|
+
return typeof value === "string" ? value : "";
|
|
91
|
+
}
|
|
92
|
+
function sameToken(given, expected) {
|
|
93
|
+
// Hashed first so both buffers have the same length, whatever was sent.
|
|
94
|
+
const digest = (value) => createHash("sha256").update(value).digest();
|
|
95
|
+
return timingSafeEqual(digest(given), digest(expected));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Refuses, before any route runs, a request that does not come from the dashboard page itself.
|
|
99
|
+
* `port` is the port the server really listens on.
|
|
100
|
+
*/
|
|
101
|
+
function assertTrustedRequest(req, url, port, token) {
|
|
102
|
+
// The browser sends the name it was given: a rebinding site arrives as "evil.example:24681".
|
|
103
|
+
const host = header(req, "host");
|
|
104
|
+
if (host !== `127.0.0.1:${port}` && host !== `localhost:${port}`) {
|
|
105
|
+
throw new HttpError(403, "Refused: this dashboard only answers to 127.0.0.1 or localhost on its own port.");
|
|
106
|
+
}
|
|
107
|
+
const origin = header(req, "origin");
|
|
108
|
+
if (origin && origin !== `http://${host}`) {
|
|
109
|
+
throw new HttpError(403, "Refused: request sent by another origin.");
|
|
110
|
+
}
|
|
111
|
+
if (req.method !== "GET" && req.method !== "POST") {
|
|
112
|
+
throw new HttpError(405, "Only GET and POST are accepted.");
|
|
113
|
+
}
|
|
114
|
+
if (!url.startsWith("/api/"))
|
|
115
|
+
return;
|
|
116
|
+
if (!sameToken(header(req, TOKEN_HEADER), token)) {
|
|
117
|
+
throw new HttpError(401, "Missing or wrong access token. Open the address printed by `depsonar --dashboard`: it carries the token.");
|
|
118
|
+
}
|
|
119
|
+
if (req.method === "POST" && !/^application\/json\s*(;|$)/i.test(header(req, "content-type"))) {
|
|
120
|
+
throw new HttpError(415, "POST requests must be sent with Content-Type: application/json.");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
44
123
|
let htmlCache = null;
|
|
45
124
|
function getHtml() {
|
|
46
125
|
if (htmlCache)
|
|
47
126
|
return htmlCache;
|
|
48
127
|
const htmlPath = join(__dirname, "..", "dashboard.html");
|
|
49
|
-
if (existsSync(htmlPath)) {
|
|
50
|
-
|
|
51
|
-
return htmlCache;
|
|
128
|
+
if (!existsSync(htmlPath)) {
|
|
129
|
+
throw new HttpError(500, `Dashboard page not found at ${htmlPath}: the installation is incomplete.`);
|
|
52
130
|
}
|
|
53
|
-
|
|
131
|
+
htmlCache = readFileSync(htmlPath, "utf-8");
|
|
132
|
+
return htmlCache;
|
|
54
133
|
}
|
|
55
134
|
// ─── Inline scan with progress tracking ────────────────────────────────
|
|
56
135
|
// getOutdated uses execSync, so we yield the event loop between each project
|
|
@@ -81,10 +160,12 @@ async function runScanWithProgress() {
|
|
|
81
160
|
entries.push({
|
|
82
161
|
project: info.name, path: info.path, language: info.language,
|
|
83
162
|
framework: info.framework, outdatedCount, majorCount,
|
|
84
|
-
securityIssues:
|
|
163
|
+
securityIssues: null, score, checkedAt: new Date().toISOString(),
|
|
85
164
|
});
|
|
86
165
|
}
|
|
87
|
-
catch {
|
|
166
|
+
catch (err) {
|
|
167
|
+
console.error(`[dashboard] ${info.name}: check failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`);
|
|
168
|
+
}
|
|
88
169
|
scanProgress.current = i + 1;
|
|
89
170
|
scanProgress.percent = Math.round(((i + 1) / projects.length) * 100);
|
|
90
171
|
}
|
|
@@ -92,29 +173,30 @@ async function runScanWithProgress() {
|
|
|
92
173
|
scanProgress = { current: projects.length, total: projects.length, currentProject: "Done", percent: 100 };
|
|
93
174
|
}
|
|
94
175
|
// ─── Request Handler ───────────────────────────────────────────────────
|
|
95
|
-
async function handleRequest(req, res) {
|
|
176
|
+
async function handleRequest(req, res, token) {
|
|
96
177
|
const url = req.url || "/";
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"Access-Control-Allow-Methods": "GET,POST,OPTIONS",
|
|
101
|
-
"Access-Control-Allow-Headers": "Content-Type",
|
|
102
|
-
});
|
|
103
|
-
return res.end();
|
|
104
|
-
}
|
|
178
|
+
const port = req.socket.address().port;
|
|
179
|
+
assertTrustedRequest(req, url, port, token);
|
|
180
|
+
const isGet = req.method === "GET";
|
|
105
181
|
// API: Overview + progress
|
|
106
|
-
if (url === "/api/status") {
|
|
182
|
+
if (url === "/api/status" && isGet) {
|
|
107
183
|
const cache = readCacheFile();
|
|
108
184
|
const base = cache || { projects: [], updatedAt: null };
|
|
109
185
|
return jsonRes(res, { ...base, scanning, scanProgress });
|
|
110
186
|
}
|
|
111
187
|
// API: Scan progress only (lightweight poll)
|
|
112
|
-
if (url === "/api/scan/progress") {
|
|
188
|
+
if (url === "/api/scan/progress" && isGet) {
|
|
113
189
|
return jsonRes(res, { scanning, ...scanProgress });
|
|
114
190
|
}
|
|
115
191
|
// API: Project detail (live scan)
|
|
116
|
-
if (url.startsWith("/api/project/")) {
|
|
117
|
-
|
|
192
|
+
if (url.startsWith("/api/project/") && isGet) {
|
|
193
|
+
let projectName;
|
|
194
|
+
try {
|
|
195
|
+
projectName = decodeURIComponent(url.replace("/api/project/", "").split("?")[0]);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
throw new HttpError(400, "The project name in the address is not valid percent-encoding.");
|
|
199
|
+
}
|
|
118
200
|
const projects = discoverProjects();
|
|
119
201
|
const info = projects.find(p => p.name === projectName);
|
|
120
202
|
if (!info)
|
|
@@ -122,7 +204,6 @@ async function handleRequest(req, res) {
|
|
|
122
204
|
try {
|
|
123
205
|
const outdated = getOutdated(info.path, info);
|
|
124
206
|
const grouped = groupByEcosystem(outdated);
|
|
125
|
-
const security = getSecurityIssues(info.path, info);
|
|
126
207
|
const health = computeHealthReport(info);
|
|
127
208
|
const enrichedGroups = {};
|
|
128
209
|
for (const [ecosystem, items] of Object.entries(grouped)) {
|
|
@@ -138,10 +219,10 @@ async function handleRequest(req, res) {
|
|
|
138
219
|
packageManager: info.packageManager,
|
|
139
220
|
outdatedCount: Object.keys(outdated).length,
|
|
140
221
|
majorCount: Object.values(outdated).filter(p => isMajorUpdate(p.current, p.latest)).length,
|
|
141
|
-
securityIssues:
|
|
222
|
+
securityIssues: health.securityIssues, health, groups: enrichedGroups,
|
|
142
223
|
updateCommands: {
|
|
143
|
-
safe:
|
|
144
|
-
latest:
|
|
224
|
+
safe: buildUpdatePlan(info, undefined, "minor").display,
|
|
225
|
+
latest: buildUpdatePlan(info, undefined, "latest").display,
|
|
145
226
|
},
|
|
146
227
|
});
|
|
147
228
|
}
|
|
@@ -166,34 +247,51 @@ async function handleRequest(req, res) {
|
|
|
166
247
|
}
|
|
167
248
|
// API: Update dependencies
|
|
168
249
|
if (url === "/api/update" && req.method === "POST") {
|
|
169
|
-
const
|
|
170
|
-
|
|
250
|
+
const { project, packages, level = "minor", dryRun = false } = await readJsonBody(req);
|
|
251
|
+
if (typeof project !== "string")
|
|
252
|
+
throw new HttpError(400, "`project` must be a string.");
|
|
253
|
+
if (packages !== undefined && typeof packages !== "string")
|
|
254
|
+
throw new HttpError(400, "`packages` must be a string.");
|
|
255
|
+
if (typeof level !== "string" || !UPDATE_LEVELS.includes(level)) {
|
|
256
|
+
throw new HttpError(400, `\`level\` must be one of: ${UPDATE_LEVELS.join(", ")}.`);
|
|
257
|
+
}
|
|
258
|
+
if (typeof dryRun !== "boolean")
|
|
259
|
+
throw new HttpError(400, "`dryRun` must be true or false.");
|
|
171
260
|
const projects = discoverProjects();
|
|
172
261
|
const info = projects.find(p => p.name === project);
|
|
173
262
|
if (!info)
|
|
174
263
|
return jsonRes(res, { error: "Project not found" }, 404);
|
|
175
|
-
|
|
264
|
+
let plan;
|
|
265
|
+
try {
|
|
266
|
+
plan = buildUpdatePlan(info, packages, level);
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
return jsonRes(res, { error: err.message, success: false }, 400);
|
|
270
|
+
}
|
|
176
271
|
if (dryRun)
|
|
177
|
-
return jsonRes(res, { command:
|
|
272
|
+
return jsonRes(res, { command: plan.display, dryRun: true });
|
|
178
273
|
try {
|
|
179
|
-
const output =
|
|
180
|
-
return jsonRes(res, { command:
|
|
274
|
+
const output = runSteps(plan.steps, info.path);
|
|
275
|
+
return jsonRes(res, { command: plan.display, output, success: true });
|
|
181
276
|
}
|
|
182
277
|
catch (err) {
|
|
183
|
-
return jsonRes(res, { command:
|
|
278
|
+
return jsonRes(res, { command: plan.display, error: err.message, success: false });
|
|
184
279
|
}
|
|
185
280
|
}
|
|
186
281
|
// API: Get auto-update config
|
|
187
282
|
if (url === "/api/autoupdate" && req.method === "GET") {
|
|
188
283
|
const config = loadConfig();
|
|
189
|
-
return jsonRes(res, { autoUpdate: config.autoUpdate
|
|
284
|
+
return jsonRes(res, { autoUpdate: config.autoUpdate });
|
|
190
285
|
}
|
|
191
286
|
// API: Toggle auto-update
|
|
192
287
|
if (url === "/api/autoupdate" && req.method === "POST") {
|
|
193
|
-
const
|
|
194
|
-
|
|
288
|
+
const { project, enabled } = await readJsonBody(req);
|
|
289
|
+
if (typeof project !== "string")
|
|
290
|
+
throw new HttpError(400, "`project` must be a string.");
|
|
291
|
+
if (typeof enabled !== "boolean")
|
|
292
|
+
throw new HttpError(400, "`enabled` must be true or false.");
|
|
195
293
|
const config = loadConfig();
|
|
196
|
-
const list = config.autoUpdate
|
|
294
|
+
const list = config.autoUpdate;
|
|
197
295
|
if (enabled && !list.includes(project))
|
|
198
296
|
list.push(project);
|
|
199
297
|
else if (!enabled) {
|
|
@@ -204,63 +302,114 @@ async function handleRequest(req, res) {
|
|
|
204
302
|
saveConfig({ autoUpdate: list });
|
|
205
303
|
return jsonRes(res, { autoUpdate: list });
|
|
206
304
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
305
|
+
if (url.startsWith("/api/"))
|
|
306
|
+
throw new HttpError(404, "Unknown API route or method.");
|
|
307
|
+
if (!isGet)
|
|
308
|
+
throw new HttpError(405, "The page is served with GET only.");
|
|
309
|
+
// Serve HTML. It holds no secret: the token stays in the address the user opened.
|
|
310
|
+
const html = getHtml();
|
|
311
|
+
res.writeHead(200, {
|
|
312
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
313
|
+
"Cache-Control": "no-store",
|
|
314
|
+
"X-Frame-Options": "DENY",
|
|
315
|
+
"X-Content-Type-Options": "nosniff",
|
|
316
|
+
"Referrer-Policy": "no-referrer",
|
|
317
|
+
"Content-Security-Policy": "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
|
|
318
|
+
});
|
|
319
|
+
res.end(html);
|
|
210
320
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
321
|
+
/** The HTTP server, not yet listening, and the token its API requires (new at every launch). */
|
|
322
|
+
export function createDashboardServer() {
|
|
323
|
+
const token = randomBytes(32).toString("hex");
|
|
324
|
+
const server = createServer((req, res) => {
|
|
325
|
+
handleRequest(req, res, token).catch((err) => {
|
|
326
|
+
if (res.headersSent)
|
|
327
|
+
return;
|
|
328
|
+
if (err instanceof HttpError)
|
|
329
|
+
return jsonRes(res, { error: err.message }, err.status);
|
|
330
|
+
console.error("[depsonar] Dashboard request failed:", err);
|
|
331
|
+
jsonRes(res, { error: err instanceof Error ? err.message : String(err) }, 500);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
return { server, token };
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Listens on the loopback address only. `schedule: false` leaves out the background scans
|
|
338
|
+
* and auto-updates (tests).
|
|
339
|
+
*/
|
|
340
|
+
export function startDashboard(port = PORT, schedule = true) {
|
|
341
|
+
const { server, token } = createDashboardServer();
|
|
342
|
+
server.listen(port, "127.0.0.1", () => {
|
|
343
|
+
const listeningPort = server.address().port;
|
|
344
|
+
console.error(`[depsonar] Dashboard v3 running. Open this address (it carries this launch's access token):`);
|
|
345
|
+
console.error(`[depsonar] http://127.0.0.1:${listeningPort}/#token=${token}`);
|
|
346
|
+
if (!schedule)
|
|
235
347
|
return;
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
348
|
+
// ─── Built-in Background Scheduler ─────────────────────────────────
|
|
349
|
+
const SCAN_INTERVAL = 12 * 60 * 60 * 1000; // 12h
|
|
350
|
+
const UPDATE_INTERVAL = 24 * 60 * 60 * 1000; // 24h
|
|
351
|
+
async function backgroundScan() {
|
|
352
|
+
if (scanning)
|
|
353
|
+
return;
|
|
354
|
+
console.error("[depsonar] Background scan starting...");
|
|
355
|
+
scanning = true;
|
|
244
356
|
try {
|
|
245
|
-
|
|
246
|
-
ok++;
|
|
247
|
-
console.error(`[depsonar] ✓ ${name}`);
|
|
357
|
+
await runScanWithProgress();
|
|
248
358
|
}
|
|
249
359
|
catch (e) {
|
|
250
|
-
|
|
251
|
-
console.error(`[depsonar] ✗ ${name}: ${e.message}`);
|
|
360
|
+
console.error("[depsonar] Background scan error:", e);
|
|
252
361
|
}
|
|
362
|
+
scanning = false;
|
|
363
|
+
console.error("[depsonar] Background scan complete.");
|
|
253
364
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
365
|
+
async function backgroundAutoUpdate() {
|
|
366
|
+
const config = loadConfig();
|
|
367
|
+
const autoList = config.autoUpdate;
|
|
368
|
+
if (!autoList.length)
|
|
369
|
+
return;
|
|
370
|
+
console.error(`[depsonar] Auto-updating ${autoList.length} projects (minor+patch only)...`);
|
|
371
|
+
const projects = discoverProjects();
|
|
372
|
+
let ok = 0, fail = 0;
|
|
373
|
+
for (const name of autoList) {
|
|
374
|
+
const info = projects.find(p => p.name === name);
|
|
375
|
+
if (!info)
|
|
376
|
+
continue;
|
|
377
|
+
try {
|
|
378
|
+
runSteps(buildUpdatePlan(info, undefined, "minor").steps, info.path);
|
|
379
|
+
ok++;
|
|
380
|
+
console.error(`[depsonar] ✓ ${name}`);
|
|
381
|
+
}
|
|
382
|
+
catch (e) {
|
|
383
|
+
fail++;
|
|
384
|
+
console.error(`[depsonar] ✗ ${name}: ${e.message}`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
console.error(`[depsonar] Auto-update done: ${ok} updated, ${fail} failed.`);
|
|
388
|
+
// Rescan after updates
|
|
389
|
+
if (ok > 0)
|
|
390
|
+
await backgroundScan();
|
|
391
|
+
}
|
|
392
|
+
// Initial scan on startup (after 10s to let things settle)
|
|
393
|
+
setTimeout(backgroundScan, 10_000);
|
|
394
|
+
// Periodic scan every 12h
|
|
395
|
+
setInterval(backgroundScan, SCAN_INTERVAL);
|
|
396
|
+
// Periodic auto-update every 24h (only projects with auto-update toggle ON)
|
|
397
|
+
setInterval(backgroundAutoUpdate, UPDATE_INTERVAL);
|
|
398
|
+
});
|
|
399
|
+
return { server, token };
|
|
400
|
+
}
|
|
401
|
+
// Started directly (`depsonar-dashboard`), not imported by index.js or a test.
|
|
402
|
+
function isDirectRun() {
|
|
403
|
+
const entry = process.argv[1];
|
|
404
|
+
if (!entry)
|
|
405
|
+
return false;
|
|
406
|
+
try {
|
|
407
|
+
return realpathSync(entry) === fileURLToPath(import.meta.url);
|
|
258
408
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
409
|
+
catch {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (isDirectRun())
|
|
414
|
+
startDashboard();
|
|
266
415
|
//# sourceMappingURL=dashboard.js.map
|