Issues (41)

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/Component.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
/*
4
 * This file is part of the eluceo/iCal package.
5
 *
6
 * (c) Markus Poerschke <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Eluceo\iCal;
13
14
use Eluceo\iCal\Util\ComponentUtil;
15
16
/**
17
 * Abstract Calender Component.
18
 */
19
abstract class Component
20
{
21
    /**
22
     * Array of Components.
23
     *
24
     * @var Component[]
25
     */
26
    protected $components = [];
27
28
    /**
29
     * The order in which the components will be rendered during build.
30
     *
31
     * Not defined components will be appended at the end.
32
     *
33
     * @var array
34
     */
35
    private $componentsBuildOrder = ['VTIMEZONE', 'DAYLIGHT', 'STANDARD'];
36
37
    /**
38
     * The type of the concrete Component.
39
     *
40
     * @abstract
41
     *
42
     * @return string
43
     */
44
    abstract public function getType();
45
46
    /**
47
     * Building the PropertyBag.
48
     *
49
     * @abstract
50
     *
51
     * @return PropertyBag
52
     */
53
    abstract public function buildPropertyBag();
54
55
    /**
56
     * Adds a Component.
57
     *
58
     * If $key is given, the component at $key will be replaced else the component will be append.
59
     *
60
     * @param Component $component The Component that will be added
61
     * @param null      $key       The key of the Component
62
     */
63 9
    public function addComponent(self $component, $key = null)
64
    {
65 9
        if (null == $key) {
66 8
            $this->components[] = $component;
67
        } else {
68 1
            $this->components[$key] = $component;
69
        }
70 9
    }
71
72
    /**
73
     * Set all Components.
74
     *
75
     * @param Component[] $components The array of Component that will be set
76
     * @param null        $key        The key of the Component
0 ignored issues
show
There is no parameter named $key. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
77
     */
78 1
    public function setComponents(array $components)
79
    {
80 1
        $this->components = $components;
81
82 1
        return $this;
83
    }
84
85
    /**
86
     * Renders an array containing the lines of the iCal file.
87
     *
88
     * @return array
89
     */
90 18
    public function build()
91
    {
92 18
        $lines = [];
93
94 18
        $lines[] = sprintf('BEGIN:%s', $this->getType());
95
96
        /** @var $property Property */
97 18
        foreach ($this->buildPropertyBag() as $property) {
98 18
            foreach ($property->toLines() as $l) {
99 18
                $lines[] = $l;
100
            }
101
        }
102
103 18
        $this->buildComponents($lines);
104
105 18
        $lines[] = sprintf('END:%s', $this->getType());
106
107 18
        $ret = [];
108
109 18
        foreach ($lines as $line) {
110 18
            foreach (ComponentUtil::fold($line) as $l) {
111 18
                $ret[] = $l;
112
            }
113
        }
114
115 18
        return $ret;
116
    }
117
118
    /**
119
     * Renders the output.
120
     *
121
     * @return string
122
     */
123 18
    public function render()
124
    {
125 18
        return implode("\r\n", $this->build());
126
    }
127
128
    /**
129
     * Renders the output when treating the class as a string.
130
     *
131
     * @return string
132
     */
133 1
    public function __toString()
134
    {
135 1
        return $this->render();
136
    }
137
138
    /**
139
     * @param $lines
140
     *
141
     * @return array
142
     */
143 18
    private function buildComponents(array &$lines)
144
    {
145 18
        $componentsByType = [];
146
147
        /** @var $component Component */
148 18
        foreach ($this->components as $component) {
149 9
            $type = $component->getType();
150 9
            if (!isset($componentsByType[$type])) {
151 9
                $componentsByType[$type] = [];
152
            }
153 9
            $componentsByType[$type][] = $component;
154
        }
155
156
        // render ordered components
157 18
        foreach ($this->componentsBuildOrder as $type) {
158 18
            if (!isset($componentsByType[$type])) {
159 18
                continue;
160
            }
161 2
            foreach ($componentsByType[$type] as $component) {
162 2
                $this->addComponentLines($lines, $component);
163
            }
164 2
            unset($componentsByType[$type]);
165
        }
166
167
        // render all other
168 18
        foreach ($componentsByType as $components) {
169 7
            foreach ($components as $component) {
170 7
                $this->addComponentLines($lines, $component);
171
            }
172
        }
173 18
    }
174
175
    /**
176
     * @param Component $component
177
     */
178 9
    private function addComponentLines(array &$lines, self $component)
179
    {
180 9
        foreach ($component->build() as $l) {
181 9
            $lines[] = $l;
182
        }
183 9
    }
184
}
185