unbound-cli 1.22.1 → 1.24.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 +26 -0
- package/package.json +1 -1
- package/src/commands/delivery.js +567 -0
- package/src/commands/setup.js +45 -7
- package/src/index.js +10 -0
- package/test/delivery.test.js +591 -0
- package/test/setup-wsl-task.test.js +123 -0
package/src/commands/setup.js
CHANGED
|
@@ -249,6 +249,35 @@ async function runPythonScript(scriptPath, args, { capture }) {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
// An elevated process can't reach WSL distros (they're per user), so onboard.py's logon
|
|
253
|
+
// task sets each user's distros up as that user. Clear drops these tools; the task goes with the last one.
|
|
254
|
+
const WSL_TASK_PY = `import importlib.util as u, sys
|
|
255
|
+
s = u.spec_from_file_location("onboard", sys.argv[1]); m = u.module_from_spec(s); s.loader.exec_module(m)
|
|
256
|
+
urls = sys.argv[3:]
|
|
257
|
+
if sys.argv[2] != "clear": sys.exit(0 if m.install_wsl_logon_task(urls) else 1)
|
|
258
|
+
for x in urls: (m._wsl_dir() / x.replace("/mdm/setup.py", "/setup.py")[len(m._RAW_SETUP) + 1:].replace("/", "-")).unlink(missing_ok=True)
|
|
259
|
+
sys.exit(0 if any(m._wsl_dir().glob("*-setup.py")) or m.remove_wsl_logon_task() else 1)`;
|
|
260
|
+
|
|
261
|
+
async function syncWslLogonTask(tools, clear) {
|
|
262
|
+
const s = output.spinner(clear ? 'Clearing WSL logon task...' : 'Setting up WSL logon task...');
|
|
263
|
+
try {
|
|
264
|
+
const r = await withSecureTempFile('.py', async (tmp) => {
|
|
265
|
+
await downloadToFile(`${SETUP_BASE_URL}/mdm/onboard.py`, tmp);
|
|
266
|
+
const py = resolvePython();
|
|
267
|
+
const urls = tools.map((t) => `${SETUP_BASE_URL}/${t.script}`);
|
|
268
|
+
return spawnSync(py.cmd, [...py.prefix, '-I', '-c', WSL_TASK_PY, tmp, clear ? 'clear' : 'install', ...urls],
|
|
269
|
+
{ encoding: 'utf8', windowsHide: true, timeout: 600000 });
|
|
270
|
+
});
|
|
271
|
+
if (r.status !== 0) throw new Error(`${r.stdout || ''}${r.stderr || ''}`.trim() || String(r.error || r.status));
|
|
272
|
+
s.succeed(clear ? 'WSL logon task updated' : "WSL distros: each user's are set up at their next login");
|
|
273
|
+
return true;
|
|
274
|
+
} catch (err) {
|
|
275
|
+
s.fail(clear ? 'Could not fully clear the WSL logon task' : 'WSL distros will not be set up; Windows setup is unaffected');
|
|
276
|
+
console.error(output.colors.dim(` ${err.message}`));
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
252
281
|
/**
|
|
253
282
|
* Builds the shared argv tail for setup.py invocations. Always passes the
|
|
254
283
|
* tenant URL flags so the script's behavior is not sensitive to drift in its
|
|
@@ -602,8 +631,9 @@ function reportMdmSkips(labels) {
|
|
|
602
631
|
* Runs a batch of tools sequentially with spinners. Stops on the first hard
|
|
603
632
|
* failure. A tool that reports an MDM skip is NOT a failure — it's collected and
|
|
604
633
|
* surfaced (in red) at the end, and the batch continues. Returns
|
|
605
|
-
* { ok, skipped } — ok is false only on a hard failure; skipped is the list of
|
|
606
|
-
* MDM-managed tool labels so callers can qualify their own success message
|
|
634
|
+
* { ok, skipped, done } — ok is false only on a hard failure; skipped is the list of
|
|
635
|
+
* MDM-managed tool labels so callers can qualify their own success message; done
|
|
636
|
+
* is the tools that ran to success, even when a later one failed.
|
|
607
637
|
* When `summary` is set, a green success line is printed for the configured
|
|
608
638
|
* tools before the MDM notice.
|
|
609
639
|
*
|
|
@@ -615,6 +645,7 @@ function reportMdmSkips(labels) {
|
|
|
615
645
|
async function runBatch(tools, runFn, { clear = false, summary = null, report = null } = {}) {
|
|
616
646
|
const action = clear ? 'Clearing' : 'Setting up';
|
|
617
647
|
const mdmSkipped = [];
|
|
648
|
+
const done = [];
|
|
618
649
|
for (const tool of tools) {
|
|
619
650
|
const s = output.spinner(`${action} ${tool.label}...`);
|
|
620
651
|
try {
|
|
@@ -627,6 +658,7 @@ async function runBatch(tools, runFn, { clear = false, summary = null, report =
|
|
|
627
658
|
mdmSkipped.push(tool.label);
|
|
628
659
|
} else {
|
|
629
660
|
s.succeed(tool.label);
|
|
661
|
+
done.push(tool);
|
|
630
662
|
}
|
|
631
663
|
} catch (err) {
|
|
632
664
|
s.fail(`Failed: ${tool.label}`);
|
|
@@ -643,7 +675,7 @@ async function runBatch(tools, runFn, { clear = false, summary = null, report =
|
|
|
643
675
|
}
|
|
644
676
|
// Still surface any tools skipped before this failure so the notice isn't lost.
|
|
645
677
|
reportMdmSkips(mdmSkipped);
|
|
646
|
-
return { ok: false, skipped: mdmSkipped };
|
|
678
|
+
return { ok: false, skipped: mdmSkipped, done };
|
|
647
679
|
}
|
|
648
680
|
}
|
|
649
681
|
const configured = tools.length - mdmSkipped.length;
|
|
@@ -654,7 +686,7 @@ async function runBatch(tools, runFn, { clear = false, summary = null, report =
|
|
|
654
686
|
output.success(mdmSkipped.length ? `${configured} of ${tools.length} tools ${clear ? 'cleared' : 'configured'}` : summary);
|
|
655
687
|
}
|
|
656
688
|
reportMdmSkips(mdmSkipped);
|
|
657
|
-
return { ok: true, skipped: mdmSkipped };
|
|
689
|
+
return { ok: true, skipped: mdmSkipped, done };
|
|
658
690
|
}
|
|
659
691
|
|
|
660
692
|
/**
|
|
@@ -922,7 +954,7 @@ must update the MDM configuration.
|
|
|
922
954
|
if (!scriptSupportsBackfill(tool.script)) noteBackfillUnsupported(tool.label, tool.script);
|
|
923
955
|
}
|
|
924
956
|
}
|
|
925
|
-
const {
|
|
957
|
+
const { done } = await runBatch(
|
|
926
958
|
resolvedTools,
|
|
927
959
|
(tool) => {
|
|
928
960
|
const toolArgs = buildScriptArgs(adminApiKey, {
|
|
@@ -938,7 +970,8 @@ must update the MDM configuration.
|
|
|
938
970
|
},
|
|
939
971
|
{ clear: opts.clear, summary: opts.clear ? 'All tools cleared' : 'All tools configured', report: { apiKey: adminApiKey, backendUrl } }
|
|
940
972
|
);
|
|
941
|
-
|
|
973
|
+
// Tools a later failure didn't reach are left as they were, on Windows and in WSL alike.
|
|
974
|
+
if (done.length && isWindowsNative()) await syncWslLogonTask(done, opts.clear);
|
|
942
975
|
return;
|
|
943
976
|
}
|
|
944
977
|
|
|
@@ -1225,6 +1258,7 @@ Examples:
|
|
|
1225
1258
|
if (includeMdm) {
|
|
1226
1259
|
const mdmTools = Object.keys(MDM_TOOLS).map(name => ({ name, ...MDM_TOOLS[name] }));
|
|
1227
1260
|
mdmFailed = await clearToolsBestEffort('mdm', mdmTools, { mdm: true, backendUrl, gatewayUrl });
|
|
1261
|
+
if (isWindowsNative() && !(await syncWslLogonTask(mdmTools, true))) mdmFailed.push('WSL logon task');
|
|
1228
1262
|
|
|
1229
1263
|
// Root-only by construction (gated on includeMdm). No-op when no binary
|
|
1230
1264
|
// install is present (python-only setups) and on Windows.
|
|
@@ -1331,7 +1365,7 @@ async function runMdmSetupAllBundle(adminApiKey, { backendUrl, frontendUrl, gate
|
|
|
1331
1365
|
if (!scriptSupportsBackfill(tool.script)) noteBackfillUnsupported(tool.label, tool.script);
|
|
1332
1366
|
}
|
|
1333
1367
|
}
|
|
1334
|
-
|
|
1368
|
+
const result = await runBatch(resolvedTools, (tool) => {
|
|
1335
1369
|
const args = buildScriptArgs(adminApiKey, {
|
|
1336
1370
|
backendUrl, frontendUrl, gatewayUrl, mdm: true,
|
|
1337
1371
|
backfill: backfill && scriptSupportsBackfill(tool.script),
|
|
@@ -1339,6 +1373,8 @@ async function runMdmSetupAllBundle(adminApiKey, { backendUrl, frontendUrl, gate
|
|
|
1339
1373
|
});
|
|
1340
1374
|
return runScriptPiped(tool.script, args);
|
|
1341
1375
|
}, { report: { apiKey: adminApiKey, backendUrl } });
|
|
1376
|
+
if (result.done.length && isWindowsNative()) await syncWslLogonTask(result.done, false);
|
|
1377
|
+
return result;
|
|
1342
1378
|
}
|
|
1343
1379
|
|
|
1344
1380
|
module.exports = {
|
|
@@ -1348,6 +1384,8 @@ module.exports = {
|
|
|
1348
1384
|
scopeNotice,
|
|
1349
1385
|
runSetupAllBundle,
|
|
1350
1386
|
runMdmSetupAllBundle,
|
|
1387
|
+
syncWslLogonTask,
|
|
1388
|
+
WSL_TASK_PY,
|
|
1351
1389
|
hasRootPrivileges,
|
|
1352
1390
|
ALL_TOOLS,
|
|
1353
1391
|
MDM_ALL_TOOLS,
|
package/src/index.js
CHANGED
|
@@ -183,6 +183,15 @@ FLAGS AND FALSE POSITIVES (Admin/Analytics Viewer/Manager; mark-fp is Admin only
|
|
|
183
183
|
Mark a detection as a false positive
|
|
184
184
|
$ unbound trace <trace-id> Log, terminal runs and data security for one trace ID
|
|
185
185
|
|
|
186
|
+
DELIVERY (Admin/Analytics Viewer, whole organization)
|
|
187
|
+
$ unbound delivery summary Branches, PRs opened and merged, spend, cost per PR
|
|
188
|
+
$ unbound delivery branches AI branches with PR, ticket, work group and cost
|
|
189
|
+
$ unbound delivery branch <id> One branch with its timeline and sessions
|
|
190
|
+
$ unbound delivery users | teams Spend, PRs and merges per person or department
|
|
191
|
+
$ unbound delivery spend --by outcome|work-group
|
|
192
|
+
AI spend by PR outcome or work group
|
|
193
|
+
$ unbound delivery repos Repositories to pass to --repo
|
|
194
|
+
|
|
186
195
|
FALSE POSITIVES ON YOUR OWN REQUESTS (any user)
|
|
187
196
|
$ unbound false-positive list <trace-id> Your findings on a blocked request
|
|
188
197
|
$ unbound false-positive mark <trace-id> Mark one as a false positive
|
|
@@ -232,6 +241,7 @@ require('./commands/user-groups').register(program);
|
|
|
232
241
|
require('./commands/tools').register(program);
|
|
233
242
|
require('./commands/analytics').register(program);
|
|
234
243
|
require('./commands/flags').register(program);
|
|
244
|
+
require('./commands/delivery').register(program);
|
|
235
245
|
require('./commands/trace').register(program);
|
|
236
246
|
require('./commands/false-positive').register(program);
|
|
237
247
|
require('./commands/download').register(program);
|