Commit graph

80 commits

Author SHA1 Message Date
Andras Bacsai
096d4369e5 fix(sentinel): add token validation to prevent command injection
Add validation to ensure sentinel tokens contain only safe characters
(alphanumeric, dots, hyphens, underscores, plus, forward slash, equals),
preventing OS command injection vulnerabilities when tokens are
interpolated into shell commands.

- Add ServerSetting::isValidSentinelToken() validation method
- Validate tokens in StartSentinel action and metrics queries
- Improve shell argument escaping with escapeshellarg()
- Add comprehensive test coverage for token validation
2026-03-10 22:19:19 +01:00
Andras Bacsai
c3f0ed3098 refactor(ssh-retry): remove Sentry tracking from retry logic
Remove the trackSshRetryEvent() method and its invocation from the SSH retry
flow. This simplifies the retry mechanism and reduces external dependencies for
retry handling.
2026-02-15 14:00:27 +01:00
Andras Bacsai
ced1938d43 chore: prepare for PR 2026-02-15 13:48:01 +01:00
Andras Bacsai
a8aa452475 fix: prevent metric charts from freezing when navigating with wire:navigate
Wraps inline chart initialization scripts in IIFEs to create local scope for variables. This prevents "Identifier has already been declared" errors when Livewire's SPA navigation re-executes scripts, allowing smooth navigation between metrics pages without page refresh.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-02 12:36:17 +01:00
Andras Bacsai
5d38147899 feat(api): Improve OpenAPI spec and add rate limit handling for Hetzner
- Add 429 response with Retry-After header for Hetzner server creation
- Create RateLimitException for proper rate limit error handling
- Rename cloud_provider_token_id to cloud_provider_token_uuid with deprecation
- Fix prices array schema in server-types endpoint with proper items definition
- Add explicit default: true to autogenerate_domain properties
- Add timeout and retry options to Docker install curl commands
- Fix race condition in deployment status update using atomic query
2025-12-11 12:12:43 +01:00
Andras Bacsai
a2e5b2d67d Fix deployment marked as failed when healthy container completes rolling update
Prevent deployment status from regressing to FAILED after it's marked as FINISHED by:
1. Calling completeDeployment() first in post_deployment() before any operations that could fail
2. Wrapping all post-deployment side effects in try-catch blocks
3. Adding FINISHED to terminal states that cannot be changed
4. Protecting ExecuteRemoteCommand from overwriting FINISHED status

This fixes the issue where a deployment with a healthy container and successful rolling update was still marked as Failed in the UI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-11 09:42:02 +01:00
Andras Bacsai
ac9eca3c05 fix: don't show health status for exited containers
Exited containers don't run health checks, so showing "(unhealthy)" is
misleading. This fix ensures exited status displays without health
suffixes across all monitoring systems (SSH, Sentinel, services, etc.)
and at the UI layer for backward compatibility with existing data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 09:09:37 +01:00
Andras Bacsai
7ceb124e9b feat: add validation for YAML parsing, integer parameters, and Docker Compose custom fields
This commit adds comprehensive validation improvements and DRY principles for handling Coolify's custom Docker Compose extensions.

## Changes

### 1. Created Reusable stripCoolifyCustomFields() Function
- Added shared helper in bootstrap/helpers/docker.php
- Removes all Coolify custom fields (exclude_from_hc, content, isDirectory, is_directory)
- Handles both long syntax (arrays) and short syntax (strings) for volumes
- Well-documented with comprehensive docblock
- Follows DRY principle for consistent field stripping

### 2. Fixed Docker Compose Modal Validation
- Updated validateComposeFile() to use stripCoolifyCustomFields()
- Now removes ALL custom fields before Docker validation (previously only removed content)
- Fixes validation errors when using templates with custom fields (e.g., traccar.yaml)
- Users can now validate compose files with Coolify extensions in UI

### 3. Enhanced YAML Validation in CalculatesExcludedStatus
- Added proper exception handling with ParseException vs generic Exception
- Added structure validation (checks if parsed result and services are arrays)
- Comprehensive logging with context (error message, line number, snippet)
- Maintains safe fallback behavior (returns empty collection on error)

### 4. Added Integer Validation to ContainerStatusAggregator
- Validates maxRestartCount parameter in both aggregateFromStrings() and aggregateFromContainers()
- Corrects negative values to 0 with warning log
- Logs warnings for suspiciously high values (> 1000)
- Prevents logic errors in crash loop detection

### 5. Comprehensive Unit Tests
- tests/Unit/StripCoolifyCustomFieldsTest.php (NEW) - 9 tests, 43 assertions
- tests/Unit/ContainerStatusAggregatorTest.php - Added 6 tests for integer validation
- tests/Unit/ExcludeFromHealthCheckTest.php - Added 4 tests for YAML validation
- All tests passing with proper Log facade mocking

### 6. Documentation
- Added comprehensive Docker Compose extensions documentation to .ai/core/deployment-architecture.md
- Documents all custom fields: exclude_from_hc, content, isDirectory/is_directory
- Includes examples, use cases, implementation details, and test references
- Updated .ai/README.md with navigation links to new documentation

## Benefits
- Better UX: Users can validate compose files with custom fields
- Better Debugging: Comprehensive logging for errors
- Better Code Quality: DRY principle with reusable validation
- Better Reliability: Prevents logic errors from invalid parameters
- Better Maintainability: Easy to add new custom fields in future

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 18:34:49 +01:00
Andras Bacsai
ae6eef3cdb feat(tests): add comprehensive tests for ContainerStatusAggregator and serverStatus accessor
- Introduced tests for ContainerStatusAggregator to validate status aggregation logic across various container states.
- Implemented tests to ensure serverStatus accessor correctly checks server infrastructure health without being affected by container status.
- Updated ExcludeFromHealthCheckTest to verify excluded status handling in various components.
- Removed obsolete PushServerUpdateJobStatusAggregationTest as its functionality is covered elsewhere.
- Updated version number for sentinel to 0.0.17 in versions.json.
2025-11-20 17:31:07 +01:00
Andras Bacsai
67605d50fc fix(deployment): prevent base deployments from being killed when PRs close (#7113)
- Fix container filtering to properly distinguish base deployments (pullRequestId=0) from PR deployments
- Add deployment cancellation when PR closes via webhook to prevent race conditions
- Prevent CleanupHelperContainersJob from killing active deployment containers
- Enhance error messages with exit codes and actual errors instead of vague "Oops" messages
- Protect status transitions in finally blocks to ensure proper job failure handling
2025-11-09 14:41:35 +01:00
Andras Bacsai
728f261316 Changes auto-committed by Conductor 2025-10-16 09:51:37 +02:00
Andras Bacsai
635af44539
Merge pull request #6837 from coollabsio/andrasbacsai/custom-webhooks
feat: add custom webhook notification support
2025-10-12 10:57:47 +02:00
Andras Bacsai
729c891542 feat: add WebhookChannel placeholder implementation
Add basic WebhookChannel infrastructure:
- Create SendsWebhook interface
- Create WebhookChannel with placeholder implementation (logs instead of sending)
- Update Test notification to support webhook channel
- Add WebhookChannel to HasNotificationSettings trait
- Add toWebhook() method to Test notification

This provides a working foundation that won't break test notifications.
The actual HTTP webhook delivery will be implemented in a follow-up.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 17:57:10 +02:00
Andras Bacsai
27879377a0 feat: add custom webhook notification support
Add basic infrastructure for custom webhook notifications:
- Create webhook_notification_settings table with event toggles
- Add WebhookNotificationSettings model with encrypted URL
- Integrate webhook settings into Team model and HasNotificationSettings trait
- Create Livewire component and Blade view for webhook configuration
- Add webhook navigation route and UI

This provides the foundation for sending webhook notifications to custom HTTP/HTTPS endpoints when events occur in Coolify.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 15:37:00 +02:00
Andras Bacsai
513f6b54f7 feat: implement Hetzner deletion failure notification system with email and messaging support 2025-10-10 09:35:58 +02:00
Andras Bacsai
a897e81566 feat(global-search): integrate projects and environments into global search functionality
- Added retrieval and mapping of projects and environments to the global search results.
- Enhanced search result structure to include resource counts and descriptions for projects and environments.
- Updated the UI to reflect the new search capabilities, improving user experience when searching for resources.
2025-09-30 13:37:03 +02:00
Andras Bacsai
a03c1b3b4b refactor(dashboard): remove deployment loading logic and introduce DeploymentsIndicator component for better UI management 2025-09-30 11:43:30 +02:00
Andras Bacsai
b83223ff6e
Merge branch 'next' into v4.x 2025-09-25 14:39:23 +02:00
Andras Bacsai
2eef83f072 fix(traits): update saved_outputs handling in ExecuteRemoteCommand to use collection methods for better performance 2025-09-25 13:19:05 +02:00
Andras Bacsai
82a8c42d9a fix(clears-global-search-cache): refine team retrieval logic in getTeamIdForCache method
- Updated the getTeamIdForCache method to differentiate team retrieval based on the instance type, ensuring correct access to the team property or method for Server models and other types.
2025-09-23 15:27:47 +02:00
Andras Bacsai
6dc5c53387 fix(environment-variables): correct method call syntax in analyzeBuildVariable function
- Updated the method call syntax in the analyzeBuildVariable function to use curly braces for dynamic method invocation, ensuring proper execution of the specified check function.
2025-09-23 11:40:56 +02:00
Andras Bacsai
e3a03eb647 fix(cache): add Model import to ClearsGlobalSearchCache trait for improved functionality 2025-09-23 11:38:55 +02:00
Andras Bacsai
dc32bed1ae fix(environment-variables): update affected services in environment variable analysis
- Expanded the list of affected services in the EnvironmentVariableAnalyzer trait to include 'bun' and 'pnpm' alongside 'npm' and 'yarn'.
- Improved clarity on the impact of problematic environment variables during the build process.
2025-09-23 08:54:20 +02:00
Andras Bacsai
b1abdcee83 feat(environment-variables): implement environment variable analysis for build-time issues
- Added EnvironmentVariableAnalyzer trait to analyze and warn about problematic environment variables during the build process.
- Integrated analysis into ApplicationDeploymentJob and Livewire components to provide feedback on potential build issues.
- Introduced a new Blade component for displaying warnings related to environment variables in the UI.
2025-09-23 08:53:14 +02:00
Andras Bacsai
8d5f9ed0f6 refactor(cache): update team retrieval method in ClearsGlobalSearchCache trait 2025-09-23 08:49:28 +02:00
Ahmed A
671e72b466
Merge branch 'next' into v4.x 2025-09-20 13:50:03 +03:00
Andras Bacsai
3f48dcb575 feat(redaction): implement sensitive information redaction in logs and commands 2025-09-19 15:54:44 +02:00
Andras Bacsai
f223623603 refactor(search): optimize cache clearing logic to only trigger on searchable field changes 2025-09-19 10:22:31 +02:00
Andras Bacsai
d8d316b5f8 feat(search): implement global search functionality with caching and modal interface 2025-09-19 10:17:55 +02:00
Ahmed A
59f3220d26
Merge branch 'next' into v4.x 2025-09-18 16:01:15 +03:00
Andras Bacsai
9e8fb36bc8 feat(deployment): implement cancellation checks during deployment process to enhance user control and prevent unnecessary execution 2025-09-16 13:40:51 +02:00
Ahmed A
4d52a26ac6 fix rebase 2025-09-13 17:04:22 +03:00
Ahmed A
5eacb01beb Merge branch 'v4.x' of https://github.com/ahmadw13/coolify into v4.x 2025-09-13 17:01:39 +03:00
Ahmed A
b3d8b99959 Adding support for using config values for process 2025-09-13 17:00:17 +03:00
Ahmed A
c2d6cd1445 spacing fix 2025-09-09 17:28:58 +03:00
Ahmed A
a4e13f56c0 Adding support for using config values for process 2025-09-09 17:25:55 +03:00
Arnaud B
e23ab1e621
feat(deployment): add SERVICE_NAME variables for service discovery
This change introduces automatically generated `SERVICE_NAME_<SERVICE>`
environment variables for each service within a Docker Compose deployment.
This allows services to reliably reference each other by name, which is particularly
useful in pull request environments where container names are dynamically suffixed.

- The application parser now generates and injects these `SERVICE_NAME` variables
   into the environment of all services in the compose file.
- `ApplicationDeploymentJob` is updated to correctly handle and filter these
  new variables during deployment.
- UI components and the `EnvironmentVariableProtection` trait have been updated
to make these generated variables read-only, preventing accidental modification.

This commit introduces two new helper functions to standardize resource naming
for pull request deployments:

-  `addPreviewDeploymentSuffix()`: Generates a consistent suffix format (-pr-{id})
   for resource names in preview deployments
-  `generateDockerComposeServiceName()`: Creates SERVICE_NAME environment variables
   for Docker Compose services
2025-09-08 15:22:44 +02:00
Andras Bacsai
45c75ad9c1 feat(ssh): add Sentry tracking for SSH retry events to enhance error monitoring 2025-09-07 18:57:20 +02:00
Andras Bacsai
4bd29bf966 refactor(ssh): enhance error handling in SSH command execution and improve connection validation logging 2025-09-07 18:45:44 +02:00
Andras Bacsai
579cc25898 fix(ssh): introduce SshRetryHandler and SshRetryable trait for enhanced SSH command retry logic with exponential backoff and error handling 2025-09-07 17:17:35 +02:00
Andras Bacsai
b847740924 refactor(command): simplify SSH command retry logic by removing unnecessary logging and improving delay calculation 2025-09-07 16:38:11 +02:00
Andras Bacsai
b6176d905b feat(command): implement SSH command retry logic with exponential backoff and logging for better error handling 2025-09-07 10:26:23 +02:00
Andras Bacsai
3e1f47a243 feat(auth): introduce resource creation authorization middleware and policies for enhanced access control 2025-08-26 10:27:38 +02:00
Andras Bacsai
38c0641734 feat(validation): centralize validation patterns for names and descriptions
- Introduced `ValidationPatterns` class to standardize validation rules and messages for name and description fields across the application.
- Updated various components and models to utilize the new validation patterns, ensuring consistent sanitization and validation logic.
- Replaced the `HasSafeNameAttribute` trait with `HasSafeStringAttribute` to enhance attribute handling and maintain consistency in name sanitization.
- Enhanced the `CleanupNames` command to align with the new validation rules, allowing for a broader range of valid characters in names.
2025-08-19 12:14:48 +02:00
Andras Bacsai
e958b3761d feat(cleanup): add command for sanitizing name fields across models
- Introduced `CleanupNames` command to sanitize name fields by removing invalid characters, ensuring only letters, numbers, spaces, dashes, underscores, and dots are retained.
- Implemented options for dry run, model-specific cleaning, database backup, and forced execution.
- Updated `Init` command to call the new `cleanup:names` command.
- Enhanced project and environment validation to enforce name sanitization rules.
- Added `HasSafeNameAttribute` trait to relevant models for consistent name handling.
2025-08-19 11:04:23 +02:00
Andras Bacsai
8e8400f595 feat(utf8-handling): implement UTF-8 sanitization for command outputs and enhance error handling in logs processing 2025-06-05 14:27:39 +02:00
Andras Bacsai
114fafb270 refactor(database): update DB facade usage for consistency across service files 2025-04-30 17:39:41 +02:00
Andras Bacsai
f63415f027 feat(EnvironmentVariable): implement protection for critical environment variables and enhance deletion logic 2025-04-07 22:57:26 +02:00
Andras Bacsai
d7d80e926e feat(user): implement session deletion on password reset 2025-03-21 15:45:29 +01:00
peaklabs-dev
f288852753
fix(notification): always send SSL notifications 2025-02-11 20:55:33 +01:00