Issues (5)

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.

dist/readme-builder.php (2 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
 * This file is a readme.txt builder used to publish updates on WordPress repository.
4
 * It avoid duplicating README.md files and ensure simplicity on Github.
5
 *
6
 * @package wp-mautic
7
 */
8
9
// -----------------------------------------------------------------------------
10
/**
11
 * Markdown parser helper
12
 *
13
 * @param  string $file
14
 * @return array
15
 */
16
function parse_markdown( string $file ) :array {
17
	$source = fopen( $file, 'r' );
18
	$content = ['default' => ''];
19
	$current = 'default';
20
	$complement = '';
21
	$level = 0;
22
	$sourceCode = false;
23
	while ( ! feof( $source ) ) {
24
		$line = rtrim(fgets( $source ));
25
		if ( '' === $line ) {
26
			$content[ $current ] .= PHP_EOL;
27
			continue;
28
		}
29
		if ( strpos( $line, '#' ) === 0 ) {
30
			$tmp = strpos( $line, ' ' );
31
			if ( $level > 1 ) {
32
				if( $tmp > $level ) {
33
					$complement = $current . '{}';
34
				} elseif($tmp < $level) {
35
					$exploded = explode('{}', $current);
36
					$complement = count($exploded) <= 2
37
						? ''
38
						: implode('{}', array_slice($exploded, 0, count($exploded)-2)).'{}';
39
40
				}
41
			} else {
42
				$complement = '';
43
			}
44
			$current = $complement . trim( substr( $line, $tmp ) );
45
			$content[ $current ] = '';
46
			$level = $tmp;
47
		} else {
48
			if (0 === strpos($line, '`')) {
49
				$sourceCode = !$sourceCode;
50
				continue;
51
			}
52
53
			$content[ $current ] .= (true === $sourceCode?'    ':'').$line . PHP_EOL;
54
		}
55
	}
56
57
	return $content;
58
}
59
60
// -----------------------------------------------------------------------------
61
// readme.txt template
62
$template = <<<TXT
63
=== WP Mautic ===
64
Author: mautic
65
Tags: marketing, automation
66
%tags%
67
Donate link: http://mautic.org/
68
69
== Description ==
70
71
%heading%
72
73
## Key features
74
%key-features%
75
76
## Configuration
77
78
%configuration%
79
80
## Usage
81
82
%documentation%
83
84
== Installation ==
85
86
%installation%
87
88
== Upgrade Notice ==
89
90
%upgrade%== Changelog ==
91
92
%changelog%
93
TXT;
94
95
// -----------------------------------------------------------------------------
96
// Extract package tag
97
$source = fopen( __DIR__ . '/../wpmautic.php', 'r' );
98
$tags = [];
99
while ( ! feof( $source ) ) {
100
	$line = fgets( $source );
101
	if ( " * @package wp-mautic\n" === $line ) {
102
		break;
103
	}
104
	if (
105
		0 === strpos( $line, ' * ' ) &&
106
		false === strpos( $line, 'Author:' ) &&
107
		false === strpos( $line, 'Plugin ' )
108
	) {
109
		$tags[] = str_replace( 'Version:', 'Stable tag:', trim( substr( $line, 3 ) ) );
110
	}
111
}
112
$tags = implode( PHP_EOL, $tags );
113
114
// -----------------------------------------------------------------------------
115
// Extract upgrade notices
116
$notices = [];
117
foreach ( parse_markdown( __DIR__ . '/../UPGRADE.md' ) as $key => $notice ) {
118
	if ( ! preg_match( '/^v.*/', $key ) ) {
119
		continue;
120
	}
121
122
	$notices[] = "= $key =\n$notice";
123
}
124
$notices = implode( $notices );
125
126
// -----------------------------------------------------------------------------
127
// Extract changelog
128
$changelog = '';
129
$title = '';
130
foreach ( parse_markdown( __DIR__ . '/../CHANGELOG.md' ) as $key => $notice ) {
131
	if ( ! preg_match( '/^\[v.*/', $key ) ) {
132
		continue;
133
	}
134
	if ( false === strpos( $key, '{}' ) ) {
135
		preg_match( '/\[(.*)\] - (.*)/', $key, $matches );
136
		$changelog .= "= {$matches[1]} =\n\nRelease date: {$matches[2]}\n\n";
137
	} else {
138
		$tmp = explode( '{}', $key );
139
		$changelog .= "* {$tmp[1]}\n" . str_replace( '- ', '  * ', $notice );
140
	}
141
}
142
143
// -----------------------------------------------------------------------------
144
// Extract README details
145
$sections = [];
146
147
$readme = parse_markdown( __DIR__ . '/../README.md' );
148
149
$header = explode('=======================', $readme['default'] ?? '');
150
$heading = end($header);
151
$keyFeature = $readme['Key features'] ?? '';
152
$configuration = $readme['Configuration'] ?? '';
153
$documentation = '';
154
$installation = '';
155
foreach ( $readme as $key => $bloc ) {
156
	$tmp = [];
157
	if (false !== strpos( $key, '{}' )) {
158
		$tmp = explode( '{}', $key );
159
	}
160 View Code Duplication
	if (0 === strpos($key, 'Usage')) {
0 ignored issues
show
This code seems to be duplicated across 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...
161
		$documentation .= (count($tmp) > 1 ? str_repeat('#', count($tmp)+1).' '.end($tmp).PHP_EOL : '').$bloc;
162
	}
163 View Code Duplication
	if (0 === strpos($key, 'Installation')) {
0 ignored issues
show
This code seems to be duplicated across 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...
164
		$installation .= (count($tmp) > 1 ? str_repeat('#', count($tmp)+1).' '.end($tmp).PHP_EOL : '').$bloc;
165
	}
166
}
167
168
// -----------------------------------------------------------------------------
169
// Export template
170
echo str_replace([
171
    '%tags%',
172
    '%heading%',
173
    '%key-features%',
174
    '%configuration%',
175
    '%documentation%',
176
    '%installation%',
177
    '%changelog%',
178
    '%upgrade%',
179
    '%upgrade%',
180
], [
181
    $tags,
182
    trim($heading),
183
    trim($keyFeature),
184
    trim($configuration),
185
    trim($documentation),
186
    trim($installation),
187
    $changelog,
188
    $notices
189
], $template);
190