Issues (15)

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/Snappy/Generator/LoggableGenerator.php (3 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 Knp\Bundle\SnappyBundle\Snappy\Generator;
4
5
@trigger_error('Logging capability is now directly integrated in Snappy. You should call setLogger on your generator rather than using this decorator.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
6
7
use Knp\Snappy\GeneratorInterface;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * Wraps a GeneratorInterface instance to log the media generations using the
12
 * configured logger.
13
 *
14
 * @deprecated Logging capability is now directly integrated in Snappy. You should use it rather than this Decorator.
15
 */
16
class LoggableGenerator implements GeneratorInterface
17
{
18
    private $generator;
19
    private $logger;
20
21
    /**
22
     * Constructor.
23
     *
24
     * @param GeneratorInterface $generator
25
     * @param LoggerInterface    $logger
0 ignored issues
show
Should the type for parameter $logger not be null|LoggerInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
26
     */
27
    public function __construct(GeneratorInterface $generator, LoggerInterface $logger = null)
28
    {
29
        $this->generator = $generator;
30
        $this->logger = $logger;
31
    }
32
33
    /**
34
     * Returns the underlying generator instance.
35
     *
36
     * @return GeneratorInterface
37
     */
38
    public function getInternalGenerator()
39
    {
40
        return $this->generator;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function generate($input, $output, array $options = [], $overwrite = false)
47
    {
48
        if (is_array($input)) {
49
            $debug_input = implode(', ', $input);
50
        } else {
51
            $debug_input = $input;
52
        }
53
        $this->logDebug(sprintf('Generate from file (%s) to file (%s).', $debug_input, $output));
54
55
        $this->generator->generate($input, $output, $options, $overwrite);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function generateFromHtml($html, $output, array $options = [], $overwrite = false)
62
    {
63
        $debugHtml = is_array($html) ? implode(', ', $html) : $html;
64
65
        $this->logDebug(sprintf('Generate from HTML (%s) to file (%s).', substr($debugHtml, 0, 100), $output));
66
67
        $this->generator->generateFromHtml($html, $output, $options, $overwrite);
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function getOutput($input, array $options = [])
74
    {
75
        if (is_array($input)) {
76
            $debug_input = implode(', ', $input);
77
        } else {
78
            $debug_input = $input;
79
        }
80
        $this->logDebug(sprintf('Output from file (%s).', $debug_input));
81
82
        return $this->generator->getOutput($input, $options);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getOutputFromHtml($html, array $options = [])
89
    {
90
        $debugHtml = is_array($html) ? implode(', ', $html) : $html;
91
92
        $this->logDebug(sprintf('Output from HTML (%s).', substr($debugHtml, 0, 100)));
93
94
        return $this->generator->getOutputFromHtml($html, $options);
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function setOption($name, $value)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
101
    {
102
        $this->logDebug(sprintf('Set option %s = %s.', $name, var_export($value, true)));
103
104
        return $this->generator->setOption($name, $value);
105
    }
106
107
    /**
108
     * Logs the given debug message if the logger is configured or do nothing
109
     * otherwise.
110
     *
111
     * @param string $message
112
     */
113
    private function logDebug($message)
114
    {
115
        if (null === $this->logger) {
116
            return;
117
        }
118
119
        $this->logger->debug($message);
120
    }
121
}
122