From 02345fadae1c82107fa4dfd2ffd2ad89ba9804ef Mon Sep 17 00:00:00 2001 From: Bappa Mandal Date: Sat, 27 Jun 2026 07:33:14 +0530 Subject: [PATCH] Avoid secret scan file race --- scripts/check-secrets.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/check-secrets.mjs b/scripts/check-secrets.mjs index e9da22c..ae1b34b 100644 --- a/scripts/check-secrets.mjs +++ b/scripts/check-secrets.mjs @@ -1,4 +1,4 @@ -import { readFileSync, readdirSync, statSync } from "node:fs"; +import { readFileSync, readdirSync } from "node:fs"; import { join, relative } from "node:path"; import { fileURLToPath } from "node:url"; import { dirname } from "node:path"; @@ -42,12 +42,11 @@ function walk(dir) { continue; } - const stats = statSync(fullPath); - if (stats.size > 1024 * 1024) { + const buffer = readFileSync(fullPath); + if (buffer.length > 1024 * 1024) { continue; } - const buffer = readFileSync(fullPath); if (!isProbablyText(buffer)) { continue; }