fase(6): fuzzing module complete
This commit is contained in:
50
dist/modules/fuzzing/infrastructure/http/FuzzingController.js
vendored
Normal file
50
dist/modules/fuzzing/infrastructure/http/FuzzingController.js
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createFuzzingRouter = createFuzzingRouter;
|
||||
const express_1 = require("express");
|
||||
function createFuzzingRouter(deps) {
|
||||
const router = (0, express_1.Router)();
|
||||
// POST /api/fuzz/run — trigger fuzzing for a given state
|
||||
router.post('/run', async (req, res) => {
|
||||
const { crawlSessionId, intensity, seed, state } = req.body;
|
||||
if (!crawlSessionId || !state) {
|
||||
res.status(400).json({ error: 'crawlSessionId and state are required' });
|
||||
return;
|
||||
}
|
||||
const result = await deps.runFuzz.execute({
|
||||
crawlSessionId,
|
||||
intensity: intensity ?? 'low',
|
||||
seed: seed ?? Date.now(),
|
||||
state,
|
||||
});
|
||||
if (!result.ok) {
|
||||
res.status(422).json({ error: result.error });
|
||||
return;
|
||||
}
|
||||
res.status(201).json(result.value);
|
||||
});
|
||||
// GET /api/fuzz/sessions/:id — get fuzz session
|
||||
router.get('/sessions/:id', async (req, res) => {
|
||||
const sessionId = req.params['id'];
|
||||
const session = await deps.repository.findById(sessionId);
|
||||
if (!session) {
|
||||
res.status(404).json({ error: 'Fuzz session not found' });
|
||||
return;
|
||||
}
|
||||
res.json(toDTO(session));
|
||||
});
|
||||
return router;
|
||||
}
|
||||
function toDTO(s) {
|
||||
return {
|
||||
id: s.id.toString(),
|
||||
crawlSessionId: s.crawlSessionId,
|
||||
intensity: s.intensity.value,
|
||||
seed: s.seed.value,
|
||||
status: s.status,
|
||||
actionsExecuted: s.actionsExecuted,
|
||||
vulnerabilitiesFound: s.vulnerabilitiesFound,
|
||||
startedAt: s.startedAt.toISOString(),
|
||||
completedAt: s.completedAt?.toISOString() ?? null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user