Issues (53)

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/Inigo/Handler/ImgHandler.php (8 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 Kaloa\Renderer\Inigo\Handler;
4
5
use Kaloa\Renderer\Inigo\Handler\ProtoHandler;
6
use Kaloa\Renderer\Inigo\Parser;
7
8
/**
9
 *
10
 */
11
final class ImgHandler extends ProtoHandler
12
{
13
    /**
14
     *
15
     * @var string
16
     */
17
    private $last_img_align = '';
18
19
    /**
20
     *
21
     */
22 18
    public function __construct()
23
    {
24 18
        $this->name = 'img';
25 18
        $this->type = Parser::TAG_OUTLINE;
26
27 18
        $this->defaultParam = 'src';
28 18
    }
29
30
    /**
31
     *
32
     * @param  string $path
33
     * @param  string $alt
34
     * @param  string $title
35
     * @param  int    $align
36
     * @param  string $dir
37
     * @return string
38
     */
39 3
    private function drawImage(
40
        $path,
41
        $alt = '',
42
        $title = '',
0 ignored issues
show
The parameter $title is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
        $align = Parser::PC_IMG_ALIGN_LEFT,
44
        $dir = ''
45
    ) {
46
        // width of framing div's border (one side)
47 3
        $border_width = 1;
48 3
        $padding      = 2;
49 3
        $ret          = '';
50 3
        $path         = $dir . $path;
51
52
        //$title = $this->ParseInline($title);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
54 3
        $width = 150;
55 3
        $attr = 'width="150" height="150"';
56
57
        // Image exists?
58 3
        if (@getimagesize($path) !== false) {
59 3
            list($width, $height, $type, $attr) = getimagesize($path);
0 ignored issues
show
The assignment to $height is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
The assignment to $type is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
60 3
        }
61
62
        //$path = $this->m_rel_path . $path;
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
64 3
        if ($alt === '') {
65 3
            $alt = $path;
66 3
        }
67
68 3
        $style = 'width: ' . ($width + 2 * (1 + $border_width + $padding)) . 'px;';
69
        //$style2 .= "height: " . ($height + 2 * ($border_width )) . "px;";
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
70
71 3
        if ($align == Parser::PC_IMG_ALIGN_RIGHT) {
72
            $ret .= '<div class="img">' . "\n"
73 1
                    . '  <div class="img_right" style="' . $style . '">' . "\n"
74 1
                    . '    <div class="img_border">' . "\n"
75 1
                    . '      <img src="' . $this->e($path) . '" alt="Bild: ' . $this->e($alt) . '" title="'
76 1
                        . $this->e($alt) . '" ' . $attr . ' />' . "\n"
77 1
                    . '    </div>' . "\n"
78 1
                    . '    <div class="img_content">';
79 3
        } elseif ($align == Parser::PC_IMG_ALIGN_CENTER) {
80
            $ret .= '<div class="center">' . "\n"
81 1
                    . '  <div class="img">' . "\n"
82 1
                    . '    <div class="img_center" style="' . $style . '">' . "\n"
83 1
                    . '      <div class="img_border">' . "\n"
84 1
                    . '        <img src="' . $this->e($path) . '" alt="Bild: ' . $this->e($alt) . '" title="'
85 1
                        . $this->e($alt) . '" ' . $attr . ' />' . "\n"
86 1
                    . '      </div>' . "\n"
87 1
                    . '      <div class="img_content">';
88 3
        } elseif ($align == Parser::PC_IMG_ALIGN_LEFT) {
89
            $ret .= '<div class="img">' . "\n"
90 3
                    . '  <div class="img_left" style="' . $style . '">' . "\n"
91 3
                    . '    <div class="img_border">' . "\n"
92 3
                    . '      <img src="' . $this->e($path) . '" alt="Bild: ' . $this->e($alt) . '" title="'
93 3
                        . $this->e($alt) . '" ' . $attr . ' />' . "\n"
94 3
                    . '    </div>' . "\n"
95 3
                    . '    <div class="img_content">';
96 3
        }
97
98 3
        return $ret;
99
    }
100
101
    /**
102
     *
103
     * @param  array  $data
104
     * @return string
105
     */
106 3
    public function draw(array $data)
107
    {
108 3
        $ret = '';
0 ignored issues
show
$ret is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
109
110 3
        if ($data['front']) {
111 3
            $src   = $this->fillParam($data, 'src', '');
112 3
            $title = $this->fillParam($data, 'title', '');
113 3
            $align = $this->fillParam($data, 'align', null);
114
115
            //$src = $this->m_image_path . $src;
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
116 3
            $this->last_img_align = $align;
117
118
            switch ($align) {
119 3
                case 'right':
120 1
                    $align = Parser::PC_IMG_ALIGN_RIGHT;
121 1
                    break;
122 3
                case 'center':
123 1
                    $align = Parser::PC_IMG_ALIGN_CENTER;
124 1
                    break;
125 3
                default:
126 3
                    $align = Parser::PC_IMG_ALIGN_LEFT;
127 3
                    break;
128 3
            }
129
130 3
            $ret = $this->drawImage($src, $title, '', $align, $data['vars']['image-dir']);
131 3
        } elseif ($this->last_img_align === 'center') {
132 1
            $this->last_img_align = '';
133 1
            $ret = "</div>\n    </div>\n  </div>\n</div>\n\n";
134 1
        } else {
135 3
            $ret = "</div>\n  </div>\n</div>\n\n";
136
        }
137
138 3
        return $ret;
139
    }
140
}
141