Issues (9)

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/Frame/PriorityTrait.php (4 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
declare(strict_types=1);
3
namespace Hyphper\Frame;
4
5
/**
6
 * Trait for frames that contain priority data. Defines extra fields that can
7
 * be used and set by frames that contain priority data.
8
 *
9
 * @package Hyphper\Frame
10
 */
11
trait PriorityTrait
12
{
13
    protected $depends_on;
14
    protected $stream_weight;
15
    protected $exclusive;
16
17 6 View Code Duplication
    public function __construct(array $options = [])
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...
18
    {
19 6
        parent::__construct($options);
20 5
        $this->depends_on = (int) ($options['depends_on'] ?? 0);
21 5
        $this->stream_weight = (int) ($options['stream_weight'] ?? 0);
22 5
        $this->exclusive = (bool) ($options['exclusive'] ?? false);
23 5
    }
24
25
    /**
26
     * @return bool
27
     */
28 2
    public function getExclusive()
29
    {
30 2
        return $this->exclusive;
31
    }
32
33
    /**
34
     * @param bool $exclusive
35
     *
36
     * @return PriorityTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type PriorityTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
37
     */
38 2
    public function setExclusive(bool $exclusive)
39
    {
40 2
        $this->exclusive = $exclusive;
41
42 2
        return $this;
43
    }
44
45
    /**
46
     * @return int
47
     */
48 2
    public function getDependsOn()
49
    {
50 2
        return $this->depends_on;
51
    }
52
53
    /**
54
     * @param int $depends_on
55
     *
56
     * @return PriorityTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type PriorityTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
57
     */
58 2
    public function setDependsOn($depends_on)
59
    {
60 2
        $this->depends_on = $depends_on;
61
62 2
        return $this;
63
    }
64
65
    /**
66
     * @return int
67
     */
68 2
    public function getStreamWeight()
69
    {
70 2
        return $this->stream_weight;
71
    }
72
73
    /**
74
     * @param int $stream_weight
75
     *
76
     * @return PriorityTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type PriorityTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
77
     */
78 2
    public function setStreamWeight($stream_weight)
79
    {
80 2
        $this->stream_weight = $stream_weight;
81
82 2
        return $this;
83
    }
84
85 3
    protected function serializePriorityData()
86
    {
87 3
        return pack(
88 3
            'NC',
89 3
            $this->depends_on | ((int) ($this->exclusive) << 31),
90 3
            $this->stream_weight
91
        );
92
    }
93
94 3
    protected function parsePriorityData(string $data): int
95
    {
96 3
        if ($unpack = @unpack('Ndepends_on/Cstream_weight', substr($data, 0, 5))) {
97 2
            $this->depends_on = $unpack['depends_on'];
98 2
            $this->stream_weight = $unpack['stream_weight'];
99 2
            $this->exclusive = (bool) ($this->depends_on & PriorityInterface::MASK);
100 2
            $this->depends_on &= ~PriorityInterface::MASK;
101
102 2
            return 5;
103
        }
104
105 1
        throw new \Hyphper\Frame\Exception\InvalidFrameException('Invalid Priority data');
106
    }
107
}
108