-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Security fixes for executable validation and state file permissions #8
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 |
|---|---|---|
|
|
@@ -118,22 +118,25 @@ def test_find_nonexistent_in_path(self): | |
| result = find_executable_in_path("definitely_not_a_real_executable_12345") | ||
| self.assertIsNone(result) | ||
|
|
||
| @patch("devhost_cli.executable_validation.is_user_writable") | ||
| @patch("subprocess.run") | ||
| def test_validate_caddy_success(self, mock_run): | ||
| def test_validate_caddy_success(self, mock_run, mock_is_writable): | ||
| """Test Caddy validation with successful version check.""" | ||
| # Create a fake executable | ||
| test_file = self.temp_path / "caddy" | ||
| test_file.write_text("#!/bin/bash\necho Caddy v2.7.4") | ||
| if sys.platform != "win32": | ||
| test_file.chmod(0o755) | ||
|
|
||
| # Mock writability check to return safe (not user-writable) | ||
| mock_is_writable.return_value = (False, None) | ||
|
|
||
|
Comment on lines
+131
to
+133
|
||
| # Mock subprocess.run to return Caddy version | ||
| mock_result = MagicMock() | ||
| mock_result.returncode = 0 | ||
| mock_result.stdout = "Caddy v2.7.4 h1:abc123" | ||
| mock_run.return_value = mock_result | ||
|
|
||
| # Skip writability check | ||
| is_valid, error = validate_caddy_executable(str(test_file)) | ||
|
|
||
| # On Windows, we might not have execute permission | ||
|
|
||
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.
The PR title/description says this is a security fix for executable validation and state file permissions, but this change is only updating a unit test by mocking
is_user_writable. If the intended security behavior changed in production code, that code change isn’t reflected here; otherwise, consider updating the PR title/description to match the actual scope.