Issues (141)

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.

src/BibTex/Item.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 SRF\BibTex;
4
5
use SMWDataValue as DataValue;
6
7
/**
8
 * @see http://www.semantic-mediawiki.org/wiki/BibTex
9
 *
10
 * @license GNU GPL v2+
11
 * @since 3.1
12
 *
13
 * @author mwjames
14
 */
15
class Item {
16
17
	/**
18
	 * @see https://en.wikipedia.org/wiki/BibTeX
19
	 *
20
	 * @var string
21
	 */
22
	private $type = '';
23
24
	/**
25
	 * @var []
26
	 */
27
	protected $fields = [
28
		'address' => '',
29
		'annote' => '',
30
		'author' => [],
31
		'booktitle' => '',
32
		'chapter' => '',
33
		'crossref' => '',
34
		'doi' => '',
35
		'edition' => '',
36
		'editor' => [],
37
		'eprint' => '',
38
		'howpublished' => '',
39
		'institution' => '',
40
		'journal' => '',
41
		'key' => '',
42
		'month' => '',
43
		'note' => '',
44
		'number' => '',
45
		'organization' => '',
46
		'pages' => '',
47
		'publisher' => '',
48
		'school' => '',
49
		'series' => '',
50
		'title' => '',
51
		'url' => '',
52
		'volume' => '',
53
		'year' => ''
54
	];
55
56
	/**
57
	 * @var callable
58
	 */
59
	private $formatterCallback;
60
61
	/**
62
	 * @since 3.1
63
	 */
64 7
	public function __construct() {
65 7
		$this->type = 'Book';
66 7
	}
67
68
	/**
69
	 * @since 3.1
70
	 *
71
	 * @param callable $compoundLabelCallback
0 ignored issues
show
There is no parameter named $compoundLabelCallback. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
72
	 */
73 3
	public function setFormatterCallback( callable $formatterCallback ) {
74 3
		$this->formatterCallback = $formatterCallback;
75 3
	}
76
77
	/**
78
	 * @since 3.1
79
	 *
80
	 * @param $key
81
	 * @param string $text
82
	 *
83
	 * @return string
84
	 */
85 6
	public function replace( $key, $text ) {
86
87 6
		if ( $key === 'uri' ) {
88 6
			$text = str_replace(
89 6
				[ "Ä", "ä", "Ö", "ö", "Ü", "ü", "ß" ],
90 6
				[ 'Ae', 'ae', 'Oe', 'oe', 'Ue', 'ue', 'ss' ],
91
				$text
92
			);
93 6
			$text = preg_replace("/[^a-zA-Z0-9]+/", "", $text );
94
		}
95
96 6
		return $text;
97
	}
98
99
	/**
100
	 * @since 3.1
101
	 *
102
	 * @param $key
103
	 * @param mixed $value
104
	 */
105 5
	public function set( $key, $value ) {
106
107 5
		$key = strtolower( $key );
108
109 5
		if ( $key === 'type' ) {
110 1
			$this->type = ucfirst( $value );
111
		}
112
113 5
		if ( isset( $this->fields[$key] ) ) {
114 5
			$this->fields[$key] = $value;
115
		}
116 5
	}
117
118
	/**
119
	 * @since 3.1
120
	 *
121
	 * @return string
122
	 */
123 5
	public function text() {
124
125 5
		$formatterCallback = $this->formatterCallback;
126
127 5
		$text = '@' . $this->type . '{' . $this->buildURI() . ",\r\n";
128
129 5
		foreach ( $this->fields as $key => $value ) {
130
131 5
			if ( ( $key === 'author' || $key === 'editor' ) && is_array( $value ) ) {
132 5
				if ( is_callable( $formatterCallback ) ) {
133 3
					$value = $formatterCallback( $key, $value );
134
				} else {
135 2
					$value = implode( ', ', $value );
136
				}
137
			}
138
139 5
			if ( $value === '' ) {
140 5
				continue;
141
			}
142
143 5
			$text .= '  ' . $key . ' = "' . $value . '", ' . "\r\n";
144
		}
145
146 5
		$text .= "}";
147
148 5
		return $text;
149
	}
150
151
	/**
152
	 * Consist of `author last name` + `year` + `first word of title`
153
	 *
154
	 * @return string
155
	 */
156 5
	protected function buildURI() {
157
158 5
		$uri = '';
159
160 5
		if ( isset( $this->fields['author'] ) ) {
161 5
			foreach ( $this->fields['author'] as $key => $author ) {
162 3
				$elements = explode( ' ', $author );
163 3
				$uri .= array_pop( $elements );
164 3
				break;
165
			}
166
		}
167
168 5
		if ( isset( $this->fields['year'] ) ) {
169 5
			$uri .= $this->fields['year'];
170
		}
171
172 5
		if ( isset( $this->fields['title'] ) ) {
173 5
			foreach ( explode( ' ', $this->fields['title'] ) as $titleWord ) {
174 5
				$charsTitleWord = preg_split( '//', $titleWord, -1, PREG_SPLIT_NO_EMPTY );
175
176 5
				if ( !empty( $charsTitleWord ) ) {
177 3
					$uri .= $charsTitleWord[0];
178
				}
179
			}
180
		}
181
182 5
		return strtolower( $this->replace( 'uri', $uri ) );
183
	}
184
185
}
186