Issues (74)

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/Extension/BuiltInFunctionsExtensionTest.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
namespace Netdudes\DataSourceryBundle\Tests\Extension;
3
4
use Netdudes\DataSourceryBundle\Extension\BuiltInFunctionsExtension;
5
use Netdudes\DataSourceryBundle\Util\CurrentDateTimeProvider;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
8
9
class BuiltInFunctionsExtensionTest extends TestCase
10
{
11
    public function testNow()
12
    {
13
        $extension = $this->getExtension();
14
15
        $todayResult = $extension->now(null);
16
        $this->assertSame("2012-06-03T22:22:22+0200", $todayResult, 'The today function result did not produce the expected  with no offset');
17
18
        $offset = "+5 days";
19
        $todayResult = $extension->now($offset);
20
        $this->assertSame("2012-06-08T22:22:22+0200", $todayResult, 'The today function result did not produce the expected result with ofset ' . $offset);
21
22
        $offset = "-3 days";
23
        $todayResult = $extension->now($offset);
24
        $this->assertSame("2012-05-31T22:22:22+0200", $todayResult, 'The today function result did not produce the expected result with ofset ' . $offset);
25
26
        $offset = "-6 days - 3 minutes";
27
        $todayResult = $extension->now($offset);
28
        $this->assertSame("2012-05-28T22:19:22+0200", $todayResult, 'The today function result did not produce the expected result with ofset ' . $offset);
29
30
        $offset = "-30 minutes";
31
        $todayResult = $extension->now($offset);
32
        $this->assertSame("2012-06-03T21:52:22+0200", $todayResult, 'The today function result did not produce the expected result with ofset ' . $offset);
33
    }
34
35 View Code Duplication
    public function testStartOfDay()
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...
36
    {
37
        $extension = $this->getExtension();
38
39
        $startOfDayResult = $extension->startOfDay();
40
        $this->assertSame('2012-06-03T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
41
42
        $startOfDayResult = $extension->startOfDay('+2 hours');
43
        $this->assertSame('2012-06-04T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
44
45
        $startOfDayResult = $extension->startOfDay('-5 days');
46
        $this->assertSame('2012-05-29T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
47
48
        $startOfDayResult = $extension->startOfDay('+1 month');
49
        $this->assertSame('2012-07-03T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
50
51
        $startOfDayResult = $extension->startOfDay('15-05-2012');
52
        $this->assertSame('2012-05-15T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
53
54
        $startOfDayResult = $extension->startOfDay('2012-05-15');
55
        $this->assertSame('2012-05-15T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
56
57
        $startOfDayResult = $extension->startOfDay('15.05.2012');
58
        $this->assertSame('2012-05-15T00:00:00+0200', $startOfDayResult, 'The startOfDay function result did not produce the expected result');
59
    }
60
61 View Code Duplication
    public function testStartOfWeek()
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...
62
    {
63
        $extension = $this->getExtension();
64
65
        $startOfWeekResult = $extension->startOfWeek();
66
        $this->assertSame('2012-05-28T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
67
68
        $startOfWeekResult = $extension->startOfWeek('+2 hours');
69
        $this->assertSame('2012-06-04T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
70
71
        $startOfWeekResult = $extension->startOfWeek('-5 days');
72
        $this->assertSame('2012-05-28T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
73
74
        $startOfWeekResult = $extension->startOfWeek('+1 month');
75
        $this->assertSame('2012-07-02T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
76
77
        $startOfWeekResult = $extension->startOfWeek('15-05-2012');
78
        $this->assertSame('2012-05-14T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
79
80
        $startOfWeekResult = $extension->startOfWeek('2012-05-15');
81
        $this->assertSame('2012-05-14T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
82
83
        $startOfWeekResult = $extension->startOfWeek('15.05.2012');
84
        $this->assertSame('2012-05-14T00:00:00+0200', $startOfWeekResult, 'The startOfWeek function result did not produce the expected result');
85
    }
86
87 View Code Duplication
    public function testStartOfMonth()
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...
88
    {
89
        $extension = $this->getExtension();
90
91
        $startOfMonthResult = $extension->startOfMonth();
92
        $this->assertSame('2012-06-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
93
94
        $startOfMonthResult = $extension->startOfMonth('+2 hours');
95
        $this->assertSame('2012-06-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
96
97
        $startOfMonthResult = $extension->startOfMonth('-5 days');
98
        $this->assertSame('2012-05-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
99
100
        $startOfMonthResult = $extension->startOfMonth('+1 month');
101
        $this->assertSame('2012-07-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
102
103
        $startOfMonthResult = $extension->startOfMonth('15-05-2012');
104
        $this->assertSame('2012-05-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
105
106
        $startOfMonthResult = $extension->startOfMonth('2012-05-15');
107
        $this->assertSame('2012-05-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
108
109
        $startOfMonthResult = $extension->startOfMonth('15.05.2012');
110
        $this->assertSame('2012-05-01T00:00:00+0200', $startOfMonthResult, 'The startOfMonth function result did not produce the expected result');
111
    }
112
113 View Code Duplication
    public function testStartOfYear()
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...
114
    {
115
        $extension = $this->getExtension();
116
117
        $startOfYearResult = $extension->startOfYear();
118
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
119
120
        $startOfYearResult = $extension->startOfYear('+2 hours');
121
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
122
123
        $startOfYearResult = $extension->startOfYear('-5 days');
124
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
125
126
        $startOfYearResult = $extension->startOfYear('+1 month');
127
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
128
129
        $startOfYearResult = $extension->startOfYear('15-05-2012');
130
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
131
132
        $startOfYearResult = $extension->startOfYear('2012-05-15');
133
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
134
135
        $startOfYearResult = $extension->startOfYear('15.05.2012');
136
        $this->assertSame('2012-01-01T00:00:00+0200', $startOfYearResult, 'The startOfYear function result did not produce the expected result');
137
    }
138
139
    /**
140
     * @return BuiltInFunctionsExtension
141
     */
142
    private function getExtension()
143
    {
144
        $now = new \DateTime("2012-06-03T22:22:22+0200");
145
146
        $tokenStorage = $this->prophesize(TokenStorageInterface::class);
147
        $provider = $this->prophesize(CurrentDateTimeProvider::class);
148
        $provider->get()->willReturn($now);
149
        $extension = new BuiltInFunctionsExtension($tokenStorage->reveal(), $provider->reveal());
150
151
        return $extension;
152
    }
153
}
154