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 (17)

Security Analysis    no request data  

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/EntryToObjects/EntryToObjectsService.php (1 issue)

Labels
Severity

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
2
/**
3
 * @link    https://github.com/old-town/workflow-zf2-toolkit
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Toolkit\EntryToObjects;
7
8
use OldTown\Workflow\ZF2\Toolkit\EntityRepository\DoctrineWorkflowStory\ExtEntryRepository;
9
use Zend\Serializer\AdapterPluginManager as SerializerManager;
10
use OldTown\Workflow\ZF2\Service\Annotation as WFS;
11
use Zend\Serializer\Adapter\AdapterInterface as Serializer;
12
use OldTown\Workflow\ZF2\Toolkit\Entity\DoctrineWorkflowStory\ExtEntry;
13
use OldTown\Workflow\ZF2\Toolkit\Entity\DoctrineWorkflowStory\ObjectInfo;
14
use OldTown\Workflow\ZF2\Toolkit\Options\ModuleOptions;
15
use ReflectionClass;
16
use OldTown\Workflow\ZF2\ServiceEngine\WorkflowServiceInterface;
17
use OldTown\Workflow\ZF2\Toolkit\DoctrineWorkflowStory\DoctrineWorkflowStory;
18
19
/**
20
 * Class EntryToObjectsService
21
 *
22
 * @package OldTown\Workflow\ZF2\Toolkit\EntryToObjects
23
 */
24
class EntryToObjectsService
25
{
26
    /**
27
     * Псевдоним для объектов по умолчанию
28
     *
29
     * @var string
30
     */
31
    const DEFAULT_OBJECT = 'defaultObject';
32
33
    /**
34
     * Менеджер для получения адапторов отвечающих за сериализацию данных
35
     *
36
     * @var SerializerManager
37
     */
38
    protected $serializerManager;
39
40
    /**
41
     * Сериалайзер по умолчанию
42
     *
43
     * @var string
44
     */
45
    protected $serializerName = 'json';
46
47
    /**
48
     * Настройки модуля
49
     *
50
     * @var ModuleOptions
51
     */
52
    protected $moduleOptions;
53
54
    /**
55
     * Сервис для работы с workflow
56
     *
57
     * @var WorkflowServiceInterface
58
     */
59
    protected $workflowService;
60
61
    /**
62
     * Сериалайзер
63
     *
64
     * @var Serializer
65
     */
66
    protected $serializer;
67
68
    /**
69
     * DoctrineWorkflowStoryService constructor.
70
     *
71
     * @param array $options
72
     */
73
    public function __construct(array $options = [])
74
    {
75
        $initOptions = [
76
            array_key_exists('serializerManager', $options) ? $options['serializerManager'] : null,
77
            array_key_exists('moduleOptions', $options) ? $options['moduleOptions'] : null,
78
            array_key_exists('workflowService', $options) ? $options['workflowService'] : null
79
        ];
80
        call_user_func_array([$this, 'init'], $initOptions);
81
    }
82
83
    /**
84
     * @param SerializerManager        $serializerManager
85
     * @param ModuleOptions            $moduleOptions
86
     * @param WorkflowServiceInterface $workflowService
87
     */
88
    protected function init(SerializerManager $serializerManager, ModuleOptions $moduleOptions, WorkflowServiceInterface $workflowService)
89
    {
90
        $this->setSerializerManager($serializerManager);
91
        $this->setModuleOptions($moduleOptions);
92
        $this->setWorkflowService($workflowService);
93
    }
94
95
    /**
96
     *
97
     *
98
     * @param ExtEntry               $entry
99
     * @param mixed                  $object
100
     * @param string                 $objectAlias
101
     * @param DoctrineWorkflowStory $store
102
     *
103
     * @throws Exception\InvalidWorkflowStoreException
104
     * @throws \OldTown\Workflow\Spi\Doctrine\Exception\DoctrineRuntimeException
105
     * @throws Exception\RuntimeException
106
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
107
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
108
     * @throws \Zend\ServiceManager\Exception\RuntimeException
109
     * @throws \Zend\Serializer\Exception\ExceptionInterface
110
     */
111
    public function bindObjectToWorkflowEntry(ExtEntry $entry, $object, $objectAlias = self::DEFAULT_OBJECT, DoctrineWorkflowStory $store)
112
    {
113
        $em = $store->getEntityManager();
114
115
        $objectClass = get_class($object);
116
        $metadata = $em->getClassMetadata($objectClass);
117
118
        $serializerName = $this->getSerializerName();
119
        /** @var Serializer $serializer */
120
        $serializer = $this->getSerializerManager()->get($serializerName);
121
122
        $id = $metadata->getIdentifierValues($object);
123
        $prepareId = [];
124
        foreach ($id as $idField => $idValue) {
125
            $prepareId[$idField] = (string)$idValue;
126
        }
127
        $serializedId = $serializer->serialize($prepareId);
128
129
        $objectInfoClass = $this->getModuleOptions()->getEntityClassName('DoctrineWorkflowStory\\ObjectInfo');
130
131
        $r = new ReflectionClass($objectInfoClass);
132
        /** @var  ObjectInfo $objectInfo */
133
        $objectInfo = $r->newInstance();
134
135
        $objectInfo->setClassName($objectClass);
136
        $objectInfo->setObjectId($serializedId);
137
        $objectInfo->setAlias($objectAlias);
138
        $objectInfo->addEntry($entry);
139
140
141
        $entry->addObjectInfo($objectInfo);
142
143
        $em->persist($objectInfo);
144
        $em->flush();
145
    }
146
147
    /**
148
     * Востановить объект привязанный к процессу
149
     *
150
     * @WFS\ResultVariable(name="resultVariableName")
151
     *
152
     *
153
     * @param ExtEntry              $entry
154
     * @param string                $objectAlias
155
     * @param DoctrineWorkflowStory $store
156
     *
157
     * @return mixed
158
     *
159
     * @throws \OldTown\Workflow\Spi\Doctrine\Exception\DoctrineRuntimeException
160
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
161
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
162
     * @throws \Zend\ServiceManager\Exception\RuntimeException
163
     * @throws \Zend\Serializer\Exception\ExceptionInterface
164
     * @throws Exception\InvalidRestoreObjectException
165
     * @throws Exception\InvalidArgumentException
166
     */
167
    public function restoreObjectBindingToEntry(ExtEntry $entry, $objectAlias = self::DEFAULT_OBJECT, DoctrineWorkflowStory $store)
168
    {
169
        $objectsInfo = $entry->getObjectsInfo();
170
171
        foreach ($objectsInfo as $objectInfo) {
172
            if ($objectAlias === $objectInfo->getAlias()) {
173
                $className = $objectInfo->getClassName();
174
175
                $em = $store->getEntityManager();
176
177
                $serializer = $this->getSerializer();
178
179
                $serializedId = $objectInfo->getObjectId();
180
                $id = $serializer->unserialize($serializedId);
181
182
                $object = $em->getRepository($className)->find($id);
183
184
                if (!is_object($object)) {
185
                    $errMsg = sprintf('Invalid restore object. Alias: %s. Class: %s. Id: %s', $objectAlias, $className, $serializedId);
186
                    throw new Exception\InvalidRestoreObjectException($errMsg);
187
                }
188
189
                return $object;
190
            }
191
        }
192
193
        $errMsg = sprintf('Invalid object alias: %s', $objectAlias);
194
        throw new Exception\InvalidArgumentException($errMsg);
195
    }
196
197
198
    /**
199
     * Получене информации о процессе на основе данных о объектах привязанных к процессу
200
     *
201
     * Структура objectsInfo
202
     * $objectsInfo = [
203
     *      $entityClassName => [
204
     *          $propertyName => $idValue
205
     *      ]
206
     * ]
207
     *
208
     * Где:
209
     * $entityClassName - имя класса сущности которая привязана к процессу workflow
210
     * $propertyName    - имя свойства сущности являющееся первичным ключем (или часть составного первичного ключа)
211
     * $idValue         - значение $propertyName
212
     *
213
     *
214
     * @param string $managerName
215
     * @param string $workflowName
216
     * @param array  $objectsInfo
217
     *
218
     * @return ExtEntry|null
219
     *
220
     * @throws Exception\InvalidGetEntryByObjectsInfoException
221
     * @throws \Zend\Serializer\Exception\ExceptionInterface
222
     */
223
    public function getEntryByObjectsInfo($managerName, $workflowName, array $objectsInfo = [])
224
    {
225
        try {
226
            $workflowManager = $this->getWorkflowService()->getWorkflowManager($managerName);
227
228
229
            $store = $workflowManager->getConfiguration()->getWorkflowStore();
230
231
            if (!$store instanceof DoctrineWorkflowStory) {
232
                $errMsg = sprintf('Workflow store not implement %s', DoctrineWorkflowStory::class);
233
                throw new Exception\InvalidWorkflowStoreException($errMsg);
234
            }
235
            $em = $store->getEntityManager();
236
237
            $serializer = $this->getSerializer();
238
            $objectHash = [];
239
            foreach ($objectsInfo as $entityClassName => $item) {
240
                $classMetadata = $em->getClassMetadata($entityClassName);
241
                $identifierMetadata = $classMetadata->getIdentifier();
242
243
                $id = [];
244
245
                foreach ($identifierMetadata as $propertyName) {
246
                    if (!array_key_exists($propertyName, $item)) {
247
                        $errMsg = sprintf('Property %s not found', $propertyName);
248
                        throw new Exception\InvalidGetEntryByObjectsInfoException($errMsg);
249
                    }
250
                    $id[$propertyName] = (string)$item[$propertyName];
251
                }
252
253
                $serializedId = $serializer->serialize($id);
254
255
                $hash = $entityClassName . '_' . $serializedId;
256
                $base64Hash = base64_encode($hash);
257
258
                $objectHash[$base64Hash] = $base64Hash;
259
            }
260
261
            $extEntryClassName = $this->getModuleOptions()->getEntityClassName('DoctrineWorkflowStory\ExtEntry');
262
            /** @var ExtEntryRepository $extEntryRepository */
263
            $extEntryRepository = $em->getRepository($extEntryClassName);
0 ignored issues
show
It seems like $extEntryClassName defined by $this->getModuleOptions(...rkflowStory\\ExtEntry') on line 261 can also be of type array; however, Doctrine\Common\Persiste...anager::getRepository() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
264
265
            $entry = $extEntryRepository->findEntryByObjectInfo($workflowName, $objectHash);
266
        } catch (\Exception $e) {
267
            throw new Exception\InvalidGetEntryByObjectsInfoException($e->getMessage(), $e->getCode(), $e);
268
        }
269
        return $entry;
270
    }
271
272
    /**
273
     * @return SerializerManager
274
     */
275
    public function getSerializerManager()
276
    {
277
        return $this->serializerManager;
278
    }
279
280
    /**
281
     * @param SerializerManager $serializerManager
282
     *
283
     * @return $this
284
     */
285
    public function setSerializerManager(SerializerManager $serializerManager)
286
    {
287
        $this->serializerManager = $serializerManager;
288
289
        return $this;
290
    }
291
292
    /**
293
     * @return string
294
     */
295
    public function getSerializerName()
296
    {
297
        return $this->serializerName;
298
    }
299
300
    /**
301
     * @param string $serializerName
302
     *
303
     * @return $this
304
     */
305
    public function setSerializerName($serializerName)
306
    {
307
        $this->serializerName = $serializerName;
308
309
        return $this;
310
    }
311
312
    /**
313
     * @return ModuleOptions
314
     */
315
    public function getModuleOptions()
316
    {
317
        return $this->moduleOptions;
318
    }
319
320
    /**
321
     * @param ModuleOptions $moduleOptions
322
     *
323
     * @return $this
324
     */
325
    public function setModuleOptions(ModuleOptions $moduleOptions)
326
    {
327
        $this->moduleOptions = $moduleOptions;
328
329
        return $this;
330
    }
331
332
    /**
333
     * Сервис для работы с workflow
334
     *
335
     * @return WorkflowServiceInterface
336
     */
337
    public function getWorkflowService()
338
    {
339
        return $this->workflowService;
340
    }
341
342
    /**
343
     * Устанавливает сервис для работы с workflow
344
     *
345
     * @param WorkflowServiceInterface $workflowService
346
     *
347
     * @return $this
348
     */
349
    public function setWorkflowService(WorkflowServiceInterface $workflowService)
350
    {
351
        $this->workflowService = $workflowService;
352
353
        return $this;
354
    }
355
356
357
    /**
358
     * @return Serializer
359
     *
360
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
361
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
362
     * @throws \Zend\ServiceManager\Exception\RuntimeException
363
     */
364
    public function getSerializer()
365
    {
366
        if ($this->serializer) {
367
            return $this->serializer;
368
        }
369
370
        $serializerName = $this->getSerializerName();
371
        /** @var Serializer $serializer */
372
        $serializer = $this->getSerializerManager()->get($serializerName);
373
        $this->serializer = $serializer;
374
375
        return $this->serializer;
376
    }
377
}
378