Issues (25)

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/AppBundle/Repository/PsrRepository.php (1 issue)

Check for possibly unhandled errors passed.

Bug Security Major

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 AppBundle\Repository;
4
5
use Symfony\Component\Finder\Finder;
6
use AppBundle\Entity\Psr;
7
use Mni\FrontYAML\Parser;
8
9
class PsrRepository
10
{
11
    /**
12
     * @var string
13
     */
14
    private $path;
15
16
    /**
17
     * @var Parser
18
     */
19
    private $parser;
20
21
    /**
22
     * PsrRepository constructor.
23
     *
24
     * @param $kernelProjectDir
25
     * @param Parser $parser
26
     */
27
    public function __construct($kernelProjectDir, Parser $parser)
28
    {
29
        $this->path = $kernelProjectDir;
30
        $this->parser = $parser;
31
    }
32
33
    /**
34
     * return array
35
     */
36
    public function findAll()
37
    {
38
        $finder = new Finder();
39
        $finder->files()->in($this->path.'/vendor/symfony-si/fig-standards-sl/accepted');
40
        $finder->files()->name('*md');
41
        $finder->sortByName();
42
43
        $psrs = [];
44
        foreach ($finder as $file) {
45
            if (substr($file->getFileName(), -7) != 'meta.md' && substr($file->getFileName(), -11) != 'examples.md') {
46
                $psrs[] = $this->getPsrByFile($file->getRealPath());
47
            }
48
        }
49
50
        return $psrs;
51
    }
52
53
    /**
54
     * @param string $slug
55
     * @return Psr
56
     */
57
    public function findOneBySlug($slug)
58
    {
59
        $finder = new Finder();
60
        $finder->files()->in($this->path.'/vendor/symfony-si/fig-standards-sl/accepted')->name("*.md");
61
        $finder->sortByName();
62
63
        foreach ($finder as $file) {
64
            $document = $this->parser->parse($file->getContents());
65
            if ($document->getYAML()['slug'] == $slug) {
66
                return $this->getPsrByFile($file->getRealPath());
67
            }
68
        }
69
70
        return null;
71
    }
72
73
    /**
74
     * @param string $file
75
     * @return null|Psr
76
     */
77
    public function getPsrByFile($file)
78
    {
79
        if (!file_exists($file)) {
80
            return null;
81
        }
82
83
        $psr = $this->getPsrByFileWithoutChilds($file);
84
        $metaFile = substr($file, 0, -3).'-meta.md';
85
        if (file_exists($metaFile)) {
86
            $meta = $this->getPsrByFileWithoutChilds($metaFile);
87
            $psr->setMeta($meta);
88
        }
89
90
        $examplesFile = substr($file, 0, -3).'-examples.md';
91
        if (file_exists($examplesFile)) {
92
            $examples = $this->getPsrByFileWithoutChilds($examplesFile);
93
            $psr->setExamples($examples);
94
        }
95
96
        return $psr;
97
    }
98
99
    /**
100
     * Get Psr without meta or example child documents.
101
     *
102
     * @param string $file
103
     * @return Psr
104
     */
105
    private function getPsrByFileWithoutChilds($file)
106
    {
107
        $document = $this->parser->parse(file_get_contents($file));
108
109
        $psr = new Psr();
110
        $psr->setTitle($document->getYAML()['title']);
111
        $psr->setSlug($document->getYaml()['slug']);
112
        $psr->setContent($document->getContent());
113
        $psr->setReadTime($document->getYAML()['read_time']);
114
        $psr->setDescription($document->getYAML()['description']);
115
        $psr->setUpdated(\DateTime::createFromFormat('Y-m-d', $document->getYAML()['updated']));
0 ignored issues
show
It seems like \DateTime::createFromFor...->getYAML()['updated']) targeting DateTime::createFromFormat() can also be of type false; however, AppBundle\Entity\Psr::setUpdated() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
116
117
        return $psr;
118
    }
119
}
120