Issues (524)

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.

code/control/DeploynautLogFile.php (1 issue)

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
 * Simple support class for reading and writing deploynaut job logs
5
 */
6
class DeploynautLogFile {
7
8
	protected $logFile;
9
10
	protected $basePath;
11
12
	/**
13
	 * @param string $logFile The log filename
14
	 * @param string|null $basePath Base path of where logs reside. Defaults to DEPLOYNAUT_LOG_PATH
15
	 */
16
	public function __construct($logFile, $basePath = null) {
17
		$this->logFile = $logFile;
18
		if ($basePath !== null) {
19
			$this->basePath = $basePath;
20
		} else if (defined('DEPLOYNAUT_LOG_PATH')) {
21
			$this->basePath = DEPLOYNAUT_LOG_PATH;
22
		} else {
23
			$this->basePath = sys_get_temp_dir();
24
		}
25
	}
26
27
	/**
28
	 * Set the log filename
29
	 * @param string $filename
30
	 */
31
	public function setLogFile($filename) {
32
		$this->logFile = $filename;
33
	}
34
35
	/**
36
	 * Set the base path of where logs reside
37
	 * @param string $path
38
	 */
39
	public function setBasePath($path) {
40
		$this->basePath = $path;
41
	}
42
43
	/**
44
	 * Return the un-sanitised log path.
45
	 * @return string
46
	 */
47
	public function getRawFilePath() {
48
		return $this->basePath . '/' . $this->logFile;
49
	}
50
51
	/**
52
	 * Get the sanitised log path.
53
	 * @return string
54
	 */
55
	public function getSanitisedLogFilePath() {
56
		return $this->basePath . '/' . strtolower(FileNameFilter::create()->filter($this->logFile));
57
	}
58
59
	/**
60
	 * Return log file path, assuming it exists. Returns NULL if nothing found.
61
	 * @return string|null
62
	 */
63
	public function getLogFilePath() {
64
		$path = $this->getSanitisedLogFilePath();
65
66
		// for backwards compatibility on old logs
67
		if (!file_exists($path)) {
68
			$path = $this->getRawFilePath();
69
70
			if (!file_exists($path)) {
71
				return null;
72
			}
73
		}
74
75
		return $path;
76
	}
77
78
	/**
79
	 * Write a message line into the log file.
80
	 * @param string $message
81
	 */
82
	public function write($message) {
83
		// Make sure we write into the old path for existing logs. New logs use the sanitised file path instead.
84
		$path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath();
85
86
		error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path);
87
		@chmod($path, 0666);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
88
	}
89
90
	/**
91
	 * Does the log file exist?
92
	 * @return bool
93
	 */
94
	public function exists() {
95
		return (bool) $this->getLogFilePath();
96
	}
97
98
	/**
99
	 * Return the content of the log file.
100
	 * @return string
101
	 */
102
	public function content() {
103
		return $this->exists() ? file_get_contents($this->getLogFilePath()) : 'Log has not been created yet.';
104
	}
105
106
}
107