GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (10)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Console/RunProjectionCommand.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php declare(strict_types=1);
2
3
namespace SmoothPhp\LaravelAdapter\Console;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Contracts\Config\Repository;
7
use Illuminate\Contracts\Foundation\Application;
8
use Illuminate\Database\DatabaseManager;
9
use Illuminate\Support\Collection;
10
use SmoothPhp\Contracts\Domain\DomainMessage;
11
use SmoothPhp\Contracts\EventDispatcher\EventDispatcher;
12
use SmoothPhp\Contracts\EventDispatcher\Subscriber;
13
use SmoothPhp\Contracts\EventStore\EventStore;
14
use SmoothPhp\Contracts\Projections\ProjectionServiceProvider;
15
use SmoothPhp\Domain\DomainEventStream;
16
17
/**
18
 * Class RunProjectionCommand
19
 * @package SmoothPhp\LaravelAdapter\Console
20
 * @author Simon Bennett <[email protected]>
21
 */
22
final class RunProjectionCommand extends Command
23
{
24
    /**
25
     * The name and signature of the console command.
26
     *
27
     * @var string
28
     */
29
    protected $signature = 'smoothphp:project {projections} {--transactions}';
30
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Run Projections';
37
38
    /** @var Repository */
39
    private $config;
40
41
    /** @var EventStore */
42
    private $eventStore;
43
    /** @var Application */
44
    private $application;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
45
    /** @var DatabaseManager */
46
    private $databaseManager;
47
48
    /**
49
     * RunProjectionCommand constructor.
50
     * @param Repository $config
51
     * @param EventStore $eventStore
52
     * @param Application $application
53
     * @param DatabaseManager $databaseManager
54
     */
55
    public function __construct(
56
        Repository $config,
57
        EventStore $eventStore,
58
        Application $application,
59
        DatabaseManager $databaseManager
60
    ) {
61
        parent::__construct();
62
        $this->config = $config;
63
        $this->eventStore = $eventStore;
64
        $this->application = $application;
65
        $this->databaseManager = $databaseManager;
66
    }
67
68
    /**
69
     * Execute the console command.
70
     *
71
     * @return mixed
72
     * @throws \Exception
73
     */
74
    public function handle()
75
    {
76
        $projectionRequest = collect(explode(',', $this->argument('projections')));
77
78
        $projectionsServiceProviders = $projectionRequest->each(
79
            function ($projectionName) {
80
                if (!isset($this->config->get('cqrses.projections_service_providers')[$projectionName])) {
81
                    $this->error("{$projectionName} Does not exist, check cqrses config");
82
83
                    exit();
84
                }
85
            }
86
        )->map(
87
            function ($projectionName) {
88
                return $this->application->make(
89
                    $this->config->get('cqrses.projections_service_providers')[$projectionName]
90
                );
91
            }
92
        )->each(
93
            function (ProjectionServiceProvider $projectionClass) {
94
                $this->downMigration($projectionClass);
95
            }
96
        )->each(
97
            function (ProjectionServiceProvider $projectionClass) {
98
                $this->upMigration($projectionClass);
99
            }
100
        );
101
102
        /** @var Collection|Subscriber[] $projections */
103
        $projections = $projectionsServiceProviders->map(
104
            function (ProjectionServiceProvider $projectServiceProvider) {
105
                return collect($projectServiceProvider->getProjections())->map(
106
                    function ($projection) {
107
                        return $this->application->make($projection);
108
                    }
109
                );
110
            }
111
        )->collapse();
112
113
        $events = $projections->map(
114
            function (Subscriber $subscriber) {
115
                return array_keys($subscriber->getSubscribedEvents());
116
            }
117
        )->collapse()->map(
118
            function ($eventClassName) {
119
                return str_replace('\\', '.', $eventClassName);
120
            }
121
        );
122
123
        $this->replayEvents($projections, $events->toArray());
124
    }
125
126
    /**
127
     * @param ProjectionServiceProvider $projectionServiceProvider
128
     */
129
    public function downMigration(ProjectionServiceProvider $projectionServiceProvider)
130
    {
131
        $response = $projectionServiceProvider->down();
132
        $this->line($response ?? 'Migrated Down: ' . \get_class($projectionServiceProvider));
133
    }
134
135
    /**
136
     * @param ProjectionServiceProvider $projectionServiceProvider
137
     */
138
    public function upMigration(ProjectionServiceProvider $projectionServiceProvider)
139
    {
140
        $response = $projectionServiceProvider->up();
141
        $this->line($response ?? 'Migrated Up: ' . \get_class($projectionServiceProvider));
142
    }
143
144
    /**
145
     * @param Collection|Subscriber[]
146
     * @param string[] $events
147
     *
148
     * @throws \Exception
149
     */
150
    protected function replayEvents($projections, $events)
151
    {
152
        $eventCount = $this->eventStore->getEventCountByTypes($events);
153
        $take = (int)$this->config->get('cqrses.rebuild_transaction_size', 1000);
154
155
        $this->output->progressStart($eventCount);
156
        $dispatcher = $this->buildAndRegisterDispatcher($projections);
157
158
        /** @var DomainEventStream $eventStream */
159
        foreach ($this->eventStore->getEventsByType($events, $take) as $eventStream) {
160
            if ($this->option('transactions')) {
161
                $this->databaseManager->connection()->beginTransaction();
162
            }
163
            foreach ($eventStream as $eventRow) {
164
                $this->dispatchEvent($dispatcher, $eventRow);
165
            }
166
            if ($this->option('transactions')) {
167
                $this->databaseManager->connection()->commit();
168
            }
169
            $this->output->progressAdvance($take);
170
        }
171
172
        $this->output->progressFinish();
173
        $this->line((memory_get_peak_usage(true) / 1024 / 1024) . "mb Peak Usage", false);
0 ignored issues
show
false is of type boolean, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
174
    }
175
176
    /**
177
     * @param EventDispatcher $eventDispatcher
178
     * @param $eventRow
179
     */
180
    protected function dispatchEvent(EventDispatcher $eventDispatcher, DomainMessage $eventRow)
181
    {
182
        $eventDispatcher->dispatch(
183
            $eventRow->getType(),
184
            [
185
                $eventRow->getPayload(),
186
            ],
187
            true
188
        );
189
    }
190
191
    /**
192
     * @param Collection $projections
193
     * @return EventDispatcher
194
     */
195
    protected function buildAndRegisterDispatcher($projections)
196
    {
197
        /** @var EventDispatcher $dispatcher */
198
        $dispatcher = $this->application->make(
199
            $this->config->get(
200
                'cqrses.rebuild_event_dispatcher',
201
                $this->config->get('cqrses.event_dispatcher')
202
            )
203
        );
204
205
        $projections->each(
206
            function ($projection) use ($dispatcher) {
207
                $dispatcher->addSubscriber($projection);
208
            }
209
        );
210
211
        return $dispatcher;
212
    }
213
}
214