Issues (201)

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/Discovery/Binding/SyncBindingUuid.php (3 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
2
3
/*
4
 * This file is part of the puli/manager package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Discovery\Binding;
13
14
use LogicException;
15
use Puli\Discovery\Api\EditableDiscovery;
16
use Puli\Manager\Api\Discovery\BindingDescriptor;
17
use Puli\Manager\Transaction\AtomicOperation;
18
use Rhumsaa\Uuid\Uuid;
19
20
/**
21
 * Synchronizes a binding descriptor UUID with the discovery.
22
 *
23
 * The method {@link takeSnapshot()} must be called before executing the
24
 * operation. This method will record whether a binding descriptor is currently
25
 * enabled (i.e. loaded in the discovery) for that UUID.
26
 *
27
 * Once the operation is executed, another snapshot is taken. If the snapshots
28
 * differ, the binding descriptor for the UUID is then either bound to or
29
 * unbound from the discovery, depending on the outcome.
30
 *
31
 * @since  1.0
32
 *
33
 * @author Bernhard Schussek <[email protected]>
34
 */
35
class SyncBindingUuid implements AtomicOperation
36
{
37
    /**
38
     * @var Uuid
39
     */
40
    private $uuid;
41
42
    /**
43
     * @var EditableDiscovery
44
     */
45
    private $discovery;
46
47
    /**
48
     * @var BindingDescriptor
49
     */
50
    private $enabledBindingBefore;
51
52
    /**
53
     * @var BindingDescriptor
54
     */
55
    private $enabledBindingAfter;
56
57
    /**
58
     * @var BindingDescriptorCollection
59
     */
60
    private $bindingDescriptors;
61
62
    /**
63
     * @var bool
64
     */
65
    private $snapshotTaken = false;
66
67 24
    public function __construct(Uuid $uuid, EditableDiscovery $discovery, BindingDescriptorCollection $bindingDescriptors)
68
    {
69 24
        $this->uuid = $uuid;
70 24
        $this->discovery = $discovery;
71 24
        $this->bindingDescriptors = $bindingDescriptors;
72 24
    }
73
74
    /**
75
     * Records whether the UUID is currently enabled.
76
     */
77 24
    public function takeSnapshot()
78
    {
79 24
        $this->enabledBindingBefore = null;
80
81 24 View Code Duplication
        if ($this->bindingDescriptors->contains($this->uuid)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82 19
            $bindingDescriptor = $this->bindingDescriptors->get($this->uuid);
83
84 19
            if ($bindingDescriptor->isEnabled()) {
85
                // Clone so that rollback() works if the binding is unloaded
86 11
                $this->enabledBindingBefore = clone $bindingDescriptor;
87
            }
88
        }
89
90 24
        $this->snapshotTaken = true;
91 24
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96 23
    public function execute()
97
    {
98 23
        if (!$this->snapshotTaken) {
99
            throw new LogicException('takeSnapshot() was not called');
100
        }
101
102
        // Remember for rollback()
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
103 23
        $this->enabledBindingAfter = null;
104
105 23 View Code Duplication
        if ($this->bindingDescriptors->contains($this->uuid)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106 16
            $bindingDescriptor = $this->bindingDescriptors->get($this->uuid);
107
108 16
            if ($bindingDescriptor->isEnabled()) {
109
                // Clone so that rollback() works if the binding is unloaded
110 8
                $this->enabledBindingAfter = clone $bindingDescriptor;
111
            }
112
        }
113
114 23
        $this->syncBindingUuid($this->enabledBindingBefore, $this->enabledBindingAfter);
115 23
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120 7
    public function rollback()
121
    {
122 7
        $this->syncBindingUuid($this->enabledBindingAfter, $this->enabledBindingBefore);
123 7
    }
124
125 23
    private function syncBindingUuid(BindingDescriptor $enabledBefore = null, BindingDescriptor $enabledAfter = null)
126
    {
127 23
        if (!$enabledBefore && $enabledAfter) {
128 11
            $this->discovery->addBinding($enabledAfter->getBinding());
129 19
        } elseif ($enabledBefore && !$enabledAfter) {
130 13
            $this->discovery->removeBinding($enabledBefore->getUuid());
131 6
        } elseif ($enabledBefore && $enabledAfter && $enabledBefore->getBinding() != $enabledAfter->getBinding()) {
132 1
            $this->discovery->removeBinding($enabledBefore->getUuid());
133 1
            $this->discovery->addBinding($enabledAfter->getBinding());
134
        }
135 23
    }
136
}
137