-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(security): address CodeQL security alerts and code quality issues #1286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,10 @@ | |
| Tests the PR review orchestrator and follow-up review functionality. | ||
| """ | ||
|
|
||
| import json | ||
| import sys | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from unittest.mock import AsyncMock, MagicMock, patch | ||
| from dataclasses import asdict | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
||
|
|
@@ -30,7 +28,7 @@ | |
| MergeVerdict, | ||
| FollowupReviewContext, | ||
| ) | ||
| from bot_detection import BotDetector, BotDetectionState | ||
| from bot_detection import BotDetector | ||
|
|
||
|
|
||
| # ============================================================================ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,8 @@ | |
| import os | ||
| import subprocess | ||
| import sys | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from typing import Callable, Generator | ||
| from unittest.mock import MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,12 +16,11 @@ | ||||||||||||||||||||||||||||
| import tempfile | |||||||||||||||||||||||||||||
| import shutil | |||||||||||||||||||||||||||||
| from pathlib import Path | |||||||||||||||||||||||||||||
| from datetime import datetime | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Add parent directory to path for imports | |||||||||||||||||||||||||||||
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| from recovery import RecoveryManager, FailureType, RecoveryAction | |||||||||||||||||||||||||||||
| from recovery import RecoveryManager, FailureType | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| def setup_test_environment(): | |||||||||||||||||||||||||||||
|
|
@@ -96,7 +95,8 @@ | ||||||||||||||||||||||||||||
| temp_dir, spec_dir, project_dir, saved_env = setup_test_environment() | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| try: | |||||||||||||||||||||||||||||
| manager = RecoveryManager(spec_dir, project_dir) | |||||||||||||||||||||||||||||
| # Initialize manager to trigger directory creation (manager instance not needed) | |||||||||||||||||||||||||||||
| _manager = RecoveryManager(spec_dir, project_dir) | |||||||||||||||||||||||||||||
Check noticeCode scanning / CodeQL Unused local variable Note test
Variable _manager is not used.
Copilot AutofixAI 3 days ago In general, to fix an "unused local variable" warning you either (1) remove the binding if the value is truly unused and the right-hand side’s side effects must still occur, or (2) rename the variable to a conventionally accepted “unused” name if it is intentionally unused but must exist, or (3) actually use the variable if it was meant to be used. Here, the comment explicitly states that the manager instance is “not needed,” and the only goal is to “trigger directory creation.” Therefore, the best, minimal-impact fix is to remove the _manager = RecoveryManager(spec_dir, project_dir)with: RecoveryManager(spec_dir, project_dir)This preserves the constructor side effects while eliminating the unused variable, requires no new imports or additional definitions, and does not alter test behavior.
Suggested changeset
1
tests/test_recovery.py
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Check that memory directory was created | |||||||||||||||||||||||||||||
| assert (spec_dir / "memory").exists(), "Memory directory not created" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,9 +14,8 @@ | |||||
| import pytest | ||||||
| import sys | ||||||
| import time | ||||||
| from datetime import datetime, timedelta | ||||||
| from pathlib import Path | ||||||
| from unittest.mock import MagicMock, patch, AsyncMock | ||||||
| from unittest.mock import MagicMock, patch | ||||||
|
|
||||||
| # Add auto-claude directory to path for imports | ||||||
| sys.path.insert(0, str(Path(__file__).parent.parent / "Apps" / "backend")) | ||||||
|
|
@@ -356,9 +355,6 @@ def test_removes_empty_pending_folder(self, temp_dir: Path): | |||||
| import os | ||||||
| os.utime(old_pending, (old_time, old_time)) | ||||||
|
|
||||||
| # Store the inode to verify it's actually deleted and recreated | ||||||
| old_inode = old_pending.stat().st_ino | ||||||
|
|
||||||
| # Creating orchestrator triggers cleanup | ||||||
| # The cleanup removes 002-pending (empty and old) | ||||||
| # Then _create_spec_dir creates 004-pending (after 003) | ||||||
|
|
@@ -386,8 +382,8 @@ def test_keeps_folder_with_requirements(self, temp_dir: Path): | |||||
| import os | ||||||
| os.utime(pending_with_req, (old_time, old_time)) | ||||||
|
|
||||||
| # Creating orchestrator triggers cleanup | ||||||
| orchestrator = SpecOrchestrator(project_dir=temp_dir) | ||||||
| # Creating orchestrator triggers cleanup (instance not used) | ||||||
| SpecOrchestrator(project_dir=temp_dir) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While creating an instance of
Suggested change
|
||||||
|
|
||||||
| assert pending_with_req.exists() | ||||||
|
|
||||||
|
|
@@ -408,8 +404,8 @@ def test_keeps_folder_with_spec(self, temp_dir: Path): | |||||
| import os | ||||||
| os.utime(pending_with_spec, (old_time, old_time)) | ||||||
|
|
||||||
| # Creating orchestrator triggers cleanup | ||||||
| orchestrator = SpecOrchestrator(project_dir=temp_dir) | ||||||
| # Creating orchestrator triggers cleanup (instance not used) | ||||||
| SpecOrchestrator(project_dir=temp_dir) | ||||||
|
|
||||||
| assert pending_with_spec.exists() | ||||||
|
|
||||||
|
|
@@ -424,8 +420,8 @@ def test_keeps_recent_pending_folder(self, temp_dir: Path): | |||||
| recent_pending = specs_dir / "001-pending" | ||||||
| recent_pending.mkdir() | ||||||
|
|
||||||
| # Creating orchestrator triggers cleanup | ||||||
| orchestrator = SpecOrchestrator(project_dir=temp_dir) | ||||||
| # Creating orchestrator triggers cleanup (instance not used) | ||||||
| SpecOrchestrator(project_dir=temp_dir) | ||||||
|
|
||||||
| # Recent folder should still exist (unless orchestrator created 002-pending) | ||||||
| # The folder might be gone if orchestrator picked a different name | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,6 @@ | |
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| # Add auto-claude to path | ||
| sys.path.insert(0, str(Path(__file__).parent.parent / "Apps" / "backend")) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore
isWindowsimport and use platform abstraction functions.The
isWindowsimport should not be removed. This file contains directprocess.platformchecks on lines 45 and 168, which violate the coding guidelines requiring platform abstraction functions. Based on learnings, all platform checks inapps/frontend/src/main/**/*.{ts,tsx}must use abstraction functions likeisWindows()from the platform module.♻️ Proposed fix to restore the import
📝 Committable suggestion
🤖 Prompt for AI Agents