GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (19)

Security Analysis    not enabled

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/View.php (1 issue)

Labels
Severity

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 declare(strict_types=1);
2
/**
3
 * Starlit App.
4
 *
5
 * @copyright Copyright (c) 2016 Starweb AB
6
 * @license   BSD 3-Clause
7
 */
8
9
namespace Starlit\App;
10
11
use Starlit\App\ViewHelper\Capturer;
12
use Starlit\App\ViewHelper\InlineScriptCapturer;
13
use Starlit\App\ViewHelper\MustacheTmplCapturer;
14
use Starlit\App\ViewHelper\Pagination;
15
use Starlit\App\ViewHelper\Url;
16
use Symfony\Component\HttpFoundation\Request;
17
use Starlit\App\ViewHelper\AbstractViewHelper;
18
19
class View implements ViewInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $scriptRootPath = 'app/views';
25
26
    /**
27
     * @var string
28
     */
29
    protected $fileExtension = 'html.php';
30
31
    /**
32
     * Default helpers.
33
     *
34
     * @var array
35
     */
36
    protected $helperClasses = [
37
        'capturer'             => Capturer::class,
38
        'mustacheTmplCapturer' => MustacheTmplCapturer::class,
39
        'pagination'           => Pagination::class,
40
        'url'                  => Url::class,
41
        'inlineScriptCapturer' => InlineScriptCapturer::class,
42
    ];
43
44
    /**
45
     * @var array
46
     */
47
    protected $helpers = [];
48
49
    /**
50
     * @var array
51
     */
52
    protected $variables = [];
53
54
    /**
55
     * @var string|null
56
     */
57
    protected $layoutScript;
58
59
    /**
60
     * @var string|null
61
     */
62
    protected $layoutContent;
63
64
    /**
65
     * @var Request
66
     */
67
    private $request;
68
69 15
    public function __construct(array $options = [])
70
    {
71 15
        $this->setOptions($options);
72 15
    }
73
74 15
    public function setOptions(array $options): void
75
    {
76 15
        if (isset($options['scriptRootPath'])) {
77 12
            $this->scriptRootPath = $options['scriptRootPath'];
78
        }
79
80 15
        if (isset($options['fileExtension'])) {
81 1
            $this->fileExtension = $options['fileExtension'];
82
        }
83 15
    }
84
85
    /**
86
     * Magic method to set view variables.
87
     *
88
     * @param   string $name
89
     * @param   mixed  $value
90
     */
91 4
    public function __set(string $name, $value): void
92
    {
93 4
        $this->variables[$name] = $value;
94 4
    }
95
96
    /**
97
     * Magic method to get view variables.
98
     *
99
     * @param string $name
100
     * @return mixed
101
     */
102 2
    public function __get(string $name)
103
    {
104 2
        if (!isset($this->variables[$name])) {
105 1
            return null;
106
        }
107
108 2
        return $this->variables[$name];
109
    }
110
111
    /**
112
     * Magic method to test if view variable is set.
113
     */
114 1
    public function __isset(string $name): bool
115
    {
116 1
        return isset($this->variables[$name]);
117
    }
118
119 1
    public function setLayout(string $script): void
120
    {
121 1
        $this->layoutScript = $script;
122 1
    }
123
124
    /**
125
     * Render output (returns) of the specified view script (with layout if that exists).
126
     *
127
     * @param string $script Relative script path (without file extension!). Eg. "some-script" or "admin/some-script".
128
     * @param bool   $renderLayout
129
     * @return string
130
     */
131 2
    public function render(string $script, bool $renderLayout = false): string
132
    {
133
        // Check If script should be rendered with a layout
134 2
        if ($renderLayout && !empty($this->layoutScript)) {
135 1
            $this->layoutContent = $this->renderScript($script);
136
137 1
            return $this->renderScript($this->layoutScript);
138
        } else {
139 1
            return $this->renderScript($script);
140
        }
141
    }
142
143
    /**
144
     * Internal method that does the actual script rendering.
145
     */
146 3
    protected function renderScript(string $script): string
147
    {
148 3
        $fullScriptPath = $this->scriptRootPath . '/' . $script . '.' . $this->fileExtension;
149
        // We don't unit test invalid script because it slows down the test process an entire second or more
150 3
        if (!file_exists($fullScriptPath)) {
151 1
            throw new \RuntimeException("Couldn't find view script \"{$fullScriptPath}\"");
152
        }
153
154 2
        ob_start();
155
156 2
        include $fullScriptPath;
157
158 2
        return ob_get_clean();
159
    }
160
161 2
    public function layoutContent(): string
162
    {
163 2
        return $this->layoutContent;
164
    }
165
166
    /**
167
     * Escape a string for output in view script.
168
     */
169 2
    public function escape(?string $string, int $flags = \ENT_QUOTES): string
170
    {
171 2
        return htmlspecialchars((string) $string, $flags, BaseApp::CHARSET);
172
    }
173
174
    /**
175
     * Returns view variable escaped for view script output.
176
     */
177 1
    public function getEscaped(string $name): string
178
    {
179 1
        if (empty($this->variables[$name])) {
180 1
            return '';
181
        }
182
183 1
        return $this->escape((string) $this->variables[$name]);
184
    }
185
186 2
    public function addHelperClass(string $helperName, string $className): void
187
    {
188 2
        $this->helperClasses[$helperName] = $className;
189 2
    }
190
191 3
    public function getHelper(string $helperName): AbstractViewHelper
192
    {
193
        // If helper has not already been instantiated
194 3
        if (!isset($this->helpers[$helperName])) {
195
            // Check that helper is defined
196 3
            if (!isset($this->helperClasses[$helperName])) {
197 1
                throw new \InvalidArgumentException("No helper named \"{$helperName}\"");
198
            }
199
200 2
            $this->helpers[$helperName] = new $this->helperClasses[$helperName]();
201 2
            $this->helpers[$helperName]->setView($this);
202
        }
203
204 2
        return $this->helpers[$helperName];
205
    }
206
207
    /**
208
     * Magic method to call view helpers.
209
     * If the helper has not defined __invoke(), the helper object will be returned.
210
     * Otherwise, the result of the __invoke() is returned.
211
     */
212 2
    public function __call(string $name, array $arguments = [])
213
    {
214 2
        $helper = $this->getHelper($name);
215 2
        if (is_callable($helper)) {
216 1
            return \call_user_func_array($helper, $arguments);
217
        }
218
219 1
        return $helper;
220
    }
221
222 1
    public function setRequest(Request $request): void
0 ignored issues
show
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
223
    {
224 1
        $this->request = $request;
225 1
    }
226
227 1
    public function getRequest(): Request
228
    {
229 1
        return $this->request;
230
    }
231
232 1
    public function setLayoutContent(string $value): void
233
    {
234 1
        $this->layoutContent = $value;
235 1
    }
236
}
237