40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.RunFuzzCommand = void 0;
|
|
const Result_1 = require("../../../../shared/domain/Result");
|
|
const FuzzSession_1 = require("../../domain/entities/FuzzSession");
|
|
class RunFuzzCommand {
|
|
constructor(fuzzerEngine, repository, eventBus) {
|
|
this.fuzzerEngine = fuzzerEngine;
|
|
this.repository = repository;
|
|
this.eventBus = eventBus;
|
|
}
|
|
async execute(request) {
|
|
const sessionResult = FuzzSession_1.FuzzSession.create({
|
|
crawlSessionId: request.crawlSessionId,
|
|
intensity: request.intensity,
|
|
seed: request.seed,
|
|
});
|
|
if (!sessionResult.ok) {
|
|
return (0, Result_1.Err)(sessionResult.error);
|
|
}
|
|
const session = sessionResult.value;
|
|
await this.repository.save(session);
|
|
const actions = this.fuzzerEngine.generateFuzzActions(request.state.domSnapshot, request.state);
|
|
for (const _action of actions) {
|
|
session.incrementActions();
|
|
}
|
|
session.complete();
|
|
await this.repository.update(session);
|
|
for (const event of session.domainEvents) {
|
|
await this.eventBus.publish(event);
|
|
}
|
|
session.clearEvents();
|
|
return (0, Result_1.Ok)({
|
|
fuzzSessionId: session.id.toString(),
|
|
actionsGenerated: actions.length,
|
|
});
|
|
}
|
|
}
|
|
exports.RunFuzzCommand = RunFuzzCommand;
|