Issues (51)

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.

Sniffs/DocTags/AbstractDisallowedTagsSniff.php (1 issue)

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
3
declare(strict_types=1);
4
5
namespace BestIt\Sniffs\DocTags;
6
7
use BestIt\CodeSniffer\Helper\DocTagHelper;
8
use BestIt\Sniffs\AbstractSniff;
9
use BestIt\Sniffs\DocPosProviderTrait;
10
use function in_array;
11
use function substr;
12
13
/**
14
 * Sniff to disallow the given tags.
15
 *
16
 * @author blange <[email protected]>
17
 * @package BestIt\Sniffs\DocTags
18
 */
19
abstract class AbstractDisallowedTagsSniff extends AbstractSniff
20
{
21
    use DocPosProviderTrait;
22
23
    /**
24
     * You MUST not give one of the disallowed tags in your doc comment.
25
     */
26
    public const CODE_TAG_NOT_ALLOWED = 'TagNotAllowed';
27
28
    /**
29
     * Message that comment tag is not allowed.
30
     */
31
    private const MESSAGE_TAG_NOT_ALLOWED = 'The comment tag "%s" is not allowed.';
32
33
    /**
34
     * This tags are disallowed and could be injected from the outside.
35
     *
36
     * @var array
37
     */
38
    public array $disallowedTags = [];
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
39
40
    /**
41
     * The possible tags of this php structure.
42
     *
43
     * @var array|null Tag tokens.
44
     */
45
    private ?array $tags = null;
46
47
    /**
48
     * Returns true if the requirements for this sniff are met.
49
     *
50
     * @return bool Are the requirements met and the sniff should proceed?
51
     */
52
    protected function areRequirementsMet(): bool
53
    {
54
        return $this->getDocCommentPos() && $this->getAllTags();
55
    }
56
57
    /**
58
     * Checks and registers errors for the disallowed tags.
59
     *
60
     * @return void
61
     */
62
    private function checkAndRegisterDisallowedTagsError(): void
63
    {
64
        $disallowedTags = $this->getDisallowedTags();
65
        $tags = $this->getAllTags();
66
67
        foreach ($tags as $tagPos => $tag) {
68
            $tagContent = $tag['content'];
69
70
            if (in_array(substr($tagContent, 1), $disallowedTags)) {
71
                $this->file->addError(
72
                    self::MESSAGE_TAG_NOT_ALLOWED,
73
                    $tagPos,
74
                    static::CODE_TAG_NOT_ALLOWED,
75
                    [$tagContent]
76
                );
77
            }
78
        }
79
    }
80
81
    /**
82
     * Returns all tag tokens for this doc block.
83
     *
84
     * @return array
85
     */
86
    private function getAllTags(): array
87
    {
88
        if ($this->tags === null) {
89
            $this->tags = $this->loadAllTags();
90
        }
91
92
        return $this->tags;
93
    }
94
95
    /**
96
     * Type-safe getter for the disallowed tags.
97
     *
98
     * We need this because the ruleset user can "break" the api, if he does not provide an array with his config.
99
     *
100
     * @return array
101
     */
102
    private function getDisallowedTags(): array
103
    {
104
        return $this->disallowedTags;
105
    }
106
107
    /**
108
     * Loads all tags of the structures doc block.
109
     *
110
     * @return array
111
     */
112
    private function loadAllTags(): array
113
    {
114
        return (new DocTagHelper(
115
            $this->file,
116
            $this->getDocCommentPos(),
117
            $this->tokens
118
        )
119
        )->getTagTokens();
120
    }
121
122
    /**
123
     * Processes the token.
124
     *
125
     * @return void
126
     */
127
    protected function processToken(): void
128
    {
129
        $this->checkAndRegisterDisallowedTagsError();
130
    }
131
132
    /**
133
     * Removes the cached data.
134
     *
135
     * @return void
136
     */
137
    protected function tearDown(): void
138
    {
139
        $this->resetDocCommentPos();
140
141
        $this->tags = null;
142
    }
143
}
144