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 (23)

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.

Twig/PjaxExtension.php (2 issues)

Languages
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
2
namespace Strontium\PjaxBundle\Twig;
3
4
use Strontium\PjaxBundle\Helper\PjaxHelperInterface;
5
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\RequestStack;
8
9
class PjaxExtension extends \Twig_Extension
10
{
11
12
    /**
13
     * @var PjaxHelperInterface
14
     */
15
    protected $pjax;
16
17
    /**
18
     * @var array
19
     */
20
    protected $sections = [];
21
22
    /**
23
     * @var RequestStack
24
     */
25
    protected $requestStack;
26
27
    /**
28
     * @param PjaxHelperInterface $pjax
29
     * @param RequestStack        $requestStack
30
     */
31
    public function __construct(PjaxHelperInterface $pjax, RequestStack $requestStack)
32
    {
33
        $this->pjax = $pjax;
34
        $this->requestStack = $requestStack;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function getFunctions()
41
    {
42
        return array(
43
            new \Twig_SimpleFunction('is_pjax', [$this, 'isPjax'], ['is_safe' => ['html']]),
44
            new \Twig_SimpleFunction('pjax_attr', [$this, 'generatePjaxAttributes'], ['is_safe' => ['html']]),
45
            new \Twig_SimpleFunction('pjax_version', [$this, 'pjaxVersion'], ['is_safe' => ['html']]),
46
            new \Twig_SimpleFunction('pjax_target', [$this, 'getPjaxTarget'], ['is_safe' => ['html']]),
47
            new \Twig_SimpleFunction('pjax_layout', [$this, 'getLayout'], ['is_safe' => ['html']]),
48
            new \Twig_SimpleFunction('pjax_base', [$this, 'getBase'], ['is_safe' => ['html']]),
49
        );
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getFilters()
56
    {
57
        return array(
58
            new \Twig_SimpleFilter('to_attr', [$this, 'toAttributes'], ['is_safe' => ['html']]),
59
        );
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getLayout($section = 'default', $layout = null)
66
    {
67
        $sectionConfig = $this->getSectionConfig($section);
68
        $request = $this->requestStack->getCurrentRequest();
69
70
        if (null !== $layout) {
71
            return $sectionConfig['layouts'][$layout];
72
        }
73
        if ($this->pjax->isPjaxRequest($request)) {
0 ignored issues
show
It seems like $request defined by $this->requestStack->getCurrentRequest() on line 68 can be null; however, Strontium\PjaxBundle\Hel...erface::isPjaxRequest() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
74
            $target = $this->pjax->getTarget($request);
0 ignored issues
show
It seems like $request defined by $this->requestStack->getCurrentRequest() on line 68 can be null; however, Strontium\PjaxBundle\Hel...rInterface::getTarget() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
75
            if (isset($sectionConfig['layouts'][$target])) {
76
                return $sectionConfig['layouts'][$target];
77
            } else {
78
                return $sectionConfig['layouts'][$sectionConfig['default_layout']];
79
            }
80
        }
81
82
        return $sectionConfig['layouts'][$sectionConfig['default_layout']];
83
    }
84
85
    /**
86
     * @param string $section
87
     *
88
     * @return string
89
     */
90
    public function getBase($section = 'default')
91
    {
92
        $sectionConfig = $this->getSectionConfig($section);
93
        $request = $this->requestStack->getCurrentRequest();
94
        if ((null !== $request && $this->pjax->isPjaxRequest($request))
95
            || null !== $this->requestStack->getParentRequest()
96
        ) {
97
            return $sectionConfig['pjax_template'];
98
        }
99
100
        return $sectionConfig['base_template'];
101
    }
102
103
    /**
104
     * @param array $sections
105
     *
106
     * @return $this
107
     */
108
    public function setSections(array $sections)
109
    {
110
        $this->sections = $sections;
111
112
        return $this;
113
    }
114
115
    /**
116
     * @param Request $request
117
     *
118
     * @return string|null
119
     */
120
    public function pjaxVersion(Request $request)
121
    {
122
        $version = $this->pjax->generateVersion($request);
123
124
        return $version ? sprintf('<meta http-equiv="x-pjax-version" content="%s"/>', $version) : null;
125
    }
126
127
    /**
128
     * Convert array to html attributes
129
     *
130
     * @param array $attributes
131
     *
132
     * @return string
133
     */
134
    public function toAttributes(array $attributes = array())
135
    {
136
        $htmlAttr = [];
137
138
        foreach ($attributes as $key => $value) {
139
            if (is_bool($value)) {
140
                $value = $value ? 'true' : 'false';
141
            }
142
            $htmlAttr[] = sprintf(' %s="%s"', $key, $value);
143
        }
144
145
        if (!count($htmlAttr)) {
146
            return '';
147
        }
148
149
        return implode('', $htmlAttr);
150
    }
151
152
    /**
153
     * Has Request been made by PJAX?
154
     *
155
     * @param Request $request
156
     *
157
     * @return bool
158
     */
159
    public function isPjax(Request $request)
160
    {
161
        return $this->pjax->isPjaxRequest($request);
162
    }
163
164
    /**
165
     * @param Request $request
166
     *
167
     * @return string
168
     */
169
    public function getPjaxTarget(Request $request)
170
    {
171
        return $this->pjax->getTarget($request);
172
    }
173
174
    /**
175
     * Generate PJAX attributes
176
     *
177
     * @param string $target         data-pjax-container="$target" where content will load
178
     * @param string $redirectTarget data-pjax-redirect-target="$redirectTarget" where content will load after redirect
179
     *
180
     * @return array
181
     */
182
    public function generatePjaxAttributes($target = null, $redirectTarget = null)
183
    {
184
        $attributes = [];
185
        if (null !== $target) {
186
            $attributes['data-pjax'] = (string)$target;
187
        }
188
        if (null !== $redirectTarget) {
189
            $attributes['data-pjax-redirect-target'] = (string)$redirectTarget;
190
        }
191
192
        return $attributes;
193
    }
194
195
    /**
196
     * {@inheritDoc}
197
     */
198
    public function getName()
199
    {
200
        return 'pjax_extension';
201
    }
202
203
    /**
204
     * @param string $section
205
     *
206
     * @return array
207
     */
208
    protected function getSectionConfig($section)
209
    {
210
        if (!isset($this->sections[$section])) {
211
            throw new InvalidConfigurationException(sprintf('Section "%s" does not configured', $section));
212
        }
213
        $sectionConfig = $this->sections[$section];
214
215
        return $sectionConfig;
216
    }
217
}
218