Issues (16)

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/PartitionContainer.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
2
3
namespace drupol\phpartition;
4
5
/**
6
 * Class PartitionContainer.
7
 *
8
 * @package drupol\phpartition
9
 */
10
class PartitionContainer extends \SplHeap
11
{
12
13
  /**
14
   * The algorithm to use.
15
   *
16
   * @var BasePartitionAlgorithm
17
   */
18
    protected $algo;
19
20
  /**
21
   * The number of partition to use.
22
   *
23
   * @var int
24
   */
25
    protected $size;
26
27
  /**
28
   * Override compare method.
29
   *
30
   * @param Partition $partitionA
31
   *   The first partition.
32
   * @param Partition $partitionB
33
   *   The second partition.
34
   *
35
   *   {@inheritdoc}.
36
   */
37 14
    public function compare($partitionA, $partitionB)
38
    {
39 14
        $partitionAWeight = $partitionA->getAlgo()->getPartitionWeight($partitionA);
40 14
        $partitionBWeight = $partitionB->getAlgo()->getPartitionWeight($partitionB);
41
42 14
        if ($partitionAWeight == $partitionBWeight) {
43 14
            return 0;
44
        }
45
46 14
        return ($partitionAWeight > $partitionBWeight) ? -1 : +1;
47
    }
48
49
  /**
50
   * Set the size of the container.
51
   *
52
   * @param int $size
53
   *   The size.
54
   */
55 14
    public function setSize($size)
56
    {
57 14
        $this->size = $size;
58
59 14
        for ($i = 0; $i < $size; $i++) {
60 14
            $subset = new Partition();
61 14
            $subset->setAlgo($this->getAlgo());
62 14
            $this->insert($subset);
63 14
        }
64 14
    }
65
66
  /**
67
   * Return the size of the container.
68
   *
69
   * @return int
70
   *   The number of partitions the container has.
71
   */
72 14
    public function getSize()
73
    {
74 14
        return $this->size;
75
    }
76
77
  /**
78
   * Add items to the partition.
79
   *
80
   * @param PartitionItem[] $items
81
   *   The items to add.
82
   */
83 6
    public function addItemsToPartition(array $items = array())
84
    {
85 6
        foreach ($items as $item) {
86 6
            $this->addItemToPartition($item);
87 6
        }
88 6
    }
89
90
  /**
91
   * Add an item to the first partition.
92
   *
93
   * @param \drupol\phpartition\PartitionItem $item
94
   *   The item to add.
95
   */
96 6
    public function addItemToPartition(PartitionItem $item)
97
    {
98 6
        $this->top();
99 6
        $subset = $this->extract();
100 6
        $subset->addItem($item);
101 6
        $this->insert($subset);
102 6
    }
103
104
  /**
105
   * Get the partition in the container.
106
   *
107
   * @return Partition[]
108
   *   An array of partitions.
109
   */
110 14 View Code Duplication
    public function getPartitions()
0 ignored issues
show
This method seems to be duplicated in 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...
111
    {
112 14
        $data = array();
113 14
        $clone = clone $this;
114
115 14
        for ($clone->top(); $clone->valid(); $clone->next()) {
116 14
            $data[] = $clone->current();
117 14
        }
118
119 14
        return $data;
120
    }
121
122
  /**
123
   * Return the items from each partitions in the container.
124
   *
125
   * @return mixed[]
126
   *   The items.
127
   */
128 14 View Code Duplication
    public function getPartitionsItemsArray()
0 ignored issues
show
This method seems to be duplicated in 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...
129
    {
130 14
        $data = array();
131
132 14
        foreach ($this->getPartitions() as $subset) {
133 14
            $data[] = $subset->getRawItems();
134 14
        }
135
136 14
        return array_values(array_filter($data));
137
    }
138
139
  /**
140
   * Set the algorithm to use.
141
   *
142
   * @param \drupol\phpartition\BasePartitionAlgorithm $algo
143
   *   The algorithm.
144
   */
145 14
    public function setAlgo(BasePartitionAlgorithm $algo)
146
    {
147 14
        $this->algo = $algo;
148 14
    }
149
150
  /**
151
   * Get the algorithm.
152
   *
153
   * @return BasePartitionAlgorithm
154
   *   The algorithm.
155
   */
156 14
    public function getAlgo()
157
    {
158 14
        return $this->algo;
159
    }
160
}
161