diff --git a/.gitea/workflows/security-scan.yml b/.gitea/workflows/security-scan.yml index c6d66cdb..48440d3c 100644 --- a/.gitea/workflows/security-scan.yml +++ b/.gitea/workflows/security-scan.yml @@ -18,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" \ 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); 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) {