Issues (168)

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/generator/VirtualQuery.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
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by Vitaly Iegorov <[email protected]>.
5
 * on 22.03.16 at 15:46
6
 */
7
namespace samsoncms\api\generator;
8
9
use samsoncms\api\generator\metadata\VirtualMetadata;
10
use samsoncms\api\query\Entity;
11
use samsonphp\generator\Generator;
12
13
/**
14
 * Virtual entity query class generator.
15
 *
16
 * @package samsoncms\api\generator
17
 */
18
class VirtualQuery extends RealQuery
19
{
20
    /**
21
     * Class uses generation part.
22
     *
23
     * @param VirtualMetadata $metadata Entity metadata
24
     */
25
    protected function createUses($metadata)
26
    {
27
        $this->generator
28
            ->newLine('use samsonframework\orm\QueryInterface;')
29
            ->newLine('use samsonframework\orm\ArgumentInterface;')
30
            ->newLine('use samson\activerecord\dbQuery;')
31
            ->newLine();
32
    }
33
34
    /**
35
     * Query constructor.
36
     *
37
     * @param Generator $generator
38
     * @param VirtualMetadata $metadata
39
     */
40
    public function __construct(Generator $generator, $metadata)
41
    {
42
        parent::__construct($generator, $metadata);
43
44
        $this->parentClass = '\\'.Entity::class;
45
        $this->entityClass = '\samsoncms\api\generated\\' . $metadata->entity;
46
    }
47
48
    /**
49
     * Class static fields generation part.
50
     *
51
     * @param VirtualMetadata $metadata Entity metadata
52
     */
53
    protected function createStaticFields($metadata)
54
    {
55
        $this->generator
56
            ->commentVar('array', 'Collection of localized additional fields identifiers')
57
            ->defClassVar('$virtualFieldIDs', 'public static', $metadata->fields)
58
            ->commentVar('array', 'Collection of additional fields value column names')
59
            ->defClassVar('$virtualFieldValueColumns', 'public static', $metadata->allFieldValueColumns)
60
            ->commentVar('array', 'Collection of real additional field names')
61
            ->defClassVar('$virtualFieldRealNames', 'public static', $metadata->realNames)
62
            ->commentVar('array', 'Collection of additional field names')
63
            ->defClassVar('$virtualFieldNames', 'public static', $metadata->fieldNames)
64
            ->commentVar('array', 'Collection of additional field names')
65
            ->defClassVar('$virtualRealFieldNames', 'public static', $metadata->fieldNames)
66
67
            ->commentVar('array', 'Collection of localized additional fields identifiers')
68
            ->defClassVar('$fieldIDs', 'public static', $metadata->parent->fields)
69
            ->commentVar('array', 'Collection of additional field names')
70
            ->defClassVar('$fieldNames', 'public static', $metadata->parent->fieldNames)
71
72
            // TODO: two above fields should be protected
73
            ->commentVar('array', 'Collection of navigation identifiers')
74
            ->defClassVar('$navigationIDs', 'public static', array($metadata->entityID))
75
            ->commentVar('string', 'Entity full class name')
76
            ->defClassVar('$identifier', 'public static', $this->entityClass)
77
            ->commentVar('array', 'Collection of localized additional fields identifiers')
78
            ->defClassVar('$localizedFieldIDs', 'public static', $metadata->localizedFieldIDs)
79
            ->commentVar('array', 'Collection of NOT localized additional fields identifiers')
80
            ->defClassVar('$notLocalizedFieldIDs', 'public static', $metadata->notLocalizedFieldIDs)
81
        ;
82
    }
83
84
    /**
85
     * Class constructor generation part.
86
     *
87
     * @param \samsoncms\api\generator\metadata\VirtualMetadata $metadata Entity metadata
88
     */
89 View Code Duplication
    protected function createConstructor($metadata)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        $class = "\n\t" . '/**';
92
        $class .= "\n\t" . ' * @param string $locale Localization identifier';
93
        $class .= "\n\t" . ' * @param QueryInterface $query Database query instance';
94
        $class .= "\n\t" . ' */';
95
        $class .= "\n\t" . 'public function __construct($locale = null, QueryInterface $query = null)';
96
        $class .= "\n\t" . '{';
97
        $class .= "\n\t\t" . '// TODO: This should be removed!';
98
        $class .= "\n\t\t" . '$container = $GLOBALS[\'__core\']->getContainer();';
99
        $class .= "\n\t\t" . 'parent::__construct($query ?? $container->get("query"), $locale);';
100
        $class .= "\n\t" . '}';
101
102
        $this->generator->text($class);
103
    }
104
}
105
//[PHPCOMPRESSOR(remove,end)]
106