Issues (15)

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/JsynExtractor.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 samshal/scripd package.
5
 *
6
 * (c) Samuel Adeshina <[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 Samshal\Scripd;
13
14
/**
15
 * Contains utility methods for parsing a jsyn file.
16
 *
17
 * @since  1.0
18
 *
19
 * @author Samuel Adeshina <[email protected]>
20
 */
21
final class JsynExtractor
22
{
23
    /**
24
     * @var string
25
     *
26
     * Content of the JSYN File
27
     */
28
    private $jsyn;
29
30
    /**
31
     * @var string
32
     *
33
     * SQL Syntax to use for script generation
34
     */
35
    private $sqlSyntax;
36
37
    /**
38
     * @param string $jsynFile string | PathUtil
39
     * @param $sqlSyntax string
40
     */
41
    public function __construct($jsynFile, $sqlSyntax)
42
    {
43
        self::setJsynFile($jsynFile);
44
        self::setSqlSyntax($sqlSyntax);
45
    }
46
47
    /**
48
     * @param $jsynFile string | PathUtil
49
     *
50
     * Setter function for the jsonFile global property
51
     *
52
     * @return void
53
     */
54
    public function setJsynFile($jsynFile)
55
    {
56
        $this->jsyn = json_decode(file_get_contents($jsynFile));
57
58
        if (isset($this->sqlSyntax)) {
59
            $sqlSyntax = $this->sqlSyntax;
60
            if (!isset($this->jsyn->$sqlSyntax)) {
61
                $sqlSyntax = 'default';
62
            }
63
            $this->jsyn = $this->jsyn->$sqlSyntax;
64
        }
65
    }
66
67
    /**
68
     * @param $sqlSyntax string
69
     *
70
     * Setter function for the sqlSyntax global property
71
     *
72
     * @return void
73
     */
74
    public function setSqlSyntax($sqlSyntax)
75
    {
76
        $this->sqlSyntax = $sqlSyntax;
77
78
        if (isset($this->jsyn->$sqlSyntax)) {
79
            $this->jsyn = $this->jsyn->$sqlSyntax;
80
        } else {
81
            $sqlSyntax = 'default';
82
            $this->jsyn = $this->jsyn->$sqlSyntax;
83
        }
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    public function getJsyn()
90
    {
91
        return $this->jsyn;
92
    }
93
94
    /**
95
     * Performs extraction of the appropriate sql syntax
96
     * fromthe supplied jsyn file.
97
     *
98
     * @return void
99
     */
100
    public function formatJsyn()
101
    {
102
        for ($i = 0; $i < count($this->jsyn); ++$i) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
103
            if (strpos($this->jsyn[$i], '[') === 0 || strpos($this->jsyn[$i], '{') === (int) 0) {
104
                $this->jsyn[$i] = strtolower($this->jsyn[$i]);
105
            } else {
106
                $this->jsyn[$i] = strtoupper($this->jsyn[$i]);
107
            }
108
        }
109
    }
110
111
    /**
112
     * Returns the extracted jsyn as a string.
113
     *
114
     * @return string
115
     */
116
    public function __toString()
117
    {
118
        return implode(' ', $this->getJsyn());
119
    }
120
}
121