Commit graph

47 commits

Author SHA1 Message Date
Muhammed Mustafa AKŞAM
9b6d1613ed
fix(docs): remove incorrect uuid format in openapi spec (#7419)
Co-authored-by: 🏔️ Peak <122374094+peaklabs-dev@users.noreply.github.com>
2026-01-04 16:16:19 +01:00
Andras Bacsai
4706bc23aa Refactor: Centralize service application prerequisites
Refactors the Appwrite and Beszel service-specific application settings
to use a centralized constant-based approach, following the same pattern
as NEEDS_TO_CONNECT_TO_PREDEFINED_NETWORK.

Changes:
- Added NEEDS_TO_DISABLE_GZIP constant for services requiring gzip disabled
- Added NEEDS_TO_DISABLE_STRIPPREFIX constant for services requiring stripprefix disabled
- Created applyServiceApplicationPrerequisites() helper function in bootstrap/helpers/services.php
- Updated all service creation flows to use the centralized helper:
  * app/Livewire/Project/Resource/Create.php (web handler)
  * app/Http/Controllers/Api/ServicesController.php (API handler - BUG FIX)
  * app/Livewire/Project/New/DockerCompose.php (custom compose handler)
  * app/Http/Controllers/Api/ApplicationsController.php (API custom compose handler)
- Added comprehensive unit tests for the new helper function

Benefits:
- Single source of truth for service prerequisites
- DRY - eliminates code duplication between web and API handlers
- Fixes bug where API-created services didn't get prerequisites applied
- Easy to extend for future services (just edit the constant)
- More maintainable and testable

Related commits: 3a94f1ea1 (Beszel), 02b18c86e (Appwrite)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 16:47:09 +01:00
Andras Bacsai
e5280fd3ad feat: add predefined network connection for pgAdmin and postgresus services 2025-11-28 10:29:13 +01:00
Andras Bacsai
a4e4cc2c17 fix: update service creation logic to only connect pgAdmin to Docker network 2025-11-28 10:17:27 +01:00
Zach Silveira
b72f93faab fix api call booleans not being used 2025-10-26 11:25:44 -04:00
Andras Bacsai
fa8393184f refactor: improve validation error handling and coding standards
Changes:
1. Add explicit try-catch blocks around validateDockerComposeForInjection()
   in API endpoints to return proper 422 JSON responses with validation errors
2. Rename $service_payload to $servicePayload for PSR-12 compliance (camelCase)

API endpoints now properly handle validation failures:
- One-click service creation (line 334)
- Custom compose service creation (line 480)
- Service update endpoint (line 808)

All return consistent error format:
{
  "message": "Validation failed.",
  "errors": {
    "docker_compose_raw": "Invalid Docker Compose service name: ..."
  }
}

Livewire components already have proper exception handling via handleError().

All 60 security tests pass (176 assertions).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 09:51:37 +02:00
Andras Bacsai
cb1f571eb4 fix: prevent command injection in Docker Compose parsing - add pre-save validation
This commit addresses a critical security issue where malicious Docker Compose
data was being saved to the database before validation occurred.

Problem:
- Service models were saved to database first
- Validation ran afterwards during parse()
- Malicious data persisted even when validation failed
- User saw error but damage was already done

Solution:
1. Created validateDockerComposeForInjection() to validate YAML before save
2. Added pre-save validation to all Service creation/update points:
   - Livewire: DockerCompose.php, StackForm.php
   - API: ServicesController.php (create, update, one-click)
3. Validates service names and volume paths (string + array formats)
4. Blocks shell metacharacters: backticks, $(), |, ;, &, >, <, newlines

Security fixes:
- Volume source paths (string format) - validated before save
- Volume source paths (array format) - validated before save
- Service names - validated before save
- Environment variable patterns - safe ${VAR} allowed, ${VAR:-$(cmd)} blocked

Testing:
- 60 security tests pass (176 assertions)
- PreSaveValidationTest.php: 15 tests for pre-save validation
- ValidateShellSafePathTest.php: 15 tests for core validation
- VolumeSecurityTest.php: 15 tests for volume parsing
- ServiceNameSecurityTest.php: 15 tests for service names

Related commits:
- Previous: Added validation during parse() phase
- This commit: Moves validation before database save

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 09:51:37 +02:00
elmariss
737ec521b6 fix: missing 422 error code in openapi spec 2025-10-12 14:20:45 +02:00
Andras Bacsai
5b3b4bbc43 refactor(environment): remove 'is_build_time' attribute from environment variable handling across the application to simplify configuration 2025-09-11 16:51:56 +02:00
Andras Bacsai
b1334a1bc6 feat(auth): implement comprehensive authorization checks across API controllers 2025-08-23 18:51:10 +02:00
Andras Bacsai
0e014ce213 fix(service api): separate create and update service functionalities 2025-08-17 19:45:12 +02:00
Yanluis Fermin
9b0fd2073a
fix(api): update service upsert to retain name and description values if not set 2025-08-11 12:31:12 -04:00
Yanluis Fermin
4ff7ab7895
Merge branch 'next' into fix/service-update-required-params 2025-08-11 10:23:30 -04:00
🏔️ Peak
2a526c54d5
fix(docker): volumes get delete when stopping a service if Delete Unused Volumes is activated (#6317) 2025-08-04 21:15:56 +02:00
Yanluis Fermin
ad8f442318
refactor(services): update validation rules to be optional 2025-07-30 15:59:35 -04:00
peaklabs-dev
2934d4a259
chore(api): update API docs 2025-05-27 15:10:20 +02:00
Dusan
94df6ca51f
feat(api): Add latest query param to Service restart API (#5881) 2025-05-27 15:03:17 +02:00
Andras Bacsai
eee57d4c06 fix(api): handle JSON response in service creation and update methods for improved error handling 2025-04-22 11:16:49 +02:00
Laurence
1e7b15ae77
enhance: Add missing UUID to openapi spec 2025-04-09 17:52:12 +01:00
Meghea Iulian
d9be1191d6
feat(api): update OpenAPI spec for services (#5448) 2025-04-03 16:02:59 +02:00
Andras Bacsai
120facfca3 feat(api): unify service creation endpoint and enhance validation 2025-03-21 11:31:17 +01:00
Meghea Iulian
d08774d083
feat(api): update Services api routes and handlers 2025-03-20 08:28:28 +02:00
Meghea Iulian
d16888b707
feat(api): separate create and one-click routes
Moves previous POST /services to POST /services/one-click.
Adds new POST /services that takes a docker_compose.
2025-03-19 10:22:34 +02:00
Meghea Iulian
5a7ced9438
feat(api): add api to create custom services
Add separate API to create services with custom Docker compose instead
of oneclick services implement as a POST to /services/compose.
This is somewhat similar to /applications/dockercompose but that API is
the only one in ApplicationsController that actually works with the `Service` model.
2025-03-19 06:51:20 +02:00
Andras Bacsai
1fe4dd722b Revert "rector: arrrrr"
This reverts commit 16c0cd10d8.
2025-01-07 15:31:43 +01:00
Andras Bacsai
16c0cd10d8 rector: arrrrr 2025-01-07 14:52:08 +01:00
Andras Bacsai
9e3467578f feat: add environment_uuid support and update API documentation
- Introduced `environment_uuid` as a required field in various API endpoints and schemas.
- Updated descriptions to clarify that either `environment_name` or `environment_uuid` must be provided.
- Modified routes and controller methods to accommodate the new UUID parameter.
- Adjusted frontend components to utilize `environment_uuid` for better consistency and clarity.
- Removed deprecated fields related to environment handling.

This change enhances the API's flexibility in identifying environments, improving overall usability.
2024-12-17 13:42:16 +01:00
Andras Bacsai
2a9d499251 feat: migrate env variables to polymorphic relationship
fix: proxy status query ui
2024-12-17 10:38:42 +01:00
Andras Bacsai
4901b12279 fix: service status indicator + oauth saving 2024-12-13 12:03:10 +01:00
Andras Bacsai
458cd96ac8 fix: services env values should be sensitive 2024-12-12 13:20:13 +01:00
Andras Bacsai
3fa7d03db7 fix: root + read:sensive could read senstive data with a middlewarew 2024-12-09 11:10:35 +01:00
Kael
b9597e53e1 Merge branch 'next' into feat/deployment-token 2024-11-01 16:55:00 +11:00
Lucas Michot
1ec224fde1 Inline many variables. 2024-10-31 18:20:11 +01:00
Lucas Michot
8e1444eaa7 Get rid of many useless blank lines 2024-10-31 17:44:01 +01:00
Kael
6520235667 middleware should allow, not deny 2024-10-30 19:06:50 +11:00
Andras Bacsai
9212f3b24c feat: Update resource deletion job to allow configurable options through API 2024-10-01 09:02:16 +02:00
Andras Bacsai
63729c7bbf
Merge pull request #3373 from mattstein/api-project-description
feat: Expose project description in API response
2024-09-10 08:49:08 +02:00
Matt Stein
44d417c07e
Fix user-facing string case. 2024-09-09 09:38:40 -07:00
Andras Bacsai
ec7b18556e Update services controller to include new service envs commands 2024-09-06 10:48:47 +02:00
Gabriel Galer
2e5ed5969d Update services controller to include new service envs commands 2024-09-05 23:58:52 +03:00
Andras Bacsai
25480fe624 fix: openapi endpoint urls 2024-09-04 10:09:10 +02:00
Stuart Rowlands
dfb6d4da3d Return applications & databases in service API. 2024-08-07 17:20:55 +10:00
Andras Bacsai
33b965d9db chore: more details 2024-07-09 13:59:54 +02:00
Andras Bacsai
6c33bd9c72 openapi services 2024-07-09 13:30:13 +02:00
Andras Bacsai
efa2ae5177 api api api api 2024-07-04 13:45:06 +02:00
Andras Bacsai
b24a489c77 fix: api updates 2024-07-03 13:13:38 +02:00
Andras Bacsai
4459c9f73d feat: api api api api api api 2024-07-02 16:12:04 +02:00