Issues (10)

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.

tests/FacadeTest.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
/**
3
 * Copyright 2017 OpenStack Foundation
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 * http://www.apache.org/licenses/LICENSE-2.0
8
 * Unless required by applicable law or agreed to in writing, software
9
 * distributed under the License is distributed on an "AS IS" BASIS,
10
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 * See the License for the specific language governing permissions and
12
 * limitations under the License.
13
 **/
14
15
use OutlookRestClient\IOutlookRestClient;
16
use OutlookRestClient\Facade\OutlookRestClient;
17
use OutlookRestClient\Facade\Requests\CalendarVO;
18
use OutlookRestClient\Facade\Requests\EventVO;
19
use OutlookRestClient\Facade\Requests\LocationVO;
20
use OutlookRestClient\Facade\Requests\AddressVO;
21
/**
22
 * Class FacadeTest
23
 */
24
final class FacadeTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
25
{
26
    /**
27
     * @var IOutlookRestClient
28
     */
29
    private static $client;
30
31
    private static function generateRandomResourceId(){
32
        return md5(uniqid(mt_rand(), true));
33
    }
34
35
    public static function setUpBeforeClass()
36
    {
37
        $dotenv = new Dotenv\Dotenv(__DIR__.'/../');
38
        $dotenv->load();
39
        self::$client = new OutlookRestClient();
40
        self::$client->setTokenCallback(function($access_token){
0 ignored issues
show
The parameter $access_token is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
            echo "renewed accesss token!";
42
        });
43
        $access_token = <<< JSON
44
{"token_type":"Bearer","scope":"https:\/\/outlook.office.com\/User.Read https:\/\/outlook.office.com\/Calendars.ReadWrite","ext_expires_in":0,"id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjFMVE16YWtpaGlSbGFfOHoyQkVKVlhlV01xbyJ9.eyJ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OFvb26kzx2rvZbYpY6kJ1RgdTW7XdWoeTVfNqMGc1gOeHzY2I43cp04zvktAgd!0ryOXuw!RPAUqWy8yntWMuICY5vZC!lCTbnEcln8EnH8ILmgCnPx*fKoMzwp9r2RyEvKywZuNZuAYZ2LeEngz5jZqmQqiHSj38gwZc4aWOePmKKqOHnkGGKZHNwP2SYletg!9lWTmA0QwR8KJBI7hhrt*1fUS7Hdtk6AAJdVH2XtHL3fdK1RynMlASvO6vccW7O2wssp6h031aUyAKCElka2Z3bReARDUA9Pzp9mXHDd6hz6do3!m3zcezrydPHDwzkH02p*ADCppcoXloJAwbD!mXIKh7X0W!dg3ffSZhuRdctsVgtT9LbEB5KEkXcpBcKR6nfAKh5yLzSTusk1FkxClShuAaTi2eqZFvrMtbUqMbKPwiWLehv!Y9I*60DLfMmSciRDMRCv2skqhuXVzqS9e0X483*F1YH!lN","expires":1501691484}
45
JSON;
46
        self::$client->setAccessToken(json_decode($access_token, true));
47
    }
48
49
    public static function tearDownAfterClass()
50
    {
51
        // do sth after the last test
52
    }
53
54
    public function testCreateCalendar($name = null){
55
        if(empty($name)) $name = self::generateRandomResourceId();
56
        $res = self::$client->createCalendar(new CalendarVO($name));
57
        $id = $res->getId();
58
        $this->assertTrue(!empty($id));
59
        echo printf("new calendar id %s", $id).PHP_EOL;
60
        return $id;
61
    }
62
63
    public function testDeleteCalendar(){
64
        $id  = $this->testCreateCalendar();
65
        // https://stackoverflow.com/questions/31923669/office-365-unified-api-error-when-deleting-a-calendar
66
        // https://stackoverflow.com/questions/44597230/office365-calendar-rest-api-cannot-delete-calendars
67
        //self::$client->updateCalendar($id, new CalendarVO("deleted!"));
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
68
        $res = self::$client->deleteCalendar($id);
69
70
        $this->assertTrue($res);
71
    }
72
73
    public function testAddNewEvent(){
74
        $id  = $this->testCreateCalendar();
75
76
        $res = self::$client->createEvent($id, new EventVO(
77
            "test event",
78
            "test event body",
79
            new DateTime('2017-11-01 09:00:00'),
80
            new DateTime('2017-11-01 10:30:00'),
81
            new DateTimeZone('Australia/Sydney'),
82
            new LocationVO(
83
                "Boston Marriott Copley Place",
84
                new AddressVO(
85
                    "110 Huntington Av",
86
                    "Boston",
87
                    "MA",
88
                    "USA",
89
                    "02116"
90
                ),
91
                "42.3471832",
92
                "-71.0778024"
93
            )
94
        ));
95
96
        $this->assertTrue($res instanceof \OutlookRestClient\Facade\Responses\EventResponse);
97
        $this->assertTrue(!empty($res->getId()));
98
99
        return $res->getId();
100
    }
101
102
    public function testGetCalendars(){
103
        $res = self::$client->getCalendars();
104
        $this->assertTrue(count($res->getEntries()) > 0);
0 ignored issues
show
The method getEntries does only exist in OutlookRestClient\Facade...endarCollectionResponse, but not in OutlookRestClient\Facade\Responses\ErrorResponse.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
105
    }
106
107
    public function testDeleteNewEvent(){
108
        $id  = $this->testAddNewEvent();
109
110
        $res = self::$client->deleteEvent($id);
111
112
        $this->assertTrue($res);
113
    }
114
}