Issues (12)

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/QrCodeComponent.php (5 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 2amigos/qrcode-library project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\QrCode\Component;
13
14
use Da\QrCode\Contracts\LabelInterface;
15
use Da\QrCode\Contracts\QrCodeInterface;
16
use Da\QrCode\Contracts\WriterInterface;
17
use Da\QrCode\Exception\InvalidPathException;
18
use Da\QrCode\QrCode;
19
use yii\base\Component;
20
21
/**
22
 * Class QrCodeComponent
23
 *
24
 * @author Antonio Ramirez <[email protected]>
25
 * @package Da\QrCode\Component
26
 *
27
 * @method QrCode useForegroundColor(integer $red, integer $green, integer $blue)
28
 * @method QrCode useBackgroundColor(integer $red, integer $green, integer $blue)
29
 * @method QrCode useEncoding(string $encoding)
30
 * @method QrCode useWriter(WriterInterface $writer)
31
 * @method QrCode useLogo(string $logo)
32
 * @method QrCode setText(string $text)
33
 * @method QrCode setSize(integer $size)
34
 * @method QrCode setLogoWidth(integer $width)
35
 * @method QrCode setLabel(LabelInterface $label)
36
 * @method QrCode setMargin(integer $margin)
37
 * @method QrCode setErrorCorrectionLevel(string $errorCorrectionLevel)
38
 * @method string getText()
39
 * @method integer getSize()
40
 * @method array getMargin()
41
 * @method array getForegroundColor()
42
 * @method array getBackgroundColor()
43
 * @method string getEncoding()
44
 * @method string getErrorCorrectionLevel()
45
 * @method string getLogoPath()
46
 * @method integer getLogoWidth()
47
 * @method LabelInterface getLabel()
48
 * @method string writeString()
49
 * @method string writeDataUri()
50
 * @method bool|integer writeFile(string $path)
51
 * @method string getContentType()
52
 */
53
class QrCodeComponent extends Component
54
{
55
    /**
56
     * @var string
57
     */
58
    public $text = '';
59
    /**
60
     * @var int
61
     */
62
    public $size = 300;
63
    /**
64
     * @var int
65
     */
66
    public $margin = 10;
67
    /**
68
     * @var array the foreground color. Syntax is:
69
     *
70
     * ```
71
     * [
72
     *  'r' => 0, // RED
73
     *  'g' => 0, // GREEN
74
     *  'b' => 0  // BLUE
75
     * ]
76
     * ```
77
     */
78
    public $foregroundColor;
79
    /**
80
     * @var array the background color. Syntax is:
81
     *
82
     * ```
83
     * [
84
     *  'r' => 255, // RED
85
     *  'g' => 255, // GREEN
86
     *  'b' => 255  // BLUE
87
     * ]
88
     * ```
89
     *
90
     */
91
    public $backgroundColor;
92
    /**
93
     * @var string
94
     */
95
    public $encoding = 'UTF-8';
96
    /**
97
     * @var string ErrorCorrectionLevelInterface value
98
     */
99
    public $errorCorrectionLevel;
100
    /**
101
     * @var string
102
     */
103
    public $logoPath;
104
    /**
105
     * @var int
106
     */
107
    public $logoWidth;
108
    /**
109
     * @var LabelInterface|string
110
     */
111
    public $label;
112
    /**
113
     * @var WriterInterface
114
     */
115
    public $writer;
116
    /**
117
     * @var QrCodeInterface
118
     */
119
    protected $qrCode;
120
121
    /**
122
     * @inheritdoc
123
     */
124
    public function __call($name, $params)
125
    {
126
        return call_user_func_array([$this->qrCode, $name], $params);
127
    }
128
129
    /**
130
     * @inheritdoc
131
     * @throws InvalidPathException
132
     */
133
    public function init()
134
    {
135
        $this->qrCode = (new QrCode($this->text, $this->errorCorrectionLevel, $this->writer))
136
            ->setSize(($this->size ?: 300))
137
            ->setMargin(($this->margin ?: 10))
138
            ->setEncoding(($this->encoding ?: 'UTF-8'));
139
140
        $this->qrCode = $this->logoPath ? $this->qrCode->setLogo($this->logoPath) : $this->qrCode;
141
        $this->qrCode = $this->logoWidth ? $this->qrCode->setLogoWidth($this->logoWidth) : $this->qrCode;
142
        $this->qrCode = $this->label ? $this->qrCode->setLabel($this->label) : $this->qrCode;
143
144
        if ($this->foregroundColor) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->foregroundColor 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...
145
            [$r, $g, $b] = $this->foregroundColor;
0 ignored issues
show
The variable $r does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $g does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $b does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
146
            $this->qrCode = $this->qrCode->setForegroundColor($r, $g, $b);
147
        }
148
        if ($this->backgroundColor) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->backgroundColor 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...
149
            [$r, $g, $b] = $this->backgroundColor;
150
            $this->qrCode = $this->qrCode->setBackgroundColor($r, $g, $b);
151
        }
152
    }
153
}
154