GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (7)

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/Service/WebTranslateItFileServiceTest.php (1 issue)

Labels
Severity

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
namespace Ozean12\WebTranslateItBundle\Tests\Service;
4
5
use Ozean12\WebTranslateItBundle\DTO\ProjectFileDTO;
6
use Ozean12\WebTranslateItBundle\Service\WebTranslateItFileService;
7
use Ozean12\WebTranslateItBundle\Service\WebTranslateItRepository;
8
9
/**
10
 * Class WebTranslateItFileServiceTest
11
 */
12
class WebTranslateItFileServiceTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var WebTranslateItFileService
16
     */
17
    private $service;
18
19
    /**
20
     * @var WebTranslateItRepository|\PHPUnit_Framework_MockObject_MockObject
21
     */
22
    private $translationRepository;
23
24
    /**
25
     * Set up
26
     */
27
    public function setUp()
28
    {
29
        $this->translationRepository = $this
30
            ->getMockBuilder(WebTranslateItRepository::class)
31
            ->disableOriginalConstructor()
32
            ->getMock()
33
        ;
34
35
        $this->service = new WebTranslateItFileService($this->translationRepository);
36
37
        parent::setUp();
38
    }
39
40
    /**
41
     * Tear down
42
     */
43
    public function tearDown()
44
    {
45
        $testDirectory = $this->getTranslationDirectory();
46
        if (file_exists($testDirectory)) {
47
            $testFile = sprintf('%s/%s', $testDirectory, $this->getProjectFileDTO()->getName());
48
            if (file_exists($testFile)) {
49
                unlink($testFile);
50
            }
51
            rmdir($testDirectory);
52
        }
53
54
        parent::tearDown();
55
    }
56
57
    /**
58
     * Test should be updated with local file not present
59
     */
60
    public function testShouldBeUpdatedWithNoLocalFile()
61
    {
62
        $this->service->prepare($this->getTranslationDirectory());
63
64
        $projectFile = new ProjectFileDTO();
65
        $filePath = sprintf('%s/%s', $this->getTranslationDirectory(), 'some_other_file.yml');
66
67
        $this->assertEquals(true, $this->service->shouldBeUpdated($filePath, $projectFile));
68
    }
69
70
    /**
71
     * Test should be updated
72
     *
73
     * @dataProvider shouldBeUpdatedDataProvider
74
     *
75
     * @param string $localTimestamp
76
     * @param string $remoteTimestamp
77
     * @param string $localContent
78
     * @param string $remoteContent
79
     * @param bool   $expectedResult
80
     * @param string $message
81
     */
82
    public function testShouldBeUpdated(
83
        $localTimestamp,
84
        $remoteTimestamp,
85
        $localContent,
86
        $remoteContent,
87
        $expectedResult,
88
        $message
89
    ) {
90
        $this->service->prepare($this->getTranslationDirectory());
91
        $filePath = sprintf('%s/%s', $this->getTranslationDirectory(), $this->getProjectFileDTO()->getName());
92
        file_put_contents($filePath, $localContent);
93
        touch($filePath, (new \DateTime($localTimestamp))->getTimestamp());
94
95
        $projectFile = new ProjectFileDTO();
96
        $projectFile
97
            ->setUpdatedAt(new \DateTime($remoteTimestamp))
98
            ->setHashFile(sha1($remoteContent))
99
        ;
100
101
        $this->assertEquals($expectedResult, $this->service->shouldBeUpdated($filePath, $projectFile), $message);
102
    }
103
104
    /**
105
     * @return array
106
     */
107
    public function shouldBeUpdatedDataProvider()
108
    {
109
        return [
110
            ['today', 'today', 'hello', 'hello', false, 'Everything equal - skip'],
111
            ['yesterday', 'today', 'hello', 'hello', true, 'Local file is older - pull'],
112
            ['today', 'yesterday', 'hello', 'hello', false, 'Local file is newer - skip'],
113
            ['today', 'today', 'hello', 'hello1', true, 'Hash doesn\'t match - pull'],
114
        ];
115
    }
116
117
    /**
118
     * Test update
119
     */
120
    public function testUpdate()
121
    {
122
        $projectFile = $this->getProjectFileDTO();
123
        $filePath = sprintf('%s/%s', $this->getTranslationDirectory(), $projectFile->getName());
124
        $this->translationRepository->method('pullFile')->willReturn($this->getPullFileContent());
125
        $this->translationRepository->expects($this->once())->method('pullFile')->with($projectFile->getName());
0 ignored issues
show
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Ozean12\WebTranslateItBu...ebTranslateItRepository.

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...
126
127
        $this->service->prepare($this->getTranslationDirectory());
128
        $this->service->update($filePath, $projectFile);
129
        $this->assertFileExists($filePath);
130
    }
131
132
    /**
133
     * Test prepare
134
     */
135
    public function testPrepare()
136
    {
137
        $this->service->prepare($this->getTranslationDirectory());
138
        $this->assertFileExists($this->getTranslationDirectory());
139
    }
140
141
    /**
142
     * @return string
143
     */
144
    private function getTranslationDirectory()
145
    {
146
        return __DIR__.'/translations';
147
    }
148
149
    /**
150
     * @return string
151
     */
152
    private function getPullFileContent()
153
    {
154
        return 'hello: Hello';
155
    }
156
157
    /**
158
     * @return ProjectFileDTO
159
     */
160
    private function getProjectFileDTO()
161
    {
162
        $file = new ProjectFileDTO();
163
164
        return $file
165
            ->setId(43)
166
            ->setName('test_messages.yml')
167
        ;
168
    }
169
}
170