@xagents_in/unmask 0.1.1 → 0.1.3
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 +220 -86
- package/dist/cli/batch.mjs +218 -0
- package/dist/cli/main.mjs +4 -0
- package/dist/cli/scan.mjs +128 -0
- package/dist/core/advisories.mjs +457 -0
- package/dist/core/package-details.mjs +638 -0
- package/dist/core/registry-facts.mjs +342 -0
- package/dist/core/report-exploration.mjs +328 -0
- package/dist/model/client.mjs +59 -32
- package/dist/server/app.mjs +37 -6
- package/dist/server/enrichment.mjs +116 -0
- package/dist/server/main.mjs +16 -0
- package/dist/server/queue.mjs +85 -6
- package/dist/server/registry-facts.mjs +118 -0
- package/dist/server/report-exploration.mjs +87 -0
- package/dist/version.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildReportFileInventory,
|
|
3
|
+
buildReportFileEvidence,
|
|
4
|
+
explorationJson,
|
|
5
|
+
} from "../core/report-exploration.mjs";
|
|
6
|
+
|
|
7
|
+
function queryParameters(raw, allowed) {
|
|
8
|
+
if (raw.length > 16384) throw new TypeError("Query too long");
|
|
9
|
+
decodeURIComponent(raw.replace(/\+/g, " "));
|
|
10
|
+
const params = new URLSearchParams(raw);
|
|
11
|
+
for (const key of params.keys())
|
|
12
|
+
if (!allowed.includes(key) || params.getAll(key).length !== 1)
|
|
13
|
+
throw new TypeError("Unknown or duplicate query key");
|
|
14
|
+
return params;
|
|
15
|
+
}
|
|
16
|
+
function integer(params, name, fallback) {
|
|
17
|
+
if (!params.has(name)) return fallback;
|
|
18
|
+
const value = params.get(name);
|
|
19
|
+
if (!/^(0|[1-9]\d*)$/.test(value)) throw new TypeError("Invalid integer");
|
|
20
|
+
return Number(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function handleReportExploration({ path, getJob, send }) {
|
|
24
|
+
const match = /^\/r\/([a-f0-9]{32})\/(files|file)\.json(?:\?([^#]*))?$/.exec(
|
|
25
|
+
path,
|
|
26
|
+
);
|
|
27
|
+
if (!match) return false;
|
|
28
|
+
const json = (status, body, headers = {}) =>
|
|
29
|
+
send(status, explorationJson(body), "application/json; charset=utf-8", {
|
|
30
|
+
"content-disposition":
|
|
31
|
+
match[2] === "file"
|
|
32
|
+
? 'attachment; filename="unmask-file-evidence.json"'
|
|
33
|
+
: 'attachment; filename="unmask-files.json"',
|
|
34
|
+
...headers,
|
|
35
|
+
});
|
|
36
|
+
const drilldown = match[2] === "file";
|
|
37
|
+
const context = { reportId: match[1] };
|
|
38
|
+
let options;
|
|
39
|
+
try {
|
|
40
|
+
if (drilldown) {
|
|
41
|
+
const params = queryParameters(match[3] ?? "", [
|
|
42
|
+
"path",
|
|
43
|
+
"originalPath",
|
|
44
|
+
"fileId",
|
|
45
|
+
]);
|
|
46
|
+
options = Object.fromEntries(params);
|
|
47
|
+
buildReportFileEvidence({ files: [] }, options, context);
|
|
48
|
+
} else {
|
|
49
|
+
const params = queryParameters(match[3] ?? "", [
|
|
50
|
+
"state",
|
|
51
|
+
"prefix",
|
|
52
|
+
"offset",
|
|
53
|
+
"limit",
|
|
54
|
+
]);
|
|
55
|
+
options = {
|
|
56
|
+
state: params.get("state") ?? "all",
|
|
57
|
+
prefix: params.get("prefix") ?? "",
|
|
58
|
+
offset: integer(params, "offset", 0),
|
|
59
|
+
limit: integer(params, "limit", 50),
|
|
60
|
+
};
|
|
61
|
+
buildReportFileInventory({ files: [] }, options, context);
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
json(400, { error: "invalid-query" });
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const job = getJob(match[1]);
|
|
68
|
+
if (!job) json(404, { error: "report-unavailable" });
|
|
69
|
+
else if (!job.report) {
|
|
70
|
+
const pending = ["queued", "running"].includes(job.status);
|
|
71
|
+
json(
|
|
72
|
+
pending ? 202 : 409,
|
|
73
|
+
{
|
|
74
|
+
error: pending ? "report-pending" : "report-unavailable",
|
|
75
|
+
status: job.status,
|
|
76
|
+
},
|
|
77
|
+
pending ? { "retry-after": "3" } : {},
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
const body = drilldown
|
|
81
|
+
? buildReportFileEvidence(job.report, options, context)
|
|
82
|
+
: buildReportFileInventory(job.report, options, context);
|
|
83
|
+
if (!body) json(404, { error: "file-unavailable" });
|
|
84
|
+
else json(200, { reportId: match[1], ...body });
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
package/dist/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"buildSchema":"1","version":"0.1.
|
|
1
|
+
{"buildSchema":"1","version":"0.1.3","dirty":false,"commit":"541bc4d2e4710b411202882ec2480801994b6cf9","sourceSha256":"429745022e980eb8d09b1c6a6614b8b25f49921bd1883b0b111dfd5c3137ada3","packageSha256":"28210403766aff6ca070f8ca93df42117e93eedb5005b2a1b1fec4ee2f68c0c0","lockfileSha256":"2f632db652163f9f8f55ed649962fc5e4f718daf2edf6b0f0eea5d9501013dac","files":{"cli/batch.mjs":{"sha256":"101f7ecb4c3d5890c42f402e5ca00ab97351c4a4d90e07a1fa4367e3c0807650","size":7296},"cli/hosted.mjs":{"sha256":"dea7b512a2e811102521565e9f218c77aab916fe05e838f55a9aeb7b43cd0852","size":7436},"cli/main.mjs":{"sha256":"c4429dd331b377a1b1ca9b25a04721d51f38c39ee395de2239d0ad2bf7ccb57c","size":6825},"cli/scan.mjs":{"sha256":"9bf33e926ededf1beb1e4af73c861ba5bf33bee74ca0544151112284e0afc1b5","size":3906},"core/acquire.mjs":{"sha256":"aee5ed002292edf1b03385ceec8ebfb03de452dba36bbdced96f888eaafa1d67","size":9549},"core/advisories.mjs":{"sha256":"388088e44422ffeb3b60d930c84cec29fbc89b98d8dfd2879bc6ede50f4e7ea9","size":13004},"core/archive.mjs":{"sha256":"80aa4373c0324458fe322a83af18a4cfd0ffec4b39ebdeffc9084639a8655410","size":16193},"core/compare.mjs":{"sha256":"540614266e06a2875010793d036d256ddfac72f978157cd3d147ffb99015d8e4","size":7579},"core/manifests.mjs":{"sha256":"29c40e01ff1e1dfaed444600d8c78380d23d4bc9be71960251e39ea3594de2f1","size":17891},"core/online.mjs":{"sha256":"368a3f2558e16db0701d2eaf068b48e2661e7e01ab7cf5605cdd22766aeb5cca","size":9741},"core/package-details.mjs":{"sha256":"770551a6ab84e523dbc56ede6131b08eb22b8c21fc9c8b179fe0d1769fb2ec00","size":21538},"core/pipeline.mjs":{"sha256":"9c4ddc5c258a99455a1230c978fd132c135057ad7bb6c7baa201ae530ee136fd","size":11060},"core/policy.mjs":{"sha256":"4281c626c00a6424992f5e1eba26876e2b70f4b968450a8ca52fa42f5a121ba5","size":2954},"core/registry-facts.mjs":{"sha256":"726344597044b0c23fb74aff4fbfe7c60cbbfc4c0bee838abf9257134f9c96db","size":11013},"core/report-exploration.mjs":{"sha256":"1dcc9897d3bbc98ee3107ef8f8279d9eed6ee6d104455eb214a5e5644bd197fb","size":10137},"core/report.mjs":{"sha256":"aa167c94c257a5ff6d830630a37a51a9a9e47f82aa4a0a7b96ead91a5967294b","size":15844},"core/resolve.mjs":{"sha256":"d5575da49ff78e8fea8df1f2fc10a39540adea285eddfa347746e848f9fdf957","size":5202},"core/source.mjs":{"sha256":"798fe74e3fba836b82576cd46e1b91e6f6e0a4e3cf273c533b5e074247c81373","size":3238},"core/syntax.mjs":{"sha256":"2d50f2e73e17aedbcbccd92af280e171de4ef78b55acccd23d6b6ef11e891776","size":10450},"model/client.mjs":{"sha256":"efb68132710cbdff6b86b58cbac006c48e10f9317e852f00b120ef7c3c7ed9c1","size":42865},"model/config.mjs":{"sha256":"127605979a299616be15f4a47e94dcd82928b00ad2af71744ffaa6e359516486","size":3245},"server/app.mjs":{"sha256":"2aa5678bcdd38702707fa05ec7aa749d46f1590993e491ec0adc408a35d2f890","size":10498},"server/enrichment.mjs":{"sha256":"3c5cc57f2c8f019f79418457f366a9422e0a03a8ba86a41b0767aba636bde179","size":3825},"server/main.mjs":{"sha256":"e5bdcd02209c2ccc1ed8c73b85b9988d61aa3e1bcf7c8d119eed782a4bfcd224","size":4587},"server/queue.mjs":{"sha256":"23e30f3ff570771b77a244be9200ad510d2f19811eee566d68b364b7f741a9d7","size":7371},"server/registry-facts.mjs":{"sha256":"58bce5b2a40f25e7561f122ea012594c9eb6789f993ca83dadc07f198afca9e3","size":3315},"server/report-exploration.mjs":{"sha256":"862b8d0ea07b627368aaca3a0f66359cfc638b14c54ab4158f8ef313602c3810","size":2774},"server/runner.mjs":{"sha256":"a6ca5bfbd7b239f7110639d854ca9a263f4cf3aaf06701ea54493b29f8244706","size":9071},"server/store.mjs":{"sha256":"efa2a35c7e9d0344c26e24ba360a457cdf80f4f48975f0186f81844b9fb7a097","size":2706},"server/worker.mjs":{"sha256":"1df839608cd1c691fc2801d89e698daeef3e48d7f4b8843ce1252a21fde9730a","size":1902},"viewer/render.mjs":{"sha256":"c77442c27041a5fe28269b8c80c9d24c72b73a226e8d4491e6d7285a9feb5309","size":19443},"viewer/shell.mjs":{"sha256":"5f800d0a97fe416d02cf9abef766d651b444b4745ad3a998926599469358ca79","size":9408}}}
|