Issues (17)

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.

src/RepeatableTask.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
/**
4
 * Copyright 2017 NanoSector
5
 *
6
 * You should have received a copy of the MIT license with the project.
7
 * See the LICENSE file for more information.
8
 */
9
10
namespace Yoshi2889\Tasks;
11
12
13
class RepeatableTask implements TaskInterface
14
{
15
	/**
16
	 * @var int
17
	 */
18
	protected $repeatInterval = 0;
0 ignored issues
show
Protected member variable "repeatInterval" must contain a leading underscore
Loading history...
19
20
	/**
21
	 * @var int
22
	 */
23
	protected $expiryTime = 0;
0 ignored issues
show
Protected member variable "expiryTime" must contain a leading underscore
Loading history...
24
25
	/**
26
	 * @var TaskInterface
27
	 */
28
	protected $childTask;
0 ignored issues
show
Protected member variable "childTask" must contain a leading underscore
Loading history...
29
30
	/**
31
	 * RepeatableTask constructor.
32
	 *
33
	 * @param TaskInterface $childTask
34
	 * @param int $repeatInterval
35
	 */
36 6
	public function __construct(TaskInterface $childTask, int $repeatInterval)
37
	{
38 6
		$this->expiryTime = time() + $repeatInterval;
39 6
		$this->repeatInterval = $repeatInterval;
40 6
		$this->childTask = $childTask;
41 6
	}
42
43
	/**
44
	 * @return null|TaskInterface
45
	 */
46 4
	public function run(): ?TaskInterface
47
	{
48 4
		if (time() >= $this->childTask->getExpiryTime())
49
		{
50 4
			$result = $this->childTask->run();
51
52 4
			if ($result instanceof TaskInterface)
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
53 1
				$this->childTask = $result;
54
		}
55
56 4
		$this->expiryTime = $this->getExpiryTime() + $this->getRepeatInterval();
57 4
		return $this->expiryTime > 0 ? $this : null;
58
	}
59
60 2
	public function cancel(): void
61
	{
62 2
		$this->childTask->cancel();
63 2
		$this->repeatInterval = 0;
64 2
		$this->expiryTime = 0;
65 2
	}
66
67
	/**
68
	 * @return int
69
	 */
70 6
	public function getRepeatInterval(): int
71
	{
72 6
		return $this->repeatInterval;
73
	}
74
75
	/**
76
	 * @param int $repeatInterval
77
	 */
78 1
	public function setRepeatInterval(int $repeatInterval)
79
	{
80 1
		$this->repeatInterval = $repeatInterval;
81 1
	}
82
83
	/**
84
	 * @return int
85
	 */
86 5
	public function getExpiryTime(): int
87
	{
88 5
		return $this->expiryTime;
89
	}
90
}