Commit Graph

34 Commits

Author SHA1 Message Date
Andras Bacsai a2096c6f68 feat(observability): add structured audit log channel for API and webhook events
Introduce a dedicated `audit` log channel (daily rotation, configurable retention via
LOG_AUDIT_DAYS) and a small `auditLog()` / `auditLogWebhookFailure()` helper used to
record state-changing API operations and webhook events.

Instrumented:

- API mutation endpoints (create / update / delete / start / stop / restart) across
  applications, services, databases (incl. backups, env vars, storage), servers,
  projects + environments, scheduled tasks, private keys, GitHub apps, cloud provider
  tokens, Hetzner server provisioning, instance enable/disable.
- Webhook signature verification outcomes for GitHub, GitLab, Bitbucket, Gitea and
  Stripe, plus the Sentinel push endpoint.
- Authentication and authorization outcomes via the global exception handler and
  the `ApiAbility` middleware (unauthenticated, ability-denied, policy-denied).

The helper is wrapped in try/catch so logging failures never affect the request
path. Successful operations log at `info`; suspicious/denied requests log at
`warning`. Operators wanting a failures-only feed can set `LOG_AUDIT_LEVEL=warning`.

Includes a feature test suite covering the helper, the webhook providers and the
new auth/authorization log paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 14:50:37 +02:00
Andras Bacsai 1a603a10ed fix(models): replace forceFill/forceCreate with fill/create and add fillable guards
Replace all uses of `forceFill`, `forceCreate`, and `forceFill` with their
non-force equivalents across models, actions, controllers, and Livewire
components. Add explicit `$fillable` arrays to all affected Eloquent models
to enforce mass assignment protection.

Add ModelFillableCreationTest and ModelFillableRegressionTest to verify that
model creation respects fillable constraints and prevent regressions.
2026-03-31 13:45:31 +02:00
Andras Bacsai 1da1f32f0e refactor: use forceCreate() for internal model creation
Replace create() with forceCreate() across internal model creation operations to bypass mass assignment protection. This is appropriate for internal code that constructs complete model state without user input.

Add InternalModelCreationMassAssignmentTest to ensure internal model creation behavior is properly tested. Optimize imports by using shortened Livewire attribute references and removing unused imports.
2026-03-30 13:04:11 +02:00
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
elmariss 737ec521b6 fix: missing 422 error code in openapi spec 2025-10-12 14:20:45 +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 5ded100300 feat(api): add endpoints for managing environments in projects, including listing, creating, and deleting environments 2025-08-16 18:27:38 +02:00
Andras Bacsai a32342d126 feat(api): add create_environment endpoint to ProjectController for environment creation in projects 2025-08-15 20:24:32 +02:00
Laurence 1e7b15ae77 enhance: Add missing UUID to openapi spec 2025-04-09 17:52:12 +01: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 41688f24e3 Merge branch 'next' into fix/api--projects-apps-fixes 2024-12-18 10:49:45 +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
SierraJC 9e8d9e6a9e fix: invalid API response on missing project
API was returning 500 instead of 404 due to attempting to load environments for a non-existent project
2024-12-14 12:52:47 +11:00
Andras Bacsai 99705ee9f0 fix description 2024-11-12 10:25:58 +01:00
Andras Bacsai a9832e2783 Merge pull request #3949 from peaklabs-dev/fix-project-deletion
Fix: Projects can be deleted with resources
2024-11-07 13:43:56 +01:00
Lucas Michot 8e1444eaa7 Get rid of many useless blank lines 2024-10-31 17:44:01 +01:00
peaklabs-dev 5a38b21d95 fix project deletion and refactor some code 2024-10-18 13:48:41 +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 f73983e3dd Include project’s description in API response. 2024-09-09 09:44:43 -07:00
Matt Stein 44d417c07e Fix user-facing string case. 2024-09-09 09:38:40 -07:00
Andras Bacsai 08b9c79298 fix: Handle project not found error in environment_details API endpoint 2024-09-05 11:18:00 +02:00
Andras Bacsai dbad08f4dd Merge pull request #3288 from julienbeugras/fix-project-create-api-docs
Fix project create api docs
2024-09-05 11:16:05 +02:00
Andras Bacsai 25480fe624 fix: openapi endpoint urls 2024-09-04 10:09:10 +02:00
root ae4c889fa2 Fix API documentation for project creation endpoint 2024-09-02 11:05:58 +02:00
Andras Bacsai 2ea146333e fix: uuid in api docs type 2024-07-24 21:10:32 +02:00
Andras Bacsai f1e5b61970 feat: update API endpoint summaries 2024-07-23 14:36:44 +02:00
Andras Bacsai 189a8347ed feat: add server api endpoints 2024-07-23 14:20:53 +02:00
Andras Bacsai e96e8f6fec feat: add patch request to projects 2024-07-23 11:48:38 +02:00
Andras Bacsai 38299ab507 feat: create/delete project endpoints 2024-07-23 11:36:05 +02:00
Andras Bacsai 2d3a6a4528 openapi work work 2024-07-09 10:45:10 +02:00
Andras Bacsai b24a489c77 fix: api updates 2024-07-03 13:13:38 +02:00
Andras Bacsai da6f2da3d0 feat: lots of api endpoints 2024-07-01 16:26:50 +02:00