forked from FWS/FWS-TEMPLATE-Website-OnePage
feat(api): remove size and rate limits from the bug report API
The API is consumed by curl/scripts that need to push full installation logs, but field truncation (150k chars) and a 25-per-hour IP cap were rejecting or silently cutting those payloads. Discord log chunks are now streamed instead of being built in memory, so oversized logs no longer blow up the notifier.
This commit is contained in:
3 files changed
+46
-49
No files matched your search
+15
-14
@@ -5,6 +5,10 @@
|
||||
* POST https://fwslinux.fr/api/bugs.php (JSON ou formulaire)
|
||||
* GET https://fwslinux.fr/api/bugs.php (petite page de test dans le navigateur)
|
||||
*
|
||||
* Aucun plafond de taille ni de débit : l'API est faite pour curl/scripts
|
||||
* (envoi de logs volumineux) et les seuls garde-fous restants sont le champ
|
||||
* piège « website » et le contrôle de contenu vide.
|
||||
*
|
||||
* CORS ouvert : on accepte les requêtes de n'importe quelle origine
|
||||
* (curl, app d'installation, script, site…).
|
||||
*/
|
||||
@@ -81,14 +85,16 @@ $fields = [
|
||||
'logs' => strval($data['logs'] ?? $data['log'] ?? $data['journal'] ?? ''),
|
||||
];
|
||||
|
||||
$title = mb_substr(trim($fields['title']), 0, 200);
|
||||
$description = mb_substr(trim($fields['description']), 0, 20000);
|
||||
$logs = mb_substr(trim($fields['logs']), 0, 150000);
|
||||
$app = mb_substr(trim($fields['app']), 0, 100);
|
||||
$version = mb_substr(trim($fields['version']), 0, 100);
|
||||
$email = mb_substr(trim($fields['email']), 0, 200);
|
||||
$systemInfo = mb_substr(trim($fields['system_info']), 0, 4000);
|
||||
$type = mb_substr(trim($fields['type']), 0, 50);
|
||||
/* Aucun plafond sur les champs : les logs d'installation peuvent peser
|
||||
très lourd et un client curl doit pouvoir tout envoyer. */
|
||||
$title = trim($fields['title']);
|
||||
$description = trim($fields['description']);
|
||||
$logs = trim($fields['logs']);
|
||||
$app = trim($fields['app']);
|
||||
$version = trim($fields['version']);
|
||||
$email = trim($fields['email']);
|
||||
$systemInfo = trim($fields['system_info']);
|
||||
$type = trim($fields['type']);
|
||||
|
||||
/* Un signalement doit contenir au moins un peu de contenu utile */
|
||||
if ($title === '' && $description === '' && $logs === '') {
|
||||
@@ -100,7 +106,7 @@ if ($title === '' && $description === '' && $logs === '') {
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Anti-flood léger : 25 signalements / heure / IP */
|
||||
/* Connexion à la base (aucun anti-flood : l'API est ouverte par design) */
|
||||
try {
|
||||
$pdo = fws_bugs_db();
|
||||
} catch (Throwable $e) {
|
||||
@@ -111,11 +117,6 @@ try {
|
||||
}
|
||||
|
||||
$ip = fws_bugs_client_ip();
|
||||
if (fws_bugs_count_recent_for_ip($pdo, $ip) >= 25) {
|
||||
http_response_code(429);
|
||||
echo json_encode(['ok' => false, 'error' => 'Trop de signalements depuis cette adresse, réessayez plus tard.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Insertion — l'id repart de 1 et saute ceux déjà pris */
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user