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

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/Parser.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
namespace VKBansal\FrontMatter;
3
4
use Symfony\Component\Yaml\Yaml;
5
6
/**
7
 * FrontMatter Parser
8
 * @package VKBansal\FrontMatter\Parser
9
 * @version 1.3.0
10
 * @author Vivek Kumar Bansal <[email protected]>
11
 * @license MIT
12
 */
13
class Parser
14
{
15
    /**
16
     * Regex for seperators
17
     * @var string
18
     */
19
    private static $matcherRegex = "/^-{3}\s?(\w*)\r?\n(.*)\r?\n-{3}\r?\n(.*)/s";
20
21
    /**
22
     * Constanst for Document::dump()
23
     * @see Document::dump()
24
     */
25
    const DUMP_YAML = 'yaml';
26
    const DUMP_JSON = 'json';
27
    const DUMP_INI  = 'ini';
28
29
    /**
30
     * Parse the given content
31
     * @param  string $input content to be parsed
32
     * @return Document
33
     */
34
    public static function parse($input)
35
    {
36
        if (preg_match(self::$matcherRegex, $input, $matches)) {
37
            $header = self::parseHeader($matches[2], strtolower($matches[1]));
38
            $content = $matches[3];
39
        } else {
40
            $content = $input;
41
            $header = [];
42
        }
43
44
        return new Document($content, $header);
0 ignored issues
show
It seems like $header defined by self::parseHeader($match...trtolower($matches[1])) on line 37 can also be of type string; however, VKBansal\FrontMatter\Document::__construct() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
45
    }
46
47
    /**
48
     * Convert a Document to string
49
     * @param  Document $document
50
     * @return string
51
     */
52
    public static function dump (Document $document, $mode = null)
53
    {
54
        switch ($mode) {
55
            case 'yaml':
56
                return "--- yaml\n".Yaml::dump($document->getConfig())."---\n".$document->getContent();
57
            
58
            case 'json':
59
                return "--- json\n".json_encode($document->getConfig(), JSON_PRETTY_PRINT)."\n---\n".$document->getContent();
60
            
61
            case 'ini':
62
                return "--- ini\n".self::dumpIni($document->getConfig())."---\n".$document->getContent();
63
64
            default:
65
                return "---\n".Yaml::dump($document->getConfig())."---\n".$document->getContent();
66
        }
67
    }
68
69
    /**
70
     * Determines if given content is valid 
71
     * @param  string  $input  Input to be validated
72
     * @return boolean         True if valid else false 
73
     */
74
    public static function isValid($input)
75
    {
76
        return preg_match(self::$matcherRegex, $input) === 1;
77
78
    }
79
80
    /**
81
     * Parses header
82
     * @param  string $header
83
     * @param  string $parser
84
     * @return array|string
85
     */
86
    private static function parseHeader($header, $parser)
87
    {
88
        switch($parser){
89
            case 'yaml':
90
                return Yaml::parse($header);
0 ignored issues
show
Bug Compatibility introduced by
The expression \Symfony\Component\Yaml\Yaml::parse($header); of type array|string|stdClass adds the type stdClass to the return on line 90 which is incompatible with the return type documented by VKBansal\FrontMatter\Parser::parseHeader of type array|string.
Loading history...
91
            case 'json':
92
                return json_decode($header, true);
93
            case 'ini':
94
                return parse_ini_string($header, true);
95
            default:
96
                return Yaml::parse($header);
0 ignored issues
show
Bug Compatibility introduced by
The expression \Symfony\Component\Yaml\Yaml::parse($header); of type array|string|stdClass adds the type stdClass to the return on line 96 which is incompatible with the return type documented by VKBansal\FrontMatter\Parser::parseHeader of type array|string.
Loading history...
97
        }
98
    }
99
100
    /**
101
     * Encodes PHP array to ini string
102
     * @param  array  $config
103
     * @return string
104
     */
105
    private static function dumpIni(array $config)
106
    {
107
        $sections = $globals = '';
108
        
109
        if (!empty($config)) {
110
            foreach ($config as $section => $item) {
111
                if (!is_array($item)) {
112
                    //To write globals at top
113
                    $globals .= "{$section} = {$item}\n";
114
                } else {
115
                    $sections = "\n[{$section}]\n";
116
                    foreach ($item as $key => $value) {
117
                        if (is_array($value)) {
118
                            foreach ($value as $arrKey => $arrValue) {
119
                                $sections .= "{$key}[{$arrKey}] = $arrValue\n";
120
                            }
121
                        } else {
122
                            $sections .= "{$key} = {$value}\n";
123
                        }
124
                    }
125
                }
126
            }
127
        }
128
        return $globals.$sections;
129
    }
130
}
131