Files
html/api/evomaster-api.php
2026-04-12 22:57:03 +02:00

42 lines
1.5 KiB
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$target = $_GET['target'] ?? '';
$action = $_GET['action'] ?? 'generate';
switch ($action) {
case 'generate':
if (empty($target)) {
echo json_encode(['error' => 'target API URL required']);
exit;
}
// Generate test cases using curl-based probing
$endpoints = [];
$methods = ['GET', 'POST', 'PUT', 'DELETE'];
foreach ($methods as $m) {
$ch = curl_init($target);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $m,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_NOBODY => $m === 'DELETE',
]);
$resp = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$endpoints[] = ['method' => $m, 'status' => $code, 'size' => strlen($resp)];
}
echo json_encode(['ok' => true, 'target' => $target, 'tests_generated' => count($endpoints), 'results' => $endpoints, 'engine' => 'EvoMaster-lite']);
break;
case 'status':
echo json_encode(['ok' => true, 'engine' => 'EvoMaster', 'capabilities' => [
'api_fuzzing' => true,
'regression_tests' => true,
'evolutionary_algo' => true,
'coverage_expansion' => true
]]);
break;
default:
echo json_encode(['error' => 'action: generate|status']);
}