prior-cli 1.5.3 → 1.5.4
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/lib/tools.js +40 -0
- package/package.json +1 -1
package/lib/tools.js
CHANGED
|
@@ -376,6 +376,46 @@ const TOOLS = {
|
|
|
376
376
|
summary: `@${u.username || '?'}`,
|
|
377
377
|
};
|
|
378
378
|
},
|
|
379
|
+
async zap_scan({ url, scan_type = 'passive' }, { token }) {
|
|
380
|
+
if (!url) throw new Error('"url" is required');
|
|
381
|
+
const res = await fetch(`${CLI_BASE}/api/zap/scan`, {
|
|
382
|
+
method: 'POST',
|
|
383
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
384
|
+
body: JSON.stringify({ url, scan_type }),
|
|
385
|
+
timeout: 60000,
|
|
386
|
+
});
|
|
387
|
+
if (res.status === 403) throw new Error('ZAP tools are only available to Organization accounts.');
|
|
388
|
+
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `HTTP ${res.status}`); }
|
|
389
|
+
const data = await res.json();
|
|
390
|
+
return { output: data.output || JSON.stringify(data), summary: data.summary || `scan started for ${url}` };
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
async zap_alerts({ url }, { token }) {
|
|
394
|
+
const res = await fetch(`${CLI_BASE}/api/zap/alerts`, {
|
|
395
|
+
method: 'POST',
|
|
396
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
397
|
+
body: JSON.stringify({ url }),
|
|
398
|
+
timeout: 15000,
|
|
399
|
+
});
|
|
400
|
+
if (res.status === 403) throw new Error('ZAP tools are only available to Organization accounts.');
|
|
401
|
+
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `HTTP ${res.status}`); }
|
|
402
|
+
const data = await res.json();
|
|
403
|
+
return { output: data.output || JSON.stringify(data), summary: data.summary || 'alerts fetched' };
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
async zap_spider({ url }, { token }) {
|
|
407
|
+
if (!url) throw new Error('"url" is required');
|
|
408
|
+
const res = await fetch(`${CLI_BASE}/api/zap/spider`, {
|
|
409
|
+
method: 'POST',
|
|
410
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
411
|
+
body: JSON.stringify({ url }),
|
|
412
|
+
timeout: 60000,
|
|
413
|
+
});
|
|
414
|
+
if (res.status === 403) throw new Error('ZAP tools are only available to Organization accounts.');
|
|
415
|
+
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error || `HTTP ${res.status}`); }
|
|
416
|
+
const data = await res.json();
|
|
417
|
+
return { output: data.output || JSON.stringify(data), summary: data.summary || `spider started for ${url}` };
|
|
418
|
+
},
|
|
379
419
|
};
|
|
380
420
|
|
|
381
421
|
async function executeTool(name, args, context) {
|