Issues (14)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/View/InkyView.php (9 issues)

1
<?php
2
declare(strict_types = 1);
0 ignored issues
show
Expected no space between directive and the equals sign in a declare statement
Loading history...
Expected no space between equal sign and the directive value in a declare statement
Loading history...
3
4
namespace Burzum\ZurbInky\View;
5
6
use Cake\View\View;
7
use Pelago\Emogrifier;
8
use Pinky;
0 ignored issues
show
The type Pinky was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use RuntimeException;
10
11
/**
12
 * InkyView
13
 *
14
 * @link https://github.com/zurb/inky
15
 * @link https://github.com/lorenzo/pinky
16
 * @link https://github.com/MyIntervals/emogrifier
17
 */
18
class InkyView extends View
19
{
20
    /**
21
     * CSS
22
     *
23
     * @var array
24
     */
25
    protected $_css;
26
27
    /**
28
     * Emogrifier CSS Parser Instance
29
     *
30
     * @link https://github.com/MyIntervals/emogrifier
31
     * @var \Pelago\Emogrifier
32
     */
33
    protected $_emogriefer;
34
35
    /**
36
     * @inheritDoc
37
     */
38 2
    public function initialize()
39
    {
40 2
        parent::initialize();
41
42 2
        $this->_emogriefer = new Emogrifier();
0 ignored issues
show
Deprecated Code introduced by
The class Pelago\Emogrifier has been deprecated: Will be removed for version 4.0.0. Please use the CssInliner class instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

42
        $this->_emogriefer = /** @scrutinizer ignore-deprecated */ new Emogrifier();
Loading history...
43 2
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 2
    public function render($view = null, $layout = null)
49
    {
50 2
        $output = parent::render($view, $layout);
51 2
        $output = Pinky\transformString($output)->saveHTML();
0 ignored issues
show
The function transformString was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $output = /** @scrutinizer ignore-call */ Pinky\transformString($output)->saveHTML();
Loading history...
52
53 2
        if (!empty($this->_css)) {
54 1
            $this->getEmogriefer()->setCss($this->_css);
0 ignored issues
show
$this->_css of type array is incompatible with the type string expected by parameter $css of Pelago\Emogrifier::setCss(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
            $this->getEmogriefer()->setCss(/** @scrutinizer ignore-type */ $this->_css);
Loading history...
55 1
            $this->getEmogriefer()->setHtml($output);
56
57 1
            return $this->getEmogriefer()->emogrify();
58
        }
59
60 1
        return $output;
61
    }
62
63
    /**
64
     * Gets the Emogriefer instance
65
     *
66
     * @return \Pelago\Emogrifier
67
     */
68 1
    public function getEmogriefer()
69
    {
70 1
        return $this->_emogriefer;
71
    }
72
73
    /**
74
     * Sets multiple CSS files
75
     *
76
     * @param array $cssFiles A list of CSS files to read
77
     * @return $this
78
     */
79 1
    public function setCssFiles(array $cssFiles)
80
    {
81 1
        $css = '';
82 1
        foreach ($cssFiles as $file) {
83 1
            $css .= $this->_getCssFromFile($file);
84
        }
85
86 1
        $this->setCss($css);
87
88 1
        return $this;
89
    }
90
91
    /**
92
     * Sets the CSS
93
     *
94
     * @param string $css CSS File
95
     * @return $this
96
     */
97 1
    public function setCss(string $css)
98
    {
99 1
        $this->_css .= $css;
100
101 1
        return $this;
102
    }
103
104
    /**
0 ignored issues
show
Doc comment for parameter "$file" missing
Loading history...
105
     * Gets the CSS from a file
106
     *
107
     * @param string $css CSS File
0 ignored issues
show
Doc comment for parameter $css does not match actual variable name $file
Loading history...
108
     * @return string
109
     */
110 1
    protected function _getCssFromFile(string $file) : string
0 ignored issues
show
There must not be a space before the colon in a return type declaration
Loading history...
111
    {
112 1
        $file = WWW_ROOT . $this->Url->css($file, ['timestamp' => false]);
113
114 1
        if (!file_exists($file)) {
115
            throw new RuntimeException(sprintf('The CSS file `%s` does not exist.', $file));
116
        }
117
118 1
        $css = file_get_contents($file);
119
120
        // Emogriefer works only with UTF-8!
121 1
        if (!mb_check_encoding($css, 'UTF-8')) {
122
            throw new RuntimeException(sprintf('The CSS file `$css` must be UTF-8 encoded!', $file));
123
        }
124
125 1
        return $css;
126
    }
127
}
128