Issues (125)

Security Analysis    not enabled

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.

app/Services/Exporter.php (1 issue)

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 Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[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 Tinyissue\Services;
13
14
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
15
use Maatwebsite\Excel\Files\NewExcelFile;
16
17
/**
18
 * Exporter is class for initialising the exporter, process data, and export the generated file.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @method $this sheet($sheetID, $callback = null)
23
 * @method $this store($ext = 'xls', $path = false, $returnInfo = false)
24
 * @method $this setFileName($fileName)
25
 */
26
class Exporter extends NewExcelFile
27
{
28
    /** Current supported files type */
29
    const TYPE_CSV  = 'csv';
30
    const TYPE_XLS  = 'xls';
31
    const TYPE_XLSX = 'xlsx';
32
33
    /**
34
     * Parameters.
35
     *
36
     * @var array
37
     */
38
    protected $params = [];
39
40
    /**
41
     * Export file format.
42
     *
43
     * @var string
44
     */
45
    protected $format = self::TYPE_CSV;
46
47
    /**
48
     * Type of data to export.
49
     *
50
     * @var string
51
     */
52
    protected $type = '';
53
54
    /**
55
     * Returns the parameters.
56
     *
57
     * @param string $key
58
     *
59
     * @return mixed|array
60
     */
61 4
    public function getParams($key = null)
62
    {
63 4
        if (null === $key) {
64 4
            return $this->params;
65
        }
66
67 1
        return array_get($this->params, $key);
68
    }
69
70
    /**
71
     * Start importing.
72
     *
73
     * @param string $className
74
     * @param string $format
75
     * @param array  $params
76
     *
77
     * @return array['full', 'path', 'file', 'title', 'ext']
0 ignored issues
show
The doc-type array['full', could not be parsed: Expected "]" at position 2, but found "'full'". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
78
     */
79 4
    public function exportFile($className, $format = self::TYPE_CSV, array $params = [])
80
    {
81 4
        $params['route'] = $this->app->request->route()->parameters();
82 4
        $this->format    = $format;
83 4
        $this->params    = $params;
84 4
        $this->type      = $className;
85
86
        // Update file name
87 4
        $this->setFileName($this->getFilename());
88
89
        // Start exporting
90 4
        $this->handle($className);
91
92
        // Store file and return info
93 4
        return $this->store($format, false, true);
94
    }
95
96
    /**
97
     * Returns export file name.
98
     *
99
     * @return string
100
     */
101 4
    public function getFilename()
102
    {
103 4
        return 'export_' . str_replace('\\', '_', strtolower($this->type)) . '_' . time();
104
    }
105
106
    /**
107
     * Construct the export class full name.
108
     *
109
     * @param string $type
110
     *
111
     * @return string
112
     *
113
     * @throws LaravelExcelException
114
     */
115 4
    protected function getHandlerClassName($type)
116
    {
117 4
        $handler = '\\Tinyissue\Export\\' . $type . '\\' . ucfirst(substr($this->format, 0, 3)) . 'Handler';
118
119
        // Check if the handler exists
120 4
        if (!class_exists($handler)) {
121
            throw new LaravelExcelException("$type handler [$handler] does not exist.");
122
        }
123
124 4
        return $handler;
125
    }
126
}
127