Skip to content

fix: add 's' unit to sleep-polling-loop regex so 'sleep 30s' is detected#588

Open
Abhi-DevHub wants to merge 1 commit into
FailproofAI:mainfrom
Abhi-DevHub:fix/sleep-polling-loop-detect-30s
Open

fix: add 's' unit to sleep-polling-loop regex so 'sleep 30s' is detected#588
Abhi-DevHub wants to merge 1 commit into
FailproofAI:mainfrom
Abhi-DevHub:fix/sleep-polling-loop-detect-30s

Conversation

@Abhi-DevHub

@Abhi-DevHub Abhi-DevHub commented Jul 21, 2026

Copy link
Copy Markdown

Closes #522

Problem

/\bsleep\s+(\d+(?:\.\d+)?)(m|h|d)?\b/\ silently drops \sleep 30s\ because the unit alternation lacks \s. The trailing \\b\ fails between \

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of long-running polling loops that use sleep durations specified in seconds.
    • Commands such as sleep 30s are now correctly recognized and flagged when they exceed the configured threshold.
  • Tests

    • Added coverage to verify detection of sleep durations with explicit second units.

The regex alternation (m|h|d)? omitted s, so the trailing \b
word boundary failed between
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f4773fc-10fa-4272-b247-58ff2a4104e0

📥 Commits

Reviewing files that changed from the base of the PR and between 77d0af0 and aa2900f.

📒 Files selected for processing (2)
  • __tests__/audit/detectors.test.ts
  • src/audit/detectors/sleep-polling-loop.ts

📝 Walkthrough

Walkthrough

The sleep-polling-loop detector now parses explicit seconds suffixes, and a test verifies that sleep 30s is detected.

Changes

Sleep polling detection

Layer / File(s) Summary
Seconds parsing and validation
src/audit/detectors/sleep-polling-loop.ts, __tests__/audit/detectors.test.ts
The standalone sleep regex accepts the s suffix, with coverage confirming detection of sleep 30s.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: chhhee10

Poem

I’m a rabbit with seconds to spare,
Now sleep 30s is caught in the snare.
The detector grows wise,
No short sleep disguise—
Hippity-hop, clean audits are there!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description references the issue and problem, but it omits the required Type of Change and Checklist sections. Add the Type of Change section and complete the checklist items, plus any other required template fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main regex fix for sleep 30s detection.
Linked Issues check ✅ Passed The regex update and test directly satisfy #522 by recognizing sleep 30s and covering it in the test suite.
Out of Scope Changes check ✅ Passed The changes stay focused on the detector regex and its test, with no unrelated code added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hermes-exosphere

Copy link
Copy Markdown
Contributor

Your PR is awaiting review by a reviewer. Till then you can join the Discord for conversation: https://discord.befailproof.ai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit sleep-polling-loop detector misses the most common form, sleep 30s

2 participants