Commit Graph

4 Commits

Author SHA1 Message Date
HAL9000 f8f5f2f3f4 test(lsp): cover timeout branches in detect_directory_languages
CI / lint (pull_request) Successful in 59s
CI / typecheck (pull_request) Successful in 1m8s
CI / push-validation (pull_request) Successful in 38s
CI / build (pull_request) Successful in 52s
CI / helm (pull_request) Successful in 56s
CI / security (pull_request) Successful in 1m18s
CI / quality (pull_request) Successful in 1m14s
CI / unit_tests (pull_request) Successful in 5m40s
CI / docker (pull_request) Successful in 1m36s
CI / integration_tests (pull_request) Successful in 8m59s
CI / coverage (pull_request) Successful in 9m27s
CI / status-check (pull_request) Successful in 4s
Add two BDD scenarios that mock os.walk and the time module so the
outer-loop and inner-file-loop timeout-exceeded branches in
detect_directory_languages() are deterministically exercised. Closes
the diff-coverage gap on src/cleveragents/lsp/discovery.py lines
250-257 (outer-loop timeout warning + break) and 284-291 (inner-loop
timeout warning + break) which the previous DoS protection scenarios
did not reach.

Refs: #7161
2026-06-14 20:39:38 -04:00
HAL9000 c4024146b1 fix(lsp): move tdd_issue tags before Feature keyword in dos protection feature
The @tdd_issue and @tdd_issue_7161 tags were placed inside the Feature
description body (indented after Feature:), where Behave treats them as
free-text, not tags. The parser fails at the plain-text description line
that follows ("Prevent resource exhaustion...") because it entered the
taggable_statement state after seeing the @-prefixed lines.

Moving both tags to before the Feature: line makes them proper
feature-level tags. All 9 scenarios inherit @tdd_issue via effective_tags,
satisfying the validate_tdd_tags() rule that every @tdd_issue_N scenario
must also carry @tdd_issue. All 9 scenarios now pass.

Refs: #7161
2026-06-14 20:39:38 -04:00
HAL9000 9297b283e4 fix(10632): address PR review blocking issues
Resolved three blocking review items from pr-review-worker:

1. Added @tdd_issue tag at Feature level to fix unit_tests CI failure
   (each scenario has @tdd_issue_7161 which requires @tdd_issue present)

2. Assigned milestone v3.6.0 to align with linked issue #7161

3. Applied ruff format to resolve lint/format violations in discovery.py
2026-06-14 20:39:38 -04:00
HAL9000 07469f55a5 fix(lsp): add depth/file/timeout limits to detect_directory_languages() to prevent DoS
Added robust guards to detect_directory_languages() by introducing depth, file count, and timeout controls. Defaults and validations are implemented to prevent resource exhaustion during LSP discovery.

- Added max_depth parameter (default: 50) with validation to ensure a positive integer.
- Added max_files parameter (default: 10,000) with validation to ensure a positive integer.
- Added timeout parameter (default: 30.0 seconds) with validation to ensure a positive float.
- Pass followlinks=False to os.walk() to prevent symlink-based DoS via recursive loops.
- Implemented depth tracking in the traversal loop with early break when max_depth is exceeded.
- Implemented file count tracking with early break when max_files is exceeded.
- Implemented periodic timeout checks during traversal to enforce the overall time limit.
- Added warning logging when traversal is terminated early due to any limit.
- Updated the function docstring to document the new parameters and their defaults.
- Created comprehensive BDD tests in features/lsp_discovery_dos_protection.feature to validate the protections.

ISSUES CLOSED: #7161
2026-06-14 20:39:38 -04:00