mirror of
git://f0xx.org/ac/ac-be-builder
synced 2026-07-29 04:18:20 +03:00
feat(builder): shared nav shell, fail notify, sanitizer wiring
Signed-off-by: Anton Afanasyeu <a.afanasieff@gmail.com>
This commit is contained in:
28
src/BuildErrorSanitizer.php
Normal file
28
src/BuildErrorSanitizer.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** Strip URLs, paths with secrets, and credential-like tokens from user-visible build errors. */
|
||||
final class BuildErrorSanitizer {
|
||||
public static function sanitize(string $message): string {
|
||||
if ($message === '') {
|
||||
return '';
|
||||
}
|
||||
$out = $message;
|
||||
$out = preg_replace('#https?://[^\s\'"<>]+#i', '***', $out) ?? $out;
|
||||
$out = preg_replace('#git://[^\s\'"<>]+#i', '***', $out) ?? $out;
|
||||
$out = preg_replace('#ssh://[^\s\'"<>]+#i', '***', $out) ?? $out;
|
||||
$out = preg_replace(
|
||||
'/\b(password|passwd|pass|token|secret|api[_-]?key|bearer|authorization)\s*[:=]\s*\S+/i',
|
||||
'$1=***',
|
||||
$out
|
||||
) ?? $out;
|
||||
$out = preg_replace(
|
||||
'/(?:\/[^\s]+)?\/(?:\.env|credentials(?:\.json)?|secrets?\.(?:json|ya?ml|env))[^\s]*/i',
|
||||
'***',
|
||||
$out
|
||||
) ?? $out;
|
||||
$out = preg_replace('#/var/www/[^\s\'"]+#', '***', $out) ?? $out;
|
||||
$out = preg_replace('#/home/[^\s\'"]+#', '***', $out) ?? $out;
|
||||
return trim(preg_replace('/\s{2,}/', ' ', $out) ?? $out);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user