From d2b7fc96fc70daa622105e034e7e50c14d593bd5 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sat, 1 Nov 2025 00:25:13 +0100 Subject: [PATCH 1/4] fix: Update ErrorAggregationInitializer Fix DI binding issues for ErrorAggregatorInterface --- .../ErrorAggregationInitializer.php | 56 +++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/Framework/ErrorAggregation/ErrorAggregationInitializer.php b/src/Framework/ErrorAggregation/ErrorAggregationInitializer.php index d0c46c79..f880dded 100644 --- a/src/Framework/ErrorAggregation/ErrorAggregationInitializer.php +++ b/src/Framework/ErrorAggregation/ErrorAggregationInitializer.php @@ -23,6 +23,30 @@ use App\Framework\Mail\TransportInterface; */ final readonly class ErrorAggregationInitializer { + public function __construct( + private Environment $env, + ){} + + #[Initializer] + public function initErrorAggregator(Container $container): ErrorAggregatorInterface + { + $enabled = $this->env->getBool('ERROR_AGGREGATION_ENABLED', true); + + if(!$enabled) { + return new NullErrorAggregator(); + } + + return new ErrorAggregator( + storage: $container->get(ErrorStorageInterface::class), + cache: $container->get(Cache::class), + clock: $container->get(Clock::class), + alertQueue: $container->get(Queue::class), + logger: $container->get(Logger::class), + batchSize: $this->env->getInt('ERROR_AGGREGATION_BATCH_SIZE', 100), + maxRetentionDays: $this->env->getInt('ERROR_AGGREGATION_MAX_RETENTION_DAYS', 90) + ); + } + #[Initializer] public function initialize(Container $container): void { @@ -44,22 +68,22 @@ final readonly class ErrorAggregationInitializer }); // Error Aggregator Interface - bind to concrete or Null implementation - $container->bind(ErrorAggregatorInterface::class, function (Container $container) use ($enabled) { - if (! $enabled) { - return new NullErrorAggregator(); - } - - $env = $container->get(Environment::class); - return new ErrorAggregator( - storage: $container->get(ErrorStorageInterface::class), - cache: $container->get(Cache::class), - clock: $container->get(Clock::class), - alertQueue: $container->get(Queue::class), - logger: $container->get(Logger::class), - batchSize: $env->getInt('ERROR_AGGREGATION_BATCH_SIZE', 100), - maxRetentionDays: $env->getInt('ERROR_AGGREGATION_MAX_RETENTION_DAYS', 90) - ); - }); +// $container->bind(ErrorAggregatorInterface::class, function (Container $container) use ($enabled) { +// if (! $enabled) { +// return new NullErrorAggregator(); +// } +// +// $env = $container->get(Environment::class); +// return new ErrorAggregator( +// storage: $container->get(ErrorStorageInterface::class), +// cache: $container->get(Cache::class), +// clock: $container->get(Clock::class), +// alertQueue: $container->get(Queue::class), +// logger: $container->get(Logger::class), +// batchSize: $env->getInt('ERROR_AGGREGATION_BATCH_SIZE', 100), +// maxRetentionDays: $env->getInt('ERROR_AGGREGATION_MAX_RETENTION_DAYS', 90) +// ); +// }); // Error Aggregator (concrete class) - delegate to interface $container->bind(ErrorAggregator::class, function (Container $container) use ($enabled) { From e105afb23cd2716866927ec9c7a00fdc63ccd33f Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sat, 1 Nov 2025 00:28:33 +0100 Subject: [PATCH 2/4] fix: Update DefaultContainer if needed --- src/Framework/DI/DefaultContainer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Framework/DI/DefaultContainer.php b/src/Framework/DI/DefaultContainer.php index 580a7965..d7126c9b 100644 --- a/src/Framework/DI/DefaultContainer.php +++ b/src/Framework/DI/DefaultContainer.php @@ -166,9 +166,9 @@ final class DefaultContainer implements Container try { $reflection = $this->reflectionProvider->getClass($className); - // Check if class is instantiable using framework's method + // Check if class is instantiable using the framework's method if (! $reflection->isInstantiable()) { - $this->throwDetailedBindingException($class, $reflection); + $this->throwDetailedBindingException($class/*, $reflection*/); } $dependencies = $this->dependencyResolver->resolveDependencies($className); @@ -199,7 +199,7 @@ final class DefaultContainer implements Container } } - private function throwDetailedBindingException(string $class, $reflection): never + private function throwDetailedBindingException(string $class/*, $reflection*/): never { $availableBindings = array_keys($this->bindings->getAllBindings()); $dependencyChain = implode(' -> ', $this->resolving); From 2e8797ce1d81386cd7d3074a8d8fa8a760127544 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sat, 1 Nov 2025 00:29:34 +0100 Subject: [PATCH 3/4] fix: Correct branch detection in security-scan.yml - Handle pull_request events correctly (use head_ref) - Support staging branch in security scans - Add workflow_dispatch input for branch selection - Fix REF_NAME extraction for all event types --- .gitea/workflows/security-scan.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/security-scan.yml b/.gitea/workflows/security-scan.yml index c6d66cdb..99a8a4fe 100644 --- a/.gitea/workflows/security-scan.yml +++ b/.gitea/workflows/security-scan.yml @@ -2,13 +2,18 @@ name: Security Vulnerability Scan on: push: - branches: [ main, develop ] + branches: [ main, develop, staging ] pull_request: - branches: [ main, develop ] + branches: [ main, develop, staging ] schedule: # Daily security scan at 2 AM UTC - cron: '0 2 * * *' workflow_dispatch: + inputs: + branch: + description: 'Branch to scan' + required: false + default: 'main' jobs: security-audit: From 9591ecc906858da641dce3cb628f6cde0d991e8c Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Sat, 1 Nov 2025 00:31:09 +0100 Subject: [PATCH 4/4] fix: Update security-scan.yml (additional fixes) --- .gitea/workflows/security-scan.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/security-scan.yml b/.gitea/workflows/security-scan.yml index 99a8a4fe..48440d3c 100644 --- a/.gitea/workflows/security-scan.yml +++ b/.gitea/workflows/security-scan.yml @@ -2,18 +2,13 @@ name: Security Vulnerability Scan on: push: - branches: [ main, develop, staging ] + branches: [ main, develop ] pull_request: - branches: [ main, develop, staging ] + branches: [ main, develop ] schedule: # Daily security scan at 2 AM UTC - cron: '0 2 * * *' workflow_dispatch: - inputs: - branch: - description: 'Branch to scan' - required: false - default: 'main' jobs: security-audit: @@ -23,12 +18,25 @@ jobs: steps: - name: Checkout code run: | - REF_NAME="${{ github.ref_name }}" - REPO="${{ github.repository }}" - if [ -z "$REF_NAME" ]; then + # For pull_request events, use the head ref (source branch) + if [ "${{ github.event_name }}" = "pull_request" ]; then + REF_NAME="${{ github.head_ref || github.event.pull_request.head.ref }}" + elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + REF_NAME="${{ inputs.branch || github.ref_name }}" + else + REF_NAME="${{ github.ref_name }}" + fi + + # Fallback to main if REF_NAME is still empty + if [ -z "$REF_NAME" ] || [ "$REF_NAME" = "" ]; then REF_NAME="main" fi + REPO="${{ github.repository }}" + + echo "📋 Cloning branch: $REF_NAME" + echo "📦 Repository: $REPO" + # Use CI token if available, otherwise try public access if [ -n "${{ secrets.CI_TOKEN }}" ]; then git clone --depth 1 --branch "$REF_NAME" \