From 6597765bb75cfd8fc713bfb6f70d1423d3fb45a7 Mon Sep 17 00:00:00 2001 From: Abhishek Hiremath <131762197+Abhi-DevHub@users.noreply.github.com> Date: Tue, 21 Jul 2026 22:56:14 +0530 Subject: [PATCH 1/6] fix: add 's' unit to sleep-polling-loop regex so 'sleep 30s' is detected The regex alternation (m|h|d)? omitted s, so the trailing \b word boundary failed between (cherry picked from commit aa2900f49273b80fc73a5c1f74eacdbef22bf536) --- __tests__/audit/detectors.test.ts | 3 +++ src/audit/detectors/sleep-polling-loop.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/__tests__/audit/detectors.test.ts b/__tests__/audit/detectors.test.ts index 0df1aef5e..600e50165 100644 --- a/__tests__/audit/detectors.test.ts +++ b/__tests__/audit/detectors.test.ts @@ -108,6 +108,9 @@ describe("sleep-polling-loop", () => { sleepPollingLoop.detect(bash("while true; do echo x; sleep 5; done"), {}), ).not.toBeNull(); }); + it("matches `sleep 30s`", () => { + expect(sleepPollingLoop.detect(bash("sleep 30s"), {})).not.toBeNull(); + }); it("does not match `sleep 1`", () => { expect(sleepPollingLoop.detect(bash("sleep 1"), {})).toBeNull(); }); diff --git a/src/audit/detectors/sleep-polling-loop.ts b/src/audit/detectors/sleep-polling-loop.ts index c701f0f88..248dadd26 100644 --- a/src/audit/detectors/sleep-polling-loop.ts +++ b/src/audit/detectors/sleep-polling-loop.ts @@ -20,7 +20,7 @@ export const sleepPollingLoop: Detector = { return { example: cmd.replace(/\s+/g, " ").trim().slice(0, 160) }; } // Standalone long sleep. parseFloat so `sleep 0.5m` (= 30s) isn't dropped. - const match = /\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/.exec(cmd); + const match = /\bsleep\s+(\d+(?:\.\d+)?)(s|m|h|d)?\b/.exec(cmd); if (match) { const n = parseFloat(match[1]); const unit = match[2] ?? "s"; From 1205be35c6ef5945059037e74c70d7c065321b11 Mon Sep 17 00:00:00 2001 From: lakshya-dhariwal Date: Sun, 27 Sep 2026 19:17:46 +0530 Subject: [PATCH 2/6] fix(audit): detect explicit-seconds form sleep 30s in sleep-polling-loop (#522) (cherry picked from commit 303bcccd897b6d6ce6c375781241a90662e45710) --- __tests__/audit/detectors.test.ts | 9 +++++++++ src/audit/detectors/sleep-polling-loop.ts | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/__tests__/audit/detectors.test.ts b/__tests__/audit/detectors.test.ts index 600e50165..c662d82b1 100644 --- a/__tests__/audit/detectors.test.ts +++ b/__tests__/audit/detectors.test.ts @@ -100,6 +100,15 @@ describe("sleep-polling-loop", () => { it("matches `sleep 60`", () => { expect(sleepPollingLoop.detect(bash("sleep 60"), {})).not.toBeNull(); }); + it("matches `sleep 30s` - the explicit-seconds form the regex used to drop", () => { + expect(sleepPollingLoop.detect(bash("sleep 30s"), {})).not.toBeNull(); + }); + it("matches `sleep 45s`", () => { + expect(sleepPollingLoop.detect(bash("sleep 45s"), {})).not.toBeNull(); + }); + it("still does not match `sleep 1s`", () => { + expect(sleepPollingLoop.detect(bash("sleep 1s"), {})).toBeNull(); + }); it("matches `sleep 5m`", () => { expect(sleepPollingLoop.detect(bash("sleep 5m"), {})).not.toBeNull(); }); diff --git a/src/audit/detectors/sleep-polling-loop.ts b/src/audit/detectors/sleep-polling-loop.ts index 248dadd26..e8b34de87 100644 --- a/src/audit/detectors/sleep-polling-loop.ts +++ b/src/audit/detectors/sleep-polling-loop.ts @@ -19,7 +19,9 @@ export const sleepPollingLoop: Detector = { if (/\bwhile\b[\s\S]*?\bsleep\b[\s\S]*?\bdone\b/.test(cmd)) { return { example: cmd.replace(/\s+/g, " ").trim().slice(0, 160) }; } - // Standalone long sleep. parseFloat so `sleep 0.5m` (= 30s) isn't dropped. + // Standalone long sleep. parseFloat so `sleep 0.5m` (= 30s) isn't dropped; + // the unit group includes `s` so the common explicit form `sleep 30s` matches + // (the trailing \b used to fail on `0s`, dropping the whole match). const match = /\bsleep\s+(\d+(?:\.\d+)?)(s|m|h|d)?\b/.exec(cmd); if (match) { const n = parseFloat(match[1]); From 9e89499e3e0b6bbb3e45a1c8a00cd670f87f7f8e Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Mon, 30 Nov 2026 17:18:18 +0530 Subject: [PATCH 3/6] [audit] Cover every sleep-polling-loop unit and drop a duplicate test #588 and #845 each added a `sleep 30s` case; keep #845's, which names the form the old regex dropped. Add the cases neither covered: the 30-second threshold in seconds (29s), `30s` followed by another command, decimal minutes on either side of the threshold (0.5m, 0.4m), the h and d units, and `sleep 30sec`, which sleep rejects and the detector must not count. Co-Authored-By: Claude Opus 5.5 --- __tests__/audit/detectors.test.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/__tests__/audit/detectors.test.ts b/__tests__/audit/detectors.test.ts index c662d82b1..5164fd31b 100644 --- a/__tests__/audit/detectors.test.ts +++ b/__tests__/audit/detectors.test.ts @@ -109,17 +109,33 @@ describe("sleep-polling-loop", () => { it("still does not match `sleep 1s`", () => { expect(sleepPollingLoop.detect(bash("sleep 1s"), {})).toBeNull(); }); + it("does not match `sleep 29s`, one second under the threshold", () => { + expect(sleepPollingLoop.detect(bash("sleep 29s"), {})).toBeNull(); + }); + it("matches `sleep 30s` followed by another command", () => { + expect(sleepPollingLoop.detect(bash("sleep 30s && npm test"), {})).not.toBeNull(); + }); + it("does not match `sleep 30sec`, which is not a unit sleep accepts", () => { + expect(sleepPollingLoop.detect(bash("sleep 30sec"), {})).toBeNull(); + }); it("matches `sleep 5m`", () => { expect(sleepPollingLoop.detect(bash("sleep 5m"), {})).not.toBeNull(); }); + it("matches `sleep 0.5m` (30 seconds)", () => { + expect(sleepPollingLoop.detect(bash("sleep 0.5m"), {})).not.toBeNull(); + }); + it("does not match `sleep 0.4m` (24 seconds)", () => { + expect(sleepPollingLoop.detect(bash("sleep 0.4m"), {})).toBeNull(); + }); + it("matches `sleep 2h` and `sleep 1d`", () => { + expect(sleepPollingLoop.detect(bash("sleep 2h"), {})).not.toBeNull(); + expect(sleepPollingLoop.detect(bash("sleep 1d"), {})).not.toBeNull(); + }); it("matches while-sleep loop", () => { expect( sleepPollingLoop.detect(bash("while true; do echo x; sleep 5; done"), {}), ).not.toBeNull(); }); - it("matches `sleep 30s`", () => { - expect(sleepPollingLoop.detect(bash("sleep 30s"), {})).not.toBeNull(); - }); it("does not match `sleep 1`", () => { expect(sleepPollingLoop.detect(bash("sleep 1"), {})).toBeNull(); }); From d5b0bbc41c9d770cd4168407dd0023d62b405204 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Mon, 30 Nov 2026 17:19:09 +0530 Subject: [PATCH 4/6] [audit] CHANGELOG entry for the sleep 30s detector fix Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7678d21d0..ee7b32e02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Drop the `skills` submodule and its daily Dependabot `gitsubmodule` entry. Nothing in this repo read it, nor did the npm package or any workflow, and the job in `FailproofAI/skills` that kept it current failed on every merge once the version-bot App was gone. The skills reach users through `npx skills add FailproofAI/skills`, which this pin never fed (#1075) - Delete `sync-fp-cloud-cli-skill.yml` and `sync-failproofai-sdk-skill.yml`, red on every run since August because the `SKILLS_SYNC_PAT` they pushed to `FailproofAI/skills` with was never created; that repo now pulls both skills from this public one with its own token, so nothing here holds a credential that writes to it. The fp-cloud-cli skill's description is cut from 1118 to 995 characters, under the 1024 that the skills repo's validator enforces and past which Copilot drops a skill (#1068) +- The audit's `sleep-polling-loop` detector now counts `sleep 30s`, the explicit-seconds form agents use most, which its regex used to drop; cached transcripts are re-scanned once on the next audit, so those already in history are counted too (#1100, from #588, #845, fixes #522) - Add a global `--no-color` flag, the same as `NO_COLOR=1`, accepted before or after any command; `failproofai policies` already honors `NO_COLOR` (#1067, from #695, #700, #848, fixes #688) - CI: the contributor-welcome workflow no longer tries to approve Dependabot pull requests. GitHub refuses a workflow approval while "Allow GitHub Actions to create and approve pull requests" is off, so every Dependabot PR got a failed run, and with it on the approval would count as the one review `main` requires. Dependency updates are reviewed by a person; the workflow drops `pull-requests: write` (#1049) From e5134254153319ce098d34ad50ef9b0261f1b150 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Mon, 30 Nov 2026 17:27:30 +0530 Subject: [PATCH 5/6] [audit] CHANGELOG: drop an unmeasured "most used" claim Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee7b32e02..1fb74b5af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Drop the `skills` submodule and its daily Dependabot `gitsubmodule` entry. Nothing in this repo read it, nor did the npm package or any workflow, and the job in `FailproofAI/skills` that kept it current failed on every merge once the version-bot App was gone. The skills reach users through `npx skills add FailproofAI/skills`, which this pin never fed (#1075) - Delete `sync-fp-cloud-cli-skill.yml` and `sync-failproofai-sdk-skill.yml`, red on every run since August because the `SKILLS_SYNC_PAT` they pushed to `FailproofAI/skills` with was never created; that repo now pulls both skills from this public one with its own token, so nothing here holds a credential that writes to it. The fp-cloud-cli skill's description is cut from 1118 to 995 characters, under the 1024 that the skills repo's validator enforces and past which Copilot drops a skill (#1068) -- The audit's `sleep-polling-loop` detector now counts `sleep 30s`, the explicit-seconds form agents use most, which its regex used to drop; cached transcripts are re-scanned once on the next audit, so those already in history are counted too (#1100, from #588, #845, fixes #522) +- The audit's `sleep-polling-loop` detector now counts the explicit-seconds form `sleep 30s`, which its regex used to drop; cached transcripts are re-scanned once on the next audit, so those already in history are counted too (#1100, from #588, #845, fixes #522) - Add a global `--no-color` flag, the same as `NO_COLOR=1`, accepted before or after any command; `failproofai policies` already honors `NO_COLOR` (#1067, from #695, #700, #848, fixes #688) - CI: the contributor-welcome workflow no longer tries to approve Dependabot pull requests. GitHub refuses a workflow approval while "Allow GitHub Actions to create and approve pull requests" is off, so every Dependabot PR got a failed run, and with it on the approval would count as the one review `main` requires. Dependency updates are reviewed by a person; the workflow drops `pull-requests: write` (#1049) From bfec3631f493faf188cc4ce08452a60cd26a51ad Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Mon, 30 Nov 2026 17:29:26 +0530 Subject: [PATCH 6/6] [audit] Check every sleep in a command, not just the first With `s` in the unit group, `sleep 1s && sleep 60` matched `sleep 1s` first, fell under the threshold and returned null, where the old regex had failed on `1s` and gone on to find `sleep 60`. Iterate over every match and flag the command once any reaches 30 seconds. This also catches `sleep 1; sleep 60`, which main already missed for the same reason. Raised by CodeRabbit on #1100. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- __tests__/audit/detectors.test.ts | 7 +++++++ src/audit/detectors/sleep-polling-loop.ts | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb74b5af..0057fd119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Drop the `skills` submodule and its daily Dependabot `gitsubmodule` entry. Nothing in this repo read it, nor did the npm package or any workflow, and the job in `FailproofAI/skills` that kept it current failed on every merge once the version-bot App was gone. The skills reach users through `npx skills add FailproofAI/skills`, which this pin never fed (#1075) - Delete `sync-fp-cloud-cli-skill.yml` and `sync-failproofai-sdk-skill.yml`, red on every run since August because the `SKILLS_SYNC_PAT` they pushed to `FailproofAI/skills` with was never created; that repo now pulls both skills from this public one with its own token, so nothing here holds a credential that writes to it. The fp-cloud-cli skill's description is cut from 1118 to 995 characters, under the 1024 that the skills repo's validator enforces and past which Copilot drops a skill (#1068) -- The audit's `sleep-polling-loop` detector now counts the explicit-seconds form `sleep 30s`, which its regex used to drop; cached transcripts are re-scanned once on the next audit, so those already in history are counted too (#1100, from #588, #845, fixes #522) +- The audit's `sleep-polling-loop` detector now counts the explicit-seconds form `sleep 30s`, which its regex used to drop, and checks every `sleep` in a command rather than only the first, so `sleep 1; sleep 60` counts too; cached transcripts are re-scanned once on the next audit, so those already in history are counted too (#1100, from #588, #845, fixes #522) - Add a global `--no-color` flag, the same as `NO_COLOR=1`, accepted before or after any command; `failproofai policies` already honors `NO_COLOR` (#1067, from #695, #700, #848, fixes #688) - CI: the contributor-welcome workflow no longer tries to approve Dependabot pull requests. GitHub refuses a workflow approval while "Allow GitHub Actions to create and approve pull requests" is off, so every Dependabot PR got a failed run, and with it on the approval would count as the one review `main` requires. Dependency updates are reviewed by a person; the workflow drops `pull-requests: write` (#1049) diff --git a/__tests__/audit/detectors.test.ts b/__tests__/audit/detectors.test.ts index 5164fd31b..c9ae16e13 100644 --- a/__tests__/audit/detectors.test.ts +++ b/__tests__/audit/detectors.test.ts @@ -115,6 +115,13 @@ describe("sleep-polling-loop", () => { it("matches `sleep 30s` followed by another command", () => { expect(sleepPollingLoop.detect(bash("sleep 30s && npm test"), {})).not.toBeNull(); }); + it("matches a long sleep after a short one (`sleep 1s && sleep 60`)", () => { + expect(sleepPollingLoop.detect(bash("sleep 1s && sleep 60"), {})).not.toBeNull(); + expect(sleepPollingLoop.detect(bash("sleep 1; make; sleep 45s"), {})).not.toBeNull(); + }); + it("does not match when every sleep is short (`sleep 1s && sleep 5`)", () => { + expect(sleepPollingLoop.detect(bash("sleep 1s && sleep 5"), {})).toBeNull(); + }); it("does not match `sleep 30sec`, which is not a unit sleep accepts", () => { expect(sleepPollingLoop.detect(bash("sleep 30sec"), {})).toBeNull(); }); diff --git a/src/audit/detectors/sleep-polling-loop.ts b/src/audit/detectors/sleep-polling-loop.ts index e8b34de87..beb018292 100644 --- a/src/audit/detectors/sleep-polling-loop.ts +++ b/src/audit/detectors/sleep-polling-loop.ts @@ -22,8 +22,9 @@ export const sleepPollingLoop: Detector = { // Standalone long sleep. parseFloat so `sleep 0.5m` (= 30s) isn't dropped; // the unit group includes `s` so the common explicit form `sleep 30s` matches // (the trailing \b used to fail on `0s`, dropping the whole match). - const match = /\bsleep\s+(\d+(?:\.\d+)?)(s|m|h|d)?\b/.exec(cmd); - if (match) { + // Every sleep in the command is checked, not just the first, so a short one + // ahead of a long one (`sleep 1s && sleep 60`) does not hide it. + for (const match of cmd.matchAll(/\bsleep\s+(\d+(?:\.\d+)?)(s|m|h|d)?\b/g)) { const n = parseFloat(match[1]); const unit = match[2] ?? "s"; const seconds = unit === "m" ? n * 60 : unit === "h" ? n * 3600 : unit === "d" ? n * 86400 : n;