@pensar/apex 0.0.12 → 0.0.14
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/build/benchmark.js +27 -58
- package/build/index.js +27 -58
- package/build/quicktest.js +27 -58
- package/build/swarm.js +29 -59
- package/package.json +1 -1
package/build/benchmark.js
CHANGED
|
@@ -39828,7 +39828,7 @@ function createSummarizationStream(messages, opts, model) {
|
|
|
39828
39828
|
}
|
|
39829
39829
|
|
|
39830
39830
|
// src/core/ai/ai.ts
|
|
39831
|
-
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model) {
|
|
39831
|
+
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model, silent) {
|
|
39832
39832
|
let wrappedStream = null;
|
|
39833
39833
|
const handler = {
|
|
39834
39834
|
get(target, prop) {
|
|
@@ -39853,13 +39853,17 @@ function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, mod
|
|
|
39853
39853
|
currentMessages = response.messages;
|
|
39854
39854
|
}
|
|
39855
39855
|
} catch (e) {}
|
|
39856
|
-
|
|
39856
|
+
if (!silent) {
|
|
39857
|
+
console.warn(`Context length error in wrapper, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39858
|
+
}
|
|
39857
39859
|
const summarizationStream = createSummarizationStream(currentMessages, opts, model);
|
|
39858
39860
|
for await (const chunk of summarizationStream.fullStream) {
|
|
39859
39861
|
yield chunk;
|
|
39860
39862
|
}
|
|
39861
39863
|
} else {
|
|
39862
|
-
|
|
39864
|
+
if (!silent) {
|
|
39865
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39866
|
+
}
|
|
39863
39867
|
throw error46;
|
|
39864
39868
|
}
|
|
39865
39869
|
}
|
|
@@ -39883,7 +39887,8 @@ function streamResponse(opts) {
|
|
|
39883
39887
|
tools,
|
|
39884
39888
|
onStepFinish,
|
|
39885
39889
|
abortSignal,
|
|
39886
|
-
activeTools
|
|
39890
|
+
activeTools,
|
|
39891
|
+
silent
|
|
39887
39892
|
} = opts;
|
|
39888
39893
|
const messagesContainer = { current: messages || [] };
|
|
39889
39894
|
const providerModel = getProviderModel(model);
|
|
@@ -39910,7 +39915,9 @@ function streamResponse(opts) {
|
|
|
39910
39915
|
error: error46
|
|
39911
39916
|
}) => {
|
|
39912
39917
|
try {
|
|
39913
|
-
|
|
39918
|
+
if (!silent) {
|
|
39919
|
+
console.log("Repairing tool call:", toolCall.toolName, "Error:", error46);
|
|
39920
|
+
}
|
|
39914
39921
|
const tool2 = tools2[toolCall.toolName];
|
|
39915
39922
|
if (!tool2 || !tool2.inputSchema) {
|
|
39916
39923
|
throw new Error(`Tool ${toolCall.toolName} not found or has no schema`);
|
|
@@ -39931,19 +39938,25 @@ function streamResponse(opts) {
|
|
|
39931
39938
|
});
|
|
39932
39939
|
return { ...toolCall, input: JSON.stringify(repairedArgs) };
|
|
39933
39940
|
} catch (repairError) {
|
|
39934
|
-
|
|
39941
|
+
if (!silent) {
|
|
39942
|
+
console.error("Error repairing tool call:", repairError.message);
|
|
39943
|
+
}
|
|
39935
39944
|
throw repairError;
|
|
39936
39945
|
}
|
|
39937
39946
|
}
|
|
39938
39947
|
});
|
|
39939
|
-
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel);
|
|
39948
|
+
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel, silent);
|
|
39940
39949
|
} catch (error46) {
|
|
39941
39950
|
const isContextLengthError = checkIfContextLengthError(error46);
|
|
39942
39951
|
if (isContextLengthError) {
|
|
39943
|
-
|
|
39952
|
+
if (!silent) {
|
|
39953
|
+
console.warn(`Context length error, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39954
|
+
}
|
|
39944
39955
|
return createSummarizationStream(messagesContainer.current, opts, providerModel);
|
|
39945
39956
|
}
|
|
39946
|
-
|
|
39957
|
+
if (!silent) {
|
|
39958
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39959
|
+
}
|
|
39947
39960
|
throw error46;
|
|
39948
39961
|
}
|
|
39949
39962
|
}
|
|
@@ -43267,54 +43280,9 @@ Create this POC, test it, then retry document_finding.`,
|
|
|
43267
43280
|
};
|
|
43268
43281
|
const safeTitle = finding2.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").substring(0, 50);
|
|
43269
43282
|
const findingId = `${timestamp.split("T")[0]}-${safeTitle}`;
|
|
43270
|
-
const filename = `${findingId}.
|
|
43283
|
+
const filename = `${findingId}.json`;
|
|
43271
43284
|
const filepath = join2(session.findingsPath, filename);
|
|
43272
|
-
|
|
43273
|
-
|
|
43274
|
-
**Severity:** ${finding2.severity}
|
|
43275
|
-
**Target:** ${session.target}
|
|
43276
|
-
**Date:** ${timestamp}
|
|
43277
|
-
**Session:** ${session.id}
|
|
43278
|
-
**POC:** \`${finding2.pocPath}\`
|
|
43279
|
-
|
|
43280
|
-
## Description
|
|
43281
|
-
|
|
43282
|
-
${finding2.description}
|
|
43283
|
-
|
|
43284
|
-
## Impact
|
|
43285
|
-
|
|
43286
|
-
${finding2.impact}
|
|
43287
|
-
|
|
43288
|
-
## Evidence
|
|
43289
|
-
|
|
43290
|
-
\`\`\`
|
|
43291
|
-
${finding2.evidence}
|
|
43292
|
-
\`\`\`
|
|
43293
|
-
|
|
43294
|
-
## Proof of Concept
|
|
43295
|
-
|
|
43296
|
-
A working POC script is available at: \`${finding2.pocPath}\`
|
|
43297
|
-
|
|
43298
|
-
To reproduce this vulnerability, run:
|
|
43299
|
-
\`\`\`bash
|
|
43300
|
-
cd ${session.rootPath}
|
|
43301
|
-
./${finding2.pocPath}
|
|
43302
|
-
\`\`\`
|
|
43303
|
-
|
|
43304
|
-
## Remediation
|
|
43305
|
-
|
|
43306
|
-
${finding2.remediation}
|
|
43307
|
-
|
|
43308
|
-
${finding2.references ? `## References
|
|
43309
|
-
|
|
43310
|
-
${finding2.references}` : ""}
|
|
43311
|
-
|
|
43312
|
-
---
|
|
43313
|
-
|
|
43314
|
-
*This finding was automatically documented by the Pensar penetration testing agent.*
|
|
43315
|
-
*POC verified and available at: ${finding2.pocPath}*
|
|
43316
|
-
`;
|
|
43317
|
-
writeFileSync2(filepath, markdown);
|
|
43285
|
+
writeFileSync2(filepath, JSON.stringify(findingWithMeta, null, 2));
|
|
43318
43286
|
const summaryPath = join2(session.rootPath, "findings-summary.md");
|
|
43319
43287
|
const summaryEntry = `- [${finding2.severity}] ${finding2.title} - \`findings/${filename}\` - POC: \`${finding2.pocPath}\`
|
|
43320
43288
|
`;
|
|
@@ -43530,7 +43498,7 @@ Begin your analysis now.
|
|
|
43530
43498
|
// src/core/agent/pentestAgent/agent.ts
|
|
43531
43499
|
var execAsync2 = promisify2(exec2);
|
|
43532
43500
|
function runAgent(opts) {
|
|
43533
|
-
const { target, objective, model, onStepFinish, abortSignal } = opts;
|
|
43501
|
+
const { target, objective, model, onStepFinish, abortSignal, silent } = opts;
|
|
43534
43502
|
const session = opts.session || createSession(target, objective);
|
|
43535
43503
|
const pocsPath = join3(session.rootPath, "pocs");
|
|
43536
43504
|
if (!existsSync5(pocsPath)) {
|
|
@@ -43668,7 +43636,8 @@ Remember to follow a systematic methodology and explain your reasoning for each
|
|
|
43668
43636
|
stopWhen: stepCountIs(1e4),
|
|
43669
43637
|
toolChoice: "auto",
|
|
43670
43638
|
onStepFinish,
|
|
43671
|
-
abortSignal
|
|
43639
|
+
abortSignal,
|
|
43640
|
+
silent
|
|
43672
43641
|
});
|
|
43673
43642
|
streamResult.session = session;
|
|
43674
43643
|
return { streamResult, session };
|
package/build/index.js
CHANGED
|
@@ -71169,7 +71169,7 @@ function createSummarizationStream(messages, opts, model) {
|
|
|
71169
71169
|
}
|
|
71170
71170
|
|
|
71171
71171
|
// src/core/ai/ai.ts
|
|
71172
|
-
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model) {
|
|
71172
|
+
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model, silent) {
|
|
71173
71173
|
let wrappedStream = null;
|
|
71174
71174
|
const handler = {
|
|
71175
71175
|
get(target, prop) {
|
|
@@ -71194,13 +71194,17 @@ function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, mod
|
|
|
71194
71194
|
currentMessages = response.messages;
|
|
71195
71195
|
}
|
|
71196
71196
|
} catch (e) {}
|
|
71197
|
-
|
|
71197
|
+
if (!silent) {
|
|
71198
|
+
console.warn(`Context length error in wrapper, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
71199
|
+
}
|
|
71198
71200
|
const summarizationStream = createSummarizationStream(currentMessages, opts, model);
|
|
71199
71201
|
for await (const chunk of summarizationStream.fullStream) {
|
|
71200
71202
|
yield chunk;
|
|
71201
71203
|
}
|
|
71202
71204
|
} else {
|
|
71203
|
-
|
|
71205
|
+
if (!silent) {
|
|
71206
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
71207
|
+
}
|
|
71204
71208
|
throw error46;
|
|
71205
71209
|
}
|
|
71206
71210
|
}
|
|
@@ -71224,7 +71228,8 @@ function streamResponse(opts) {
|
|
|
71224
71228
|
tools,
|
|
71225
71229
|
onStepFinish,
|
|
71226
71230
|
abortSignal,
|
|
71227
|
-
activeTools
|
|
71231
|
+
activeTools,
|
|
71232
|
+
silent
|
|
71228
71233
|
} = opts;
|
|
71229
71234
|
const messagesContainer = { current: messages || [] };
|
|
71230
71235
|
const providerModel = getProviderModel(model);
|
|
@@ -71251,7 +71256,9 @@ function streamResponse(opts) {
|
|
|
71251
71256
|
error: error46
|
|
71252
71257
|
}) => {
|
|
71253
71258
|
try {
|
|
71254
|
-
|
|
71259
|
+
if (!silent) {
|
|
71260
|
+
console.log("Repairing tool call:", toolCall.toolName, "Error:", error46);
|
|
71261
|
+
}
|
|
71255
71262
|
const tool2 = tools2[toolCall.toolName];
|
|
71256
71263
|
if (!tool2 || !tool2.inputSchema) {
|
|
71257
71264
|
throw new Error(`Tool ${toolCall.toolName} not found or has no schema`);
|
|
@@ -71272,19 +71279,25 @@ function streamResponse(opts) {
|
|
|
71272
71279
|
});
|
|
71273
71280
|
return { ...toolCall, input: JSON.stringify(repairedArgs) };
|
|
71274
71281
|
} catch (repairError) {
|
|
71275
|
-
|
|
71282
|
+
if (!silent) {
|
|
71283
|
+
console.error("Error repairing tool call:", repairError.message);
|
|
71284
|
+
}
|
|
71276
71285
|
throw repairError;
|
|
71277
71286
|
}
|
|
71278
71287
|
}
|
|
71279
71288
|
});
|
|
71280
|
-
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel);
|
|
71289
|
+
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel, silent);
|
|
71281
71290
|
} catch (error46) {
|
|
71282
71291
|
const isContextLengthError = checkIfContextLengthError(error46);
|
|
71283
71292
|
if (isContextLengthError) {
|
|
71284
|
-
|
|
71293
|
+
if (!silent) {
|
|
71294
|
+
console.warn(`Context length error, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
71295
|
+
}
|
|
71285
71296
|
return createSummarizationStream(messagesContainer.current, opts, providerModel);
|
|
71286
71297
|
}
|
|
71287
|
-
|
|
71298
|
+
if (!silent) {
|
|
71299
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
71300
|
+
}
|
|
71288
71301
|
throw error46;
|
|
71289
71302
|
}
|
|
71290
71303
|
}
|
|
@@ -73379,54 +73392,9 @@ Create this POC, test it, then retry document_finding.`,
|
|
|
73379
73392
|
};
|
|
73380
73393
|
const safeTitle = finding2.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").substring(0, 50);
|
|
73381
73394
|
const findingId = `${timestamp.split("T")[0]}-${safeTitle}`;
|
|
73382
|
-
const filename = `${findingId}.
|
|
73395
|
+
const filename = `${findingId}.json`;
|
|
73383
73396
|
const filepath = join3(session.findingsPath, filename);
|
|
73384
|
-
|
|
73385
|
-
|
|
73386
|
-
**Severity:** ${finding2.severity}
|
|
73387
|
-
**Target:** ${session.target}
|
|
73388
|
-
**Date:** ${timestamp}
|
|
73389
|
-
**Session:** ${session.id}
|
|
73390
|
-
**POC:** \`${finding2.pocPath}\`
|
|
73391
|
-
|
|
73392
|
-
## Description
|
|
73393
|
-
|
|
73394
|
-
${finding2.description}
|
|
73395
|
-
|
|
73396
|
-
## Impact
|
|
73397
|
-
|
|
73398
|
-
${finding2.impact}
|
|
73399
|
-
|
|
73400
|
-
## Evidence
|
|
73401
|
-
|
|
73402
|
-
\`\`\`
|
|
73403
|
-
${finding2.evidence}
|
|
73404
|
-
\`\`\`
|
|
73405
|
-
|
|
73406
|
-
## Proof of Concept
|
|
73407
|
-
|
|
73408
|
-
A working POC script is available at: \`${finding2.pocPath}\`
|
|
73409
|
-
|
|
73410
|
-
To reproduce this vulnerability, run:
|
|
73411
|
-
\`\`\`bash
|
|
73412
|
-
cd ${session.rootPath}
|
|
73413
|
-
./${finding2.pocPath}
|
|
73414
|
-
\`\`\`
|
|
73415
|
-
|
|
73416
|
-
## Remediation
|
|
73417
|
-
|
|
73418
|
-
${finding2.remediation}
|
|
73419
|
-
|
|
73420
|
-
${finding2.references ? `## References
|
|
73421
|
-
|
|
73422
|
-
${finding2.references}` : ""}
|
|
73423
|
-
|
|
73424
|
-
---
|
|
73425
|
-
|
|
73426
|
-
*This finding was automatically documented by the Pensar penetration testing agent.*
|
|
73427
|
-
*POC verified and available at: ${finding2.pocPath}*
|
|
73428
|
-
`;
|
|
73429
|
-
writeFileSync3(filepath, markdown);
|
|
73397
|
+
writeFileSync3(filepath, JSON.stringify(findingWithMeta, null, 2));
|
|
73430
73398
|
const summaryPath = join3(session.rootPath, "findings-summary.md");
|
|
73431
73399
|
const summaryEntry = `- [${finding2.severity}] ${finding2.title} - \`findings/${filename}\` - POC: \`${finding2.pocPath}\`
|
|
73432
73400
|
`;
|
|
@@ -73642,7 +73610,7 @@ Begin your analysis now.
|
|
|
73642
73610
|
// src/core/agent/pentestAgent/agent.ts
|
|
73643
73611
|
var execAsync3 = promisify3(exec3);
|
|
73644
73612
|
function runAgent(opts) {
|
|
73645
|
-
const { target, objective, model, onStepFinish, abortSignal } = opts;
|
|
73613
|
+
const { target, objective, model, onStepFinish, abortSignal, silent } = opts;
|
|
73646
73614
|
const session = opts.session || createSession(target, objective);
|
|
73647
73615
|
const pocsPath = join4(session.rootPath, "pocs");
|
|
73648
73616
|
if (!existsSync9(pocsPath)) {
|
|
@@ -73780,7 +73748,8 @@ Remember to follow a systematic methodology and explain your reasoning for each
|
|
|
73780
73748
|
stopWhen: stepCountIs(1e4),
|
|
73781
73749
|
toolChoice: "auto",
|
|
73782
73750
|
onStepFinish,
|
|
73783
|
-
abortSignal
|
|
73751
|
+
abortSignal,
|
|
73752
|
+
silent
|
|
73784
73753
|
});
|
|
73785
73754
|
streamResult.session = session;
|
|
73786
73755
|
return { streamResult, session };
|
package/build/quicktest.js
CHANGED
|
@@ -39824,7 +39824,7 @@ function createSummarizationStream(messages, opts, model) {
|
|
|
39824
39824
|
}
|
|
39825
39825
|
|
|
39826
39826
|
// src/core/ai/ai.ts
|
|
39827
|
-
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model) {
|
|
39827
|
+
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model, silent) {
|
|
39828
39828
|
let wrappedStream = null;
|
|
39829
39829
|
const handler = {
|
|
39830
39830
|
get(target, prop) {
|
|
@@ -39849,13 +39849,17 @@ function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, mod
|
|
|
39849
39849
|
currentMessages = response.messages;
|
|
39850
39850
|
}
|
|
39851
39851
|
} catch (e) {}
|
|
39852
|
-
|
|
39852
|
+
if (!silent) {
|
|
39853
|
+
console.warn(`Context length error in wrapper, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39854
|
+
}
|
|
39853
39855
|
const summarizationStream = createSummarizationStream(currentMessages, opts, model);
|
|
39854
39856
|
for await (const chunk of summarizationStream.fullStream) {
|
|
39855
39857
|
yield chunk;
|
|
39856
39858
|
}
|
|
39857
39859
|
} else {
|
|
39858
|
-
|
|
39860
|
+
if (!silent) {
|
|
39861
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39862
|
+
}
|
|
39859
39863
|
throw error46;
|
|
39860
39864
|
}
|
|
39861
39865
|
}
|
|
@@ -39879,7 +39883,8 @@ function streamResponse(opts) {
|
|
|
39879
39883
|
tools,
|
|
39880
39884
|
onStepFinish,
|
|
39881
39885
|
abortSignal,
|
|
39882
|
-
activeTools
|
|
39886
|
+
activeTools,
|
|
39887
|
+
silent
|
|
39883
39888
|
} = opts;
|
|
39884
39889
|
const messagesContainer = { current: messages || [] };
|
|
39885
39890
|
const providerModel = getProviderModel(model);
|
|
@@ -39906,7 +39911,9 @@ function streamResponse(opts) {
|
|
|
39906
39911
|
error: error46
|
|
39907
39912
|
}) => {
|
|
39908
39913
|
try {
|
|
39909
|
-
|
|
39914
|
+
if (!silent) {
|
|
39915
|
+
console.log("Repairing tool call:", toolCall.toolName, "Error:", error46);
|
|
39916
|
+
}
|
|
39910
39917
|
const tool2 = tools2[toolCall.toolName];
|
|
39911
39918
|
if (!tool2 || !tool2.inputSchema) {
|
|
39912
39919
|
throw new Error(`Tool ${toolCall.toolName} not found or has no schema`);
|
|
@@ -39927,19 +39934,25 @@ function streamResponse(opts) {
|
|
|
39927
39934
|
});
|
|
39928
39935
|
return { ...toolCall, input: JSON.stringify(repairedArgs) };
|
|
39929
39936
|
} catch (repairError) {
|
|
39930
|
-
|
|
39937
|
+
if (!silent) {
|
|
39938
|
+
console.error("Error repairing tool call:", repairError.message);
|
|
39939
|
+
}
|
|
39931
39940
|
throw repairError;
|
|
39932
39941
|
}
|
|
39933
39942
|
}
|
|
39934
39943
|
});
|
|
39935
|
-
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel);
|
|
39944
|
+
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel, silent);
|
|
39936
39945
|
} catch (error46) {
|
|
39937
39946
|
const isContextLengthError = checkIfContextLengthError(error46);
|
|
39938
39947
|
if (isContextLengthError) {
|
|
39939
|
-
|
|
39948
|
+
if (!silent) {
|
|
39949
|
+
console.warn(`Context length error, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39950
|
+
}
|
|
39940
39951
|
return createSummarizationStream(messagesContainer.current, opts, providerModel);
|
|
39941
39952
|
}
|
|
39942
|
-
|
|
39953
|
+
if (!silent) {
|
|
39954
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39955
|
+
}
|
|
39943
39956
|
throw error46;
|
|
39944
39957
|
}
|
|
39945
39958
|
}
|
|
@@ -42013,54 +42026,9 @@ Create this POC, test it, then retry document_finding.`,
|
|
|
42013
42026
|
};
|
|
42014
42027
|
const safeTitle = finding2.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").substring(0, 50);
|
|
42015
42028
|
const findingId = `${timestamp.split("T")[0]}-${safeTitle}`;
|
|
42016
|
-
const filename = `${findingId}.
|
|
42029
|
+
const filename = `${findingId}.json`;
|
|
42017
42030
|
const filepath = join3(session.findingsPath, filename);
|
|
42018
|
-
|
|
42019
|
-
|
|
42020
|
-
**Severity:** ${finding2.severity}
|
|
42021
|
-
**Target:** ${session.target}
|
|
42022
|
-
**Date:** ${timestamp}
|
|
42023
|
-
**Session:** ${session.id}
|
|
42024
|
-
**POC:** \`${finding2.pocPath}\`
|
|
42025
|
-
|
|
42026
|
-
## Description
|
|
42027
|
-
|
|
42028
|
-
${finding2.description}
|
|
42029
|
-
|
|
42030
|
-
## Impact
|
|
42031
|
-
|
|
42032
|
-
${finding2.impact}
|
|
42033
|
-
|
|
42034
|
-
## Evidence
|
|
42035
|
-
|
|
42036
|
-
\`\`\`
|
|
42037
|
-
${finding2.evidence}
|
|
42038
|
-
\`\`\`
|
|
42039
|
-
|
|
42040
|
-
## Proof of Concept
|
|
42041
|
-
|
|
42042
|
-
A working POC script is available at: \`${finding2.pocPath}\`
|
|
42043
|
-
|
|
42044
|
-
To reproduce this vulnerability, run:
|
|
42045
|
-
\`\`\`bash
|
|
42046
|
-
cd ${session.rootPath}
|
|
42047
|
-
./${finding2.pocPath}
|
|
42048
|
-
\`\`\`
|
|
42049
|
-
|
|
42050
|
-
## Remediation
|
|
42051
|
-
|
|
42052
|
-
${finding2.remediation}
|
|
42053
|
-
|
|
42054
|
-
${finding2.references ? `## References
|
|
42055
|
-
|
|
42056
|
-
${finding2.references}` : ""}
|
|
42057
|
-
|
|
42058
|
-
---
|
|
42059
|
-
|
|
42060
|
-
*This finding was automatically documented by the Pensar penetration testing agent.*
|
|
42061
|
-
*POC verified and available at: ${finding2.pocPath}*
|
|
42062
|
-
`;
|
|
42063
|
-
writeFileSync3(filepath, markdown);
|
|
42031
|
+
writeFileSync3(filepath, JSON.stringify(findingWithMeta, null, 2));
|
|
42064
42032
|
const summaryPath = join3(session.rootPath, "findings-summary.md");
|
|
42065
42033
|
const summaryEntry = `- [${finding2.severity}] ${finding2.title} - \`findings/${filename}\` - POC: \`${finding2.pocPath}\`
|
|
42066
42034
|
`;
|
|
@@ -42276,7 +42244,7 @@ Begin your analysis now.
|
|
|
42276
42244
|
// src/core/agent/pentestAgent/agent.ts
|
|
42277
42245
|
var execAsync3 = promisify3(exec3);
|
|
42278
42246
|
function runAgent(opts) {
|
|
42279
|
-
const { target, objective, model, onStepFinish, abortSignal } = opts;
|
|
42247
|
+
const { target, objective, model, onStepFinish, abortSignal, silent } = opts;
|
|
42280
42248
|
const session = opts.session || createSession(target, objective);
|
|
42281
42249
|
const pocsPath = join4(session.rootPath, "pocs");
|
|
42282
42250
|
if (!existsSync6(pocsPath)) {
|
|
@@ -42414,7 +42382,8 @@ Remember to follow a systematic methodology and explain your reasoning for each
|
|
|
42414
42382
|
stopWhen: stepCountIs(1e4),
|
|
42415
42383
|
toolChoice: "auto",
|
|
42416
42384
|
onStepFinish,
|
|
42417
|
-
abortSignal
|
|
42385
|
+
abortSignal,
|
|
42386
|
+
silent
|
|
42418
42387
|
});
|
|
42419
42388
|
streamResult.session = session;
|
|
42420
42389
|
return { streamResult, session };
|
package/build/swarm.js
CHANGED
|
@@ -39824,7 +39824,7 @@ function createSummarizationStream(messages, opts, model) {
|
|
|
39824
39824
|
}
|
|
39825
39825
|
|
|
39826
39826
|
// src/core/ai/ai.ts
|
|
39827
|
-
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model) {
|
|
39827
|
+
function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, model, silent) {
|
|
39828
39828
|
let wrappedStream = null;
|
|
39829
39829
|
const handler = {
|
|
39830
39830
|
get(target, prop) {
|
|
@@ -39849,13 +39849,17 @@ function wrapStreamWithErrorHandler(originalStream, messagesContainer, opts, mod
|
|
|
39849
39849
|
currentMessages = response.messages;
|
|
39850
39850
|
}
|
|
39851
39851
|
} catch (e) {}
|
|
39852
|
-
|
|
39852
|
+
if (!silent) {
|
|
39853
|
+
console.warn(`Context length error in wrapper, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39854
|
+
}
|
|
39853
39855
|
const summarizationStream = createSummarizationStream(currentMessages, opts, model);
|
|
39854
39856
|
for await (const chunk of summarizationStream.fullStream) {
|
|
39855
39857
|
yield chunk;
|
|
39856
39858
|
}
|
|
39857
39859
|
} else {
|
|
39858
|
-
|
|
39860
|
+
if (!silent) {
|
|
39861
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39862
|
+
}
|
|
39859
39863
|
throw error46;
|
|
39860
39864
|
}
|
|
39861
39865
|
}
|
|
@@ -39879,7 +39883,8 @@ function streamResponse(opts) {
|
|
|
39879
39883
|
tools,
|
|
39880
39884
|
onStepFinish,
|
|
39881
39885
|
abortSignal,
|
|
39882
|
-
activeTools
|
|
39886
|
+
activeTools,
|
|
39887
|
+
silent
|
|
39883
39888
|
} = opts;
|
|
39884
39889
|
const messagesContainer = { current: messages || [] };
|
|
39885
39890
|
const providerModel = getProviderModel(model);
|
|
@@ -39906,7 +39911,9 @@ function streamResponse(opts) {
|
|
|
39906
39911
|
error: error46
|
|
39907
39912
|
}) => {
|
|
39908
39913
|
try {
|
|
39909
|
-
|
|
39914
|
+
if (!silent) {
|
|
39915
|
+
console.log("Repairing tool call:", toolCall.toolName, "Error:", error46);
|
|
39916
|
+
}
|
|
39910
39917
|
const tool2 = tools2[toolCall.toolName];
|
|
39911
39918
|
if (!tool2 || !tool2.inputSchema) {
|
|
39912
39919
|
throw new Error(`Tool ${toolCall.toolName} not found or has no schema`);
|
|
@@ -39927,19 +39934,25 @@ function streamResponse(opts) {
|
|
|
39927
39934
|
});
|
|
39928
39935
|
return { ...toolCall, input: JSON.stringify(repairedArgs) };
|
|
39929
39936
|
} catch (repairError) {
|
|
39930
|
-
|
|
39937
|
+
if (!silent) {
|
|
39938
|
+
console.error("Error repairing tool call:", repairError.message);
|
|
39939
|
+
}
|
|
39931
39940
|
throw repairError;
|
|
39932
39941
|
}
|
|
39933
39942
|
}
|
|
39934
39943
|
});
|
|
39935
|
-
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel);
|
|
39944
|
+
return wrapStreamWithErrorHandler(response, messagesContainer, opts, providerModel, silent);
|
|
39936
39945
|
} catch (error46) {
|
|
39937
39946
|
const isContextLengthError = checkIfContextLengthError(error46);
|
|
39938
39947
|
if (isContextLengthError) {
|
|
39939
|
-
|
|
39948
|
+
if (!silent) {
|
|
39949
|
+
console.warn(`Context length error, summarizing ${messagesContainer.current.length} messages: `, error46.message);
|
|
39950
|
+
}
|
|
39940
39951
|
return createSummarizationStream(messagesContainer.current, opts, providerModel);
|
|
39941
39952
|
}
|
|
39942
|
-
|
|
39953
|
+
if (!silent) {
|
|
39954
|
+
console.error("Non-context length error, re-throwing", error46.message);
|
|
39955
|
+
}
|
|
39943
39956
|
throw error46;
|
|
39944
39957
|
}
|
|
39945
39958
|
}
|
|
@@ -42013,54 +42026,9 @@ Create this POC, test it, then retry document_finding.`,
|
|
|
42013
42026
|
};
|
|
42014
42027
|
const safeTitle = finding2.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").substring(0, 50);
|
|
42015
42028
|
const findingId = `${timestamp.split("T")[0]}-${safeTitle}`;
|
|
42016
|
-
const filename = `${findingId}.
|
|
42029
|
+
const filename = `${findingId}.json`;
|
|
42017
42030
|
const filepath = join3(session.findingsPath, filename);
|
|
42018
|
-
|
|
42019
|
-
|
|
42020
|
-
**Severity:** ${finding2.severity}
|
|
42021
|
-
**Target:** ${session.target}
|
|
42022
|
-
**Date:** ${timestamp}
|
|
42023
|
-
**Session:** ${session.id}
|
|
42024
|
-
**POC:** \`${finding2.pocPath}\`
|
|
42025
|
-
|
|
42026
|
-
## Description
|
|
42027
|
-
|
|
42028
|
-
${finding2.description}
|
|
42029
|
-
|
|
42030
|
-
## Impact
|
|
42031
|
-
|
|
42032
|
-
${finding2.impact}
|
|
42033
|
-
|
|
42034
|
-
## Evidence
|
|
42035
|
-
|
|
42036
|
-
\`\`\`
|
|
42037
|
-
${finding2.evidence}
|
|
42038
|
-
\`\`\`
|
|
42039
|
-
|
|
42040
|
-
## Proof of Concept
|
|
42041
|
-
|
|
42042
|
-
A working POC script is available at: \`${finding2.pocPath}\`
|
|
42043
|
-
|
|
42044
|
-
To reproduce this vulnerability, run:
|
|
42045
|
-
\`\`\`bash
|
|
42046
|
-
cd ${session.rootPath}
|
|
42047
|
-
./${finding2.pocPath}
|
|
42048
|
-
\`\`\`
|
|
42049
|
-
|
|
42050
|
-
## Remediation
|
|
42051
|
-
|
|
42052
|
-
${finding2.remediation}
|
|
42053
|
-
|
|
42054
|
-
${finding2.references ? `## References
|
|
42055
|
-
|
|
42056
|
-
${finding2.references}` : ""}
|
|
42057
|
-
|
|
42058
|
-
---
|
|
42059
|
-
|
|
42060
|
-
*This finding was automatically documented by the Pensar penetration testing agent.*
|
|
42061
|
-
*POC verified and available at: ${finding2.pocPath}*
|
|
42062
|
-
`;
|
|
42063
|
-
writeFileSync3(filepath, markdown);
|
|
42031
|
+
writeFileSync3(filepath, JSON.stringify(findingWithMeta, null, 2));
|
|
42064
42032
|
const summaryPath = join3(session.rootPath, "findings-summary.md");
|
|
42065
42033
|
const summaryEntry = `- [${finding2.severity}] ${finding2.title} - \`findings/${filename}\` - POC: \`${finding2.pocPath}\`
|
|
42066
42034
|
`;
|
|
@@ -42276,7 +42244,7 @@ Begin your analysis now.
|
|
|
42276
42244
|
// src/core/agent/pentestAgent/agent.ts
|
|
42277
42245
|
var execAsync3 = promisify3(exec3);
|
|
42278
42246
|
function runAgent(opts) {
|
|
42279
|
-
const { target, objective, model, onStepFinish, abortSignal } = opts;
|
|
42247
|
+
const { target, objective, model, onStepFinish, abortSignal, silent } = opts;
|
|
42280
42248
|
const session = opts.session || createSession(target, objective);
|
|
42281
42249
|
const pocsPath = join4(session.rootPath, "pocs");
|
|
42282
42250
|
if (!existsSync6(pocsPath)) {
|
|
@@ -42414,7 +42382,8 @@ Remember to follow a systematic methodology and explain your reasoning for each
|
|
|
42414
42382
|
stopWhen: stepCountIs(1e4),
|
|
42415
42383
|
toolChoice: "auto",
|
|
42416
42384
|
onStepFinish,
|
|
42417
|
-
abortSignal
|
|
42385
|
+
abortSignal,
|
|
42386
|
+
silent
|
|
42418
42387
|
});
|
|
42419
42388
|
streamResult.session = session;
|
|
42420
42389
|
return { streamResult, session };
|
|
@@ -42476,7 +42445,8 @@ async function swarm(options) {
|
|
|
42476
42445
|
session,
|
|
42477
42446
|
target: target.target,
|
|
42478
42447
|
objective: target.objective,
|
|
42479
|
-
model
|
|
42448
|
+
model,
|
|
42449
|
+
silent
|
|
42480
42450
|
});
|
|
42481
42451
|
for await (const delta of streamResult.fullStream) {
|
|
42482
42452
|
if (delta.type === "text-delta") {} else if (delta.type === "tool-call") {} else if (delta.type === "tool-result") {}
|