Issues (38)

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.

tests/UserTest.php (9 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
3
use Syntax\SteamApi\Exceptions\UnrecognizedId;
4
5
require_once('BaseTester.php');
6
7
/** @group User */
8
class UserTest extends BaseTester {
0 ignored issues
show
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
9
10
    /** @test */
11
    public function it_accepts_an_array_of_steam_ids()
12
    {
13
        $steamIds = [$this->id32, $this->altId64];
14
15
        $userService = $this->steamClient->user($steamIds);
16
17
        $this->assertCount(2, $userService->getSteamId());
18
        $this->assertEquals($this->id64, $userService->getSteamId()[0]);
19
    }
20
21
    /**
22
     * @test
23
     * @throws UnrecognizedId
24
     */
25 View Code Duplication
    public function it_throws_an_exception_when_no_display_name_is_provided()
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...
26
    {
27
        if (method_exists($this, 'setExpectedException')) {
28
            $this->setExpectedException('Syntax\SteamApi\Exceptions\UnrecognizedId');
0 ignored issues
show
The method setExpectedException() does not seem to exist on object<UserTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        } else {
30
            $this->expectException('Syntax\SteamApi\Exceptions\UnrecognizedId');
31
        }
32
        
33
        $steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL();
34
35
        $this->assertEquals('No match', $steamObject);
36
    }
37
38
    /** @test
39
     * @throws UnrecognizedId
40
     */
41
    public function it_returns_no_match_from_an_invalid_display_name()
42
    {
43
        $steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL('stygiansabyssINVALID');
44
45
        $this->assertEquals('No match', $steamObject);
46
    }
47
48
    /** @test
49
     * @throws UnrecognizedId
50
     */
51
    public function it_gets_the_steam_id_from_a_display_name()
52
    {
53
        $steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL('stygiansabyss');
54
55
        $this->assertEquals($this->id64, $steamObject->id64);
56
    }
57
58
    /** @test */
59
    public function it_gets_the_base_users_player_summary()
60
    {
61
        $friendsList = $this->steamClient->user($this->id64)->GetPlayerSummaries();
62
63
        $this->assertCount(1, $friendsList);
0 ignored issues
show
$friendsList is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
        $this->checkPlayerProperties($friendsList);
65
        $this->checkPlayerClasses($friendsList);
66
    }
67
68
    /** @test */
69
    public function it_gets_the_supplied_users_player_summary()
70
    {
71
        $friendsList = $this->steamClient->user($this->id64)->GetPlayerSummaries($this->altId64);
72
73
        $this->assertCount(1, $friendsList);
0 ignored issues
show
$friendsList is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74
        $this->checkPlayerProperties($friendsList);
75
        $this->checkPlayerClasses($friendsList);
76
77
        $this->assertNotEquals($friendsList[0]->steamId, $this->id64);
78
    }
79
80
    /** @test */
81 View Code Duplication
    public function it_gets_all_users_in_friend_list()
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...
82
    {
83
        $friendsList = $this->steamClient->user($this->id64)->GetFriendList('all');
84
85
        $this->assertGreaterThan(0, $friendsList);
86
87
        $this->checkPlayerProperties($friendsList);
88
        $this->checkPlayerClasses($friendsList);
89
    }
90
91
    /** @test */
92 View Code Duplication
    public function it_gets_friend_users_in_friend_list()
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...
93
    {
94
        $friendsList = $this->steamClient->user($this->id64)->GetFriendList('friend');
95
96
        $this->assertGreaterThan(0, $friendsList);
97
98
        $this->checkPlayerProperties($friendsList);
99
        $this->checkPlayerClasses($friendsList);
100
    }
101
102
    /** @test */
103 View Code Duplication
    public function it_throws_exception_to_invalid_relationship_types()
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...
104
    {
105
        $expectedMessage = 'Provided relationship [nonFriend] is not valid.  Please select from: all, friend';
106
        
107
        if (method_exists($this, 'setExpectedException')) {
108
            $this->setExpectedException('InvalidArgumentException', $expectedMessage);
0 ignored issues
show
The method setExpectedException() does not seem to exist on object<UserTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
        } else {
110
            $this->expectException('InvalidArgumentException');
111
            $this->expectExceptionMessage($expectedMessage);
112
        }
113
114
        $this->steamClient->user($this->id64)->GetFriendList('nonFriend');
115
    }
116
117
    /** @test */
118
    public function it_gets_the_bans_for_the_base_user()
119
    {
120
        $bans = $this->steamClient->user($this->id64)->GetPlayerBans();
121
122
        $this->assertCount(1, $bans);
123
124
        $attributes = ['SteamId', 'CommunityBanned', 'VACBanned', 'NumberOfVACBans', 'DaysSinceLastBan', 'EconomyBan'];
125
        $this->assertObjectHasAttributes($attributes, $bans[0]);
126
    }
127
128
    /** @test */
129
    public function it_gets_the_bans_for_the_supplied_user()
130
    {
131
        $bans = $this->steamClient->user($this->id64)->GetPlayerBans($this->altId64);
132
133
        $this->assertCount(1, $bans);
134
135
        $attributes = ['SteamId', 'CommunityBanned', 'VACBanned', 'NumberOfVACBans', 'DaysSinceLastBan', 'EconomyBan'];
136
        $this->assertObjectHasAttributes($attributes, $bans[0]);
137
138
        $this->assertNotEquals($bans[0]->SteamId, $this->id64);
139
    }
140
141
    private function checkPlayerClasses($friendsList)
142
    {
143
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Player', $friendsList[0]);
144
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Id', $friendsList[0]->steamIds);
145
    }
146
}