Tighten bot probe regex and React Flight Sentry filter
- Remove .xml, .log, .git from bot probe blocklist to avoid false positives on legitimate routes (e.g. /sitemap.xml) - Tighten React Flight error filter from broad string match to precise wire-format pattern (/\$\d+:[a-z]/) to avoid swallowing real errors - Remove redundant URL check from beforeSend (ignoreErrors already covers it) - Fix missing newline at end of instrument.server.mjs https://claude.ai/code/session_01Y5Ca6oxd5zyyM89acmogf7
This commit is contained in:
parent
3f5b19d4ba
commit
2429fa06d5
2 changed files with 3 additions and 6 deletions
|
|
@ -12,12 +12,9 @@ Sentry.init({
|
|||
/No route matches URL ".*\/(wp-admin|wp-login|phpmyadmin|xmlrpc)"/i,
|
||||
],
|
||||
beforeSend(event) {
|
||||
const url = event.request?.url ?? "";
|
||||
const msg = event.exception?.values?.[0]?.value ?? "";
|
||||
// Drop React Flight protocol probe errors (e.g. $1:aa:aa in multipart body)
|
||||
if (msg.includes("$1:")) return null;
|
||||
// Belt-and-suspenders: drop any remaining bot probe URL errors
|
||||
if (/\.(php|env|htaccess|xml|aspx|bak|sql)$|wp-admin|phpmyadmin/i.test(url)) return null;
|
||||
if (/\$\d+:[a-z]/.test(msg)) return null;
|
||||
return event;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ app.use((_, __, next) => DatabaseContext.run(db, next));
|
|||
|
||||
// Block common bot probe paths before React Router (and Sentry) see them
|
||||
const BOT_PROBE_RE =
|
||||
/\.(php|env|git|htaccess|xml|aspx|asp|jsp|config|bak|sql|ini|log|swp|DS_Store)$|^\/(wp-admin|wp-login|phpmyadmin|xmlrpc|server-status|cgi-bin|shell|cmd|console|actuator)(\/|$)/i;
|
||||
/\.(php|env|htaccess|aspx|asp|jsp|config|bak|sql|ini|swp|DS_Store)$|^\/(wp-admin|wp-login|phpmyadmin|xmlrpc|server-status|cgi-bin|shell|cmd|console|actuator)(\/|$)/i;
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (BOT_PROBE_RE.test(req.path)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue