Issues (7)

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/NodeVisitor/AbstractPathResolver.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 puli/twig-puli-extension package.
5
 *
6
 * (c) Bernhard Schussek <[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 Puli\TwigExtension\NodeVisitor;
13
14
use Puli\Repository\Api\ResourceRepository;
15
use Twig_BaseNodeVisitor;
16
use Twig_Environment;
17
use Twig_Node;
18
use Twig_Node_Module;
19
use Webmozart\PathUtil\Path;
20
21
/**
22
 * @since  1.0
23
 *
24
 * @author Bernhard Schussek <[email protected]>
25
 */
26
abstract class AbstractPathResolver extends Twig_BaseNodeVisitor
27
{
28
    /**
29
     * @var ResourceRepository
30
     */
31
    protected $repo;
32
33
    /**
34
     * @var string
35
     */
36
    protected $currentDir;
37
38 23
    public function __construct(ResourceRepository $repo)
39
    {
40 23
        $this->repo = $repo;
41 23
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 23
    protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
47
    {
48
        // Remember the directory of the current file
49 23
        if ($node instanceof Twig_Node_Module && $node->hasAttribute('puli-dir')) {
50
            // Currently, it doesn't seem like Twig does recursive traversals
51
            // (i.e. starting the traversal of another module while a previous
52
            // one is still in progress). Thus we don't need to track existing
53
            // values here.
54 19
            $this->currentDir = $node->getAttribute('puli-dir');
55
        }
56
57 23
        return $node;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 23
    protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
64
    {
65
        // Only process if the current directory was set
66 23
        if (null !== $this->currentDir) {
67 19
            if ($result = $this->processNode($node)) {
68 3
                $node = $result;
69
            }
70
        }
71
72 23
        return $node;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 16
    protected function resolvePath($path, $checkPath = false)
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...
79
    {
80
        // Empty path? WTF I don't want to deal with this.
81 16
        if ('' === $path) {
82
            return $path;
83
        }
84
85
        // Absolute paths are fine
86 16
        if ('/' === $path[0]) {
87 7
            return $path;
88
        }
89
90
        // Resolve relative paths
91 11
        $absolutePath = Path::makeAbsolute($path, $this->currentDir);
92
93
        // With other loaders enabled, it may happen that a path looks like
94
        // a relative path, but is none, for example
95
        // "AcmeBlogBundle::index.html.twig", which doesn't start with a forward
96
        // slash. For this reason, if $checkPath is true, we should only resolve
97
        // paths if they actually exist in the repository.
98 11
        if (!$checkPath || $this->repo->contains($absolutePath)) {
99 11
            return $absolutePath;
100
        }
101
102
        // Return the path unchanged if $checkPath and the path does not exist
103 1
        return $path;
104
    }
105
106
    /**
107
     * @param Twig_Node $node
108
     *
109
     * @return Twig_Node|null
110
     */
111
    abstract protected function processNode(Twig_Node $node);
112
}
113