Issues (9)

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/Process/ProcessManagerTest.php (3 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
 * File ProcessManagerTest.php
4
 *
5
 * @author Edward Pfremmer <[email protected]>
6
 */
7
namespace Epfremme\ProcessQueue\Tests\Process;
8
9
use Epfremme\ProcessQueue\Process\ProcessFactory;
10
use Epfremme\ProcessQueue\Process\ProcessManager;
11
use Epfremme\ProcessQueue\Process\ProcessQueue;
12
use GuzzleHttp\Promise\PromiseInterface;
13
use Symfony\Component\Process\Process;
14
15
/**
16
 * Class ProcessManagerTest
17
 *
18
 * @package Epfremme\ProcessQueue\Tests\Process
19
 */
20
class ProcessManagerTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var ProcessFactory
24
     */
25
    private $factory;
26
27
    /**
28
     * @var \SplFileInfo|\Mockery\MockInterface
29
     */
30
    private $directory;
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function setUp()
36
    {
37
        parent::setUp();
38
39
        $this->factory = new ProcessFactory('pwd');
40
        $this->directory = \Mockery::mock(\SplFileInfo::class);
41
42
        $this->directory->shouldReceive('__toString')->andReturn('/tmp');
43
    }
44
45
    public function testConstruct()
46
    {
47
        $processManager = new ProcessManager($this->factory);
48
49
        $this->assertAttributeSame($this->factory, 'factory', $processManager);
50
        $this->assertAttributeInstanceOf(ProcessQueue::class, 'queue', $processManager);
51
    }
52
53
    public function testConstructWithLimit()
54
    {
55
        $processManager = new ProcessManager($this->factory, 4);
56
        $expectedQueue = new ProcessQueue(4);
57
58
        $this->assertAttributeEquals($expectedQueue, 'queue', $processManager);
59
    }
60
61 View Code Duplication
    public function testEnqueue()
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
        $processManager = new ProcessManager($this->factory);
64
        $promise = $processManager->enqueue($this->directory);
65
66
        $this->assertAttributeCount(1, 'queue', $processManager);
67
        $this->assertInstanceOf(PromiseInterface::class, $promise);
68
    }
69
70 View Code Duplication
    public function testEnqueueWithoutCwd()
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...
71
    {
72
        $processManager = new ProcessManager($this->factory);
73
        $promise = $processManager->enqueue();
74
75
        $this->assertAttributeCount(1, 'queue', $processManager);
76
        $this->assertInstanceOf(PromiseInterface::class, $promise);
77
    }
78
79
    public function testEnqueueFulfilledPromise()
80
    {
81
        $processManager = new ProcessManager($this->factory);
82
        $promise = $processManager->enqueue($this->directory);
83
84
        $resolved = false;
85
        $promise->then(function() use (&$resolved) {
86
            $this->assertInstanceOf(Process::class, func_get_arg(0));
87
            $resolved = true;
88
        });
89
90
        $processManager->run();
91
92
        $this->assertTrue($resolved);
93
    }
94
95
    public function testEnqueueRejectedPromise()
96
    {
97
        $processFactory = new ProcessFactory('noop');
98
        $processManager = new ProcessManager($processFactory);
99
        $promise = $processManager->enqueue($this->directory);
100
101
        $rejected = false;
102
        $promise->otherwise(function() use (&$rejected) {
103
            $this->assertInstanceOf(Process::class, func_get_arg(0));
104
            $rejected = true;
105
        });
106
107
        $processManager->run();
108
109
        $this->assertTrue($rejected);
110
    }
111
112
    /** @depends testEnqueue */
113
    public function testRun()
114
    {
115
        $processManager = new ProcessManager($this->factory);
116
        $promise = $processManager->enqueue($this->directory);
117
118
        $promise->then(function($process) {
119
            /** @var Process $process */
120
            $this->assertInstanceOf(Process::class, $process);
121
            $this->assertArrayHasKey(ProcessQueue::PROMISE_KEY, $process->getOptions());
122
123
            /** @var PromiseInterface $promise */
124
            $promise = $process->getOptions()[ProcessQueue::PROMISE_KEY];
125
            $this->assertInstanceOf(PromiseInterface::class, $promise);
126
            $this->assertTrue($process->isTerminated());
127
            $this->assertTrue($process->isStarted());
128
            $this->assertFalse($process->isRunning());
129
            $this->assertEquals(PromiseInterface::FULFILLED, $promise->getState());
130
        });
131
132
        $processManager->run();
133
    }
134
135
    /** @depends testEnqueue */
136 View Code Duplication
    public function testRunWithTick()
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...
137
    {
138
        $processManager = new ProcessManager($this->factory);
139
        $processManager->enqueue($this->directory);
140
141
        $ticks = 0;
142
        $processManager->run(function() use (&$ticks) {
143
            $ticks++;
144
        });
145
146
        $this->assertGreaterThan(0, $ticks);
147
    }
148
}
149