Skip to content

fix: clear CodeQL incomplete URL substring sanitization alerts - #6804

Merged
joaomdmoura merged 4 commits into
mainfrom
cursor/fix-codeql-url-substring-c33e
Aug 5, 2026
Merged

fix: clear CodeQL incomplete URL substring sanitization alerts#6804
joaomdmoura merged 4 commits into
mainfrom
cursor/fix-codeql-url-substring-c33e

Conversation

@theCyberTech

@theCyberTech theCyberTech commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes open CodeQL py/incomplete-url-substring-sanitization findings that still match on main, and unblocks CI flakes in tool-call streaming tests.

CodeQL fixes

  1. DataTypes.from_content (lib/crewai-tools/src/crewai_tools/rag/data_types.py)
    • Replace "github.com" in url.netloc with hostname checks via urlparse.
  2. Stagehand navigate test (lib/crewai-tools/tests/tools/stagehand_tool_test.py)
    • Replace URL substring assertion with exact mocked-result equality.
  3. Tests for real vs spoofed GitHub hostnames.

CI flake fix

tests/llms/test_tool_call_streaming.py failed in CI with empty tool-call event lists (unrelated to the CodeQL changes). The emit mock only patched CrewAIEventsBus.emit on the class, which can be shadowed by an instance-level crewai_event_bus.emit. The fixture now patches both, and event extraction reads kwargs/args explicitly.

Validation

  • Local CodeQL Incomplete URL substring sanitization: 0 results
  • pytest lib/crewai-tools/tests/rag/test_data_types.py: 4 passed
  • GITHUB_ACTIONS=true pytest lib/crewai/tests/llms/test_tool_call_streaming.py: 8 passed
Open in Web Open in Cursor 

Replace hostname substring checks with urlparse hostname matching in
RAG DataType classification, and assert the full mocked Stagehand
navigate result instead of searching for a URL substring.

Co-authored-by: Rip&Tear <theCyberTech@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The pull request tightens GitHub hostname detection and adds coverage for valid and spoofed URLs. It also strengthens Stagehand navigation assertions and makes streaming event tests handle both positional and keyword mock calls.

GitHub URL classification

Layer / File(s) Summary
GitHub hostname detection and validation
lib/crewai-tools/src/crewai_tools/rag/data_types.py, lib/crewai-tools/tests/rag/test_data_types.py
GitHub detection matches github.com and its subdomains case-insensitively. Tests reject spoofed hosts and GitHub-like paths.

Test assertion reliability

Layer / File(s) Summary
Navigation result and invocation assertions
lib/crewai-tools/tests/tools/stagehand_tool_test.py
The test verifies the complete mocked result and the exact _run call arguments.
Streaming event collection
lib/crewai/tests/llms/test_tool_call_streaming.py
Streaming tests patch both event bus access paths and extract events from positional or keyword mock calls.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary CodeQL URL sanitization fix.
Description check ✅ Passed The description accurately explains the CodeQL fixes, test updates, and validation results.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-codeql-url-substring-c33e

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.

@github-actions github-actions Bot added the size/S label Aug 4, 2026
from_content lives on DataTypes, not the DataType enum.

Co-authored-by: Rip&Tear <theCyberTech@users.noreply.github.com>
@theCyberTech
theCyberTech marked this pull request as ready for review August 4, 2026 16:38
CI failed when class-level CrewAIEventsBus.emit patches were shadowed by
the singleton instance. Patch both the class and crewai_event_bus.emit,
and read events from kwargs/args explicitly.

Co-authored-by: Rip&Tear <theCyberTech@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/crewai/tests/llms/test_tool_call_streaming.py`:
- Around line 55-60: Update _event_from_emit_call to return the first positional
argument when no keyword event exists, while preserving the existing
second-argument handling for bound calls. Add a test that patches
crewai_event_bus.emit and invokes it with a positional event, verifying both
collectors retain that event.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ab1b157e-3508-4a6a-9959-e9fc7e89c2a0

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb690d and f0a7dcf.

📒 Files selected for processing (1)
  • lib/crewai/tests/llms/test_tool_call_streaming.py

Comment thread lib/crewai/tests/llms/test_tool_call_streaming.py
Copilot AI lite review requested due to automatic review settings August 5, 2026 03:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@joaomdmoura
joaomdmoura enabled auto-merge (squash) August 5, 2026 05:25
@joaomdmoura
joaomdmoura merged commit 323334d into main Aug 5, 2026
56 checks passed
@joaomdmoura
joaomdmoura deleted the cursor/fix-codeql-url-substring-c33e branch August 5, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants