Issues (169)

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/attendeeTest.php (7 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
require_once dirname(__FILE__).'/mock/functions.php';
4
require_once dirname(__FILE__).'/../programs/caldav.class.php';
5
require_once dirname(__FILE__).'/mock/calendar.php';
6
7
8
9
10
11
class LibCaldav_attendeeTest extends PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var LibCaldav_mock
15
     */
16
    static $mock;
17
18
    public static function setUpBeforeClass()
19
    {
20
        self::$mock = bab_getInstance('LibCaldav_mock');
21
    }
22
    
23
    public function testOviWithCaldavAttendeeSaveEvent()
24
    {
25
        $oviUser = self::$mock->getOviUser();
26
        $caldavUser = self::$mock->getCaldavUser();
27
        $oviBackend = self::$mock->getOviBackend();
28
        $caldavBackend = self::$mock->getCaldavBackend();
29
        
30
        
31
        $oviCalendar = $oviBackend->PersonalCalendar($oviUser);
32
        $collection = $oviBackend->CalendarEventCollection($oviCalendar);
0 ignored issues
show
It seems like $oviCalendar defined by $oviBackend->PersonalCalendar($oviUser) on line 31 can be null; however, Func_CalendarBackend::CalendarEventCollection() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
33
        
34
        $caldavCalendar = $caldavBackend->PersonalCalendar($caldavUser);
35
        
36
        $dtstart = BAB_DateTime::fromIsoDateTime('2015-01-01 00:00:00');
37
        $dtend = BAB_DateTime::fromIsoDateTime('2015-01-02 00:00:00');
38
        
39
        $period = new bab_CalendarPeriod();
40
        $period->setCollection($collection);
41
        $period->setDates($dtstart, $dtend);
42
        $period->setProperty('UID', 'LIBCALDAV_UNITTEST_2');
43
        $period->setProperty('SUMMARY', 'Test event');
44
        $period->setProperty('STATUS', 'CONFIMED');
45
        
46
        $period->addAttendee($oviCalendar);
0 ignored issues
show
It seems like $oviCalendar defined by $oviBackend->PersonalCalendar($oviUser) on line 31 can be null; however, bab_ICalendarObject::addAttendee() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
47
        $period->addAttendee($caldavCalendar);
48
        
49
        $collection->addPeriod($period);
50
        
51
        $this->assertEquals(2, count($period->getAttendees()), 'verify number of attendees');
52
        
53
        $this->assertTrue($oviBackend->savePeriod($period));
54
        
55
        // create association with external calendars:
56
        $period->commitEvent();
57
    }
58
    
59
    
60
    
61
    
62 View Code Duplication
    public function testOviGetEvent()
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...
63
    {
64
        $oviUser = self::$mock->getOviUser();
65
        $oviBackend = self::$mock->getOviBackend();
66
        
67
        $calendar = $oviBackend->PersonalCalendar($oviUser);
68
        $collection = $oviBackend->CalendarEventCollection($calendar);
0 ignored issues
show
It seems like $calendar defined by $oviBackend->PersonalCalendar($oviUser) on line 67 can be null; however, Func_CalendarBackend::CalendarEventCollection() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
69
        
70
        $period = $oviBackend->getPeriod($collection, 'LIBCALDAV_UNITTEST_2');
71
        
72
        $this->assertInstanceOf('bab_CalendarPeriod', $period);
73
        $this->assertEquals('Test event', $period->getProperty('SUMMARY'));
74
    }
75
    
76
    
77 View Code Duplication
    protected function getPeriod()
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...
78
    {
79
        $caldavUser = self::$mock->getCaldavUser();
80
        $caldavBackend = self::$mock->getCaldavBackend();
81
        
82
        $calendar = $caldavBackend->PersonalCalendar($caldavUser);
83
        $collection = $caldavBackend->CalendarEventCollection($calendar);
84
        
85
        return $caldavBackend->getPeriod($collection, 'LIBCALDAV_UNITTEST_2');
86
    }
87
    
88
    
89 View Code Duplication
    protected function getOviPeriod()
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
        $oviUser = self::$mock->getOviUser();
92
        $oviBackend = self::$mock->getOviBackend();
93
    
94
        $calendar = $oviBackend->PersonalCalendar($oviUser);
95
        $collection = $oviBackend->CalendarEventCollection($calendar);
0 ignored issues
show
It seems like $calendar defined by $oviBackend->PersonalCalendar($oviUser) on line 94 can be null; however, Func_CalendarBackend::CalendarEventCollection() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
96
    
97
        return $oviBackend->getPeriod($collection, 'LIBCALDAV_UNITTEST_2');
98
    }
99
    
100
    
101
    public function testCaldavGetEvent()
102
    {
103
        $period = $this->getPeriod();
104
    
105
        $this->assertInstanceOf('bab_CalendarPeriod', $period);
106
        $this->assertEquals('Test event', $period->getProperty('SUMMARY'));
107
    }
108
    
109
    public function testCaldavSearchEvent()
110
    {
111
        $caldavUser = self::$mock->getCaldavUser();
112
        $caldavBackend = self::$mock->getCaldavBackend();
113
        
114
        $calendar = $caldavBackend->PersonalCalendar($caldavUser);
115
        
116
        $from = BAB_DateTime::fromIsoDateTime('2015-01-01 00:00:00');
117
        $to = BAB_DateTime::fromIsoDateTime('2015-01-02 00:00:00');
118
        
119
        
120
        $query = $caldavBackend->Criteria();
121
        
122
        $criteria = $query->Begin($from)
123
            ->_AND_($query->End($to))
124
            ->_AND_($query->Calendar($calendar));
125
        
126
        $arr = $caldavBackend->selectPeriods($criteria);
127
        
128
        // can be 2 if caldav calendar has net been reset
129
        //$this->assertEquals(1, count($arr));
130
        
131
        $period = $arr[0];
132
        
133
        $this->assertInstanceOf('bab_CalendarPeriod', $period);
134
        $this->assertEquals('Test event', $period->getProperty('SUMMARY'));
135
    }
136
    
137
    
138
    public function testCancelInAllCalendars()
139
    {
140
        $caldavUser = self::$mock->getCaldavUser();
141
        $caldavBackend = self::$mock->getCaldavBackend();
142
        
143
        $calendar = $caldavBackend->PersonalCalendar($caldavUser);
144
        
145
        $period = $this->getPeriod();
146
        $this->assertTrue($period->cancelFromAllCalendars($calendar));
147
        
148
        $this->assertEquals('CANCELLED', $this->getPeriod()->getProperty('STATUS'));
149
        
150
        $oviPeriod = $this->getOviPeriod();
151
        $this->assertEquals('CANCELLED', $oviPeriod->getProperty('STATUS'));
152
    }
153
    
154
    
155
    public function testDeleteEvent()
156
    {
157
        $period = $this->getPeriod();
158
        $period->delete();
159
160
        $deletedPeriod = $this->getPeriod();
161
        
162
        $this->assertEquals(null, $deletedPeriod);
163
        
164
        // event is not deleted in ovidentia backend!
165
    }
166
}
167