Issues (3)

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/Xlsx/Spreadsheet.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 Akeneo\Component\SpreadsheetParser\Xlsx;
4
5
use Akeneo\Component\SpreadsheetParser\SpreadsheetInterface;
6
7
/**
8
 * Represents an XLSX spreadsheet
9
 *
10
 * @author    Antoine Guigan <[email protected]>
11
 * @copyright 2014 Akeneo SAS (http://www.akeneo.com)
12
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
13
 */
14
class Spreadsheet implements SpreadsheetInterface
15
{
16
17
    /**
18
     * @staticvar string Path to the relationships file inside the XLSX archive
19
     */
20
    const RELATIONSHIPS_PATH = 'xl/_rels/workbook.xml.rels';
21
22
    /**
23
     * @staticvar string Path to the spreadsheets file inside the XLSX archive
24
     */
25
    const WORKBOOK_PATH = 'xl/workbook.xml';
26
27
    /**
28
     * @var RelationshipsLoader
29
     */
30
    protected $relationshipsLoader;
31
32
    /**
33
     * @var ValueTransformerFactory
34
     */
35
    protected $valueTransformerFactory;
36
37
    /**
38
     *
39
     * @var SharedStringsLoader
40
     */
41
    protected $sharedStringsLoader;
42
43
    /**
44
     *
45
     * @var RowIteratorFactory
46
     */
47
    protected $rowIteratorFactory;
48
49
    /**
50
     * @var Archive
51
     */
52
    protected $archive;
53
54
    /**
55
     * @var StylesLoader
56
     */
57
    protected $stylesLoader;
58
59
    /**
60
     * @var WorksheetListReader
61
     */
62
    protected $worksheetListReader;
63
64
    /**
65
     * @var Relationships
66
     */
67
    private $relationships;
68
69
    /**
70
     * @var ValueTransformer
71
     */
72
    private $valueTransformer;
73
74
    /**
75
     * @var SharedStrings
76
     */
77
    private $sharedStrings;
78
79
    /**
80
     * @var array
81
     */
82
    private $worksheetPaths;
83
84
    /**
85
     * @var Styles
86
     */
87
    private $styles;
88
89
    /**
90
     * Constructor
91
     *
92
     * @param Archive                 $archive
93
     * @param RelationshipsLoader     $relationshipsLoader
94
     * @param SharedStringsLoader     $sharedStringsLoader
95
     * @param StylesLoader            $stylesLoader
96
     * @param WorksheetListReader     $worksheetListReader
97
     * @param ValueTransformerFactory $valueTransformerFactory
98
     * @param RowIteratorFactory      $rowIteratorFactory
99
     */
100 View Code Duplication
    public function __construct(
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...
101
        Archive $archive,
102
        RelationshipsLoader $relationshipsLoader,
103
        SharedStringsLoader $sharedStringsLoader,
104
        StylesLoader $stylesLoader,
105
        WorksheetListReader $worksheetListReader,
106
        ValueTransformerFactory $valueTransformerFactory,
107
        RowIteratorFactory $rowIteratorFactory
108
    ) {
109
        $this->archive = $archive;
110
        $this->relationshipsLoader = $relationshipsLoader;
111
        $this->sharedStringsLoader = $sharedStringsLoader;
112
        $this->stylesLoader = $stylesLoader;
113
        $this->worksheetListReader = $worksheetListReader;
114
        $this->valueTransformerFactory = $valueTransformerFactory;
115
        $this->rowIteratorFactory = $rowIteratorFactory;
116
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121
    public function getWorksheets()
122
    {
123
        return array_keys($this->getWorksheetPaths());
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129
    public function createRowIterator($worksheetIndex, array $options = [])
130
    {
131
        $paths = array_values($this->getWorksheetPaths());
132
133
        return $this->rowIteratorFactory->create(
134
            $this->getValueTransformer(),
135
            $this->archive->extract($paths[$worksheetIndex]),
136
            $options,
137
            $this->archive
138
        );
139
    }
140
141
    /**
142
     * {@inheritdoc}
143
     */
144
    public function getWorksheetIndex($name)
145
    {
146
        return array_search($name, $this->getWorksheets());
147
    }
148
149
    /**
150
     * @return Relationships
151
     */
152
    protected function getRelationships()
153
    {
154
        if (!$this->relationships) {
155
            $path = $this->archive->extract(static::RELATIONSHIPS_PATH);
156
            $this->relationships = $this->relationshipsLoader->open($path);
157
        }
158
159
        return $this->relationships;
160
    }
161
162
    /**
163
     * @return ValueTransformer
164
     */
165
    protected function getValueTransformer()
166
    {
167
        if (!$this->valueTransformer) {
168
            $this->valueTransformer = $this->valueTransformerFactory->create(
169
                $this->getSharedStrings(),
170
                $this->getStyles()
171
            );
172
        }
173
174
        return $this->valueTransformer;
175
    }
176
177
    /**
178
     * @return SharedStrings
179
     */
180
    protected function getSharedStrings()
181
    {
182
        if (!$this->sharedStrings) {
183
            $path = $this->archive->extract($this->relationships->getSharedStringsPath());
184
            $this->sharedStrings = $this->sharedStringsLoader->open($path, $this->archive);
185
        }
186
187
        return $this->sharedStrings;
188
    }
189
190
    /**
191
     * @return array
192
     */
193
    protected function getWorksheetPaths()
194
    {
195
        if (!$this->worksheetPaths) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->worksheetPaths of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
196
            $path = $this->archive->extract(static::WORKBOOK_PATH);
197
            $this->worksheetPaths = $this->worksheetListReader->getWorksheetPaths($this->getRelationships(), $path);
198
        }
199
200
        return $this->worksheetPaths;
201
    }
202
203
    /**
204
     * @return Styles
205
     */
206
    protected function getStyles()
207
    {
208
        if (!$this->styles) {
209
            $path = $this->archive->extract($this->relationships->getStylesPath());
210
            $this->styles = $this->stylesLoader->open($path, $this->archive);
211
        }
212
213
        return $this->styles;
214
    }
215
}
216