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/BibTexFileExportPrinter.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 SMWTimeValue as TimeValue;
6
use SMWQueryResult as QueryResult;
7
use SMW\Query\ResultPrinters\FileExportPrinter;
8
9
/**
10
 * Printer class for creating BibTeX exports
11
 *
12
 * For details on availble keys see the README
13
 *
14
 * Example of a book :
15
 *
16
 * @Book{abramowitz1964homf,
17
 *   author =     "Milton Abramowitz and Irene A. Stegun",
18
 *   title =     "Handbook of Mathematical Functions",
19
 *   publisher =     "Dover",
20
 *   year =     1964,
21
 *   address =     "New York",
22
 *   edition =     "ninth Dover printing, tenth GPO printing"
23
 * }
24
 *
25
 * @license GNU GPL v2+
26
 * @since 1.5
27
 *
28
 * @author Markus Krötzsch
29
 * @author Denny Vrandecic
30
 * @author Frank Dengler
31
 * @author Steren Giannini
32
 */
33
class BibTexFileExportPrinter extends FileExportPrinter {
34
35
	/**
36
	 * @see ResultPrinter::getName
37
	 *
38
	 * {@inheritDoc}
39
	 */
40
	public function getName() {
41
		return wfMessage( 'srf_printername_bibtex' )->text();
42
	}
43
44
	/**
45
	 * @see FileExportPrinter::getMimeType
46
	 *
47
	 * @since 1.8
48
	 *
49
	 * {@inheritDoc}
50
	 */
51 1
	public function getMimeType( QueryResult $queryResult ) {
52 1
		return 'text/bibtex';
53
	}
54
55
	/**
56
	 * @see FileExportPrinter::getFileName
57
	 *
58
	 * @since 1.8
59
	 *
60
	 * {@inheritDoc}
61
	 */
62 6
	public function getFileName( QueryResult $queryResult ) {
63
64 6
		if ( $this->params['filename'] !== '' ) {
65
66 4
			if ( strpos( $this->params['filename'], '.bib' ) === false ) {
67 1
				$this->params['filename'] .= '.bib';
68
			}
69
70 4
			return str_replace( ' ', '_', $this->params['filename'] );
71 2
		} elseif ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) != '' ) {
72 1
			return str_replace( ' ', '_', $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) . '.bib';
73
		}
74
75 1
		return 'BibTeX.bib';
76
	}
77
78
	/**
79
	 * @see ResultPrinter::getParamDefinitions
80
	 *
81
	 * @since 1.8
82
	 *
83
	 * {@inheritDoc}
84
	 */
85 1
	public function getParamDefinitions( array $definitions ) {
86 1
		$params = parent::getParamDefinitions( $definitions );
87
88 1
		$params['filename'] = [
89
			'message' => 'smw-paramdesc-filename',
90
			'default' => 'bibtex.bib',
91
		];
92
93 1
		return $params;
94
	}
95
96
	/**
97
	 * @since 3.1
98
	 *
99
	 * @param array $list
0 ignored issues
show
There is no parameter named $list. 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...
100
	 *
101
	 * @return string
102
	 */
103 1
	public function getFormattedList( $key, array $values ) {
104 1
		return $GLOBALS['wgLang']->listToText( $values );
105
	}
106
107
	/**
108
	 * @see ResultPrinter::getResultText
109
	 *
110
	 * {@inheritDoc}
111
	 */
112 2
	protected function getResultText( QueryResult $res, $outputMode ) {
113
114 2
		if ( $outputMode !== SMW_OUTPUT_FILE ) {
115 1
			return $this->getBibTexLink( $res, $outputMode );
116
		}
117
118 1
		$items = [];
119
120 1
		while ( $row = $res->getNext() ) {
121 1
			$items[] = $this->newItem( $row )->text();
122
		}
123
124 1
		return implode( "\r\n\r\n", $items );
125
	}
126
127 1
	private function getBibTexLink( QueryResult $res, $outputMode ) {
128
129
		// Can be viewed as HTML if requested, no more parsing needed
130 1
		$this->isHTML = $outputMode == SMW_OUTPUT_HTML;
131
132 1
		$link = $this->getLink(
133 1
			$res,
134
			$outputMode
135
		);
136
137 1
		return $link->getText( $outputMode, $this->mLinker );
138
	}
139
140
	/**
141
	 * @since 3.1
142
	 *
143
	 * @param $row array of SMWResultArray
144
	 *
145
	 * @return bibTexItem
146
	 */
147 1
	private function newItem( array /* of SMWResultArray */ $row ) {
148
149 1
		$item = new Item();
150 1
		$item->setFormatterCallback( [ $this, 'getFormattedList' ] );
151
152 1
		foreach ( $row as /* SMWResultArray */ $field ) {
153 1
			$printRequest = $field->getPrintRequest();
154 1
			$values = [];
155
156 1
			$label = strtolower( $printRequest->getLabel() );
157 1
			$dataValue = $field->getNextDataValue();
158
159 1
			if ( $dataValue === false ) {
160 1
				continue;
161
			}
162
163 1
			if ( $label === 'date' && $dataValue instanceof TimeValue ) {
164
				$item->set( 'year', $dataValue->getYear() );
165
				$item->set( 'month', $dataValue->getMonth() );
166 1
			} elseif ( $label === 'author' || $label === 'authors' ) {
167 1
				$values[] = $dataValue->getShortWikiText();
168
169 1
				while ( ( /* SMWDataValue */ $dataValue = $field->getNextDataValue() ) !== false ) {
170 1
					$values[] = $dataValue->getShortWikiText();
171
				}
172
173 1
				$item->set( 'author', $values );
174 1
			} elseif ( $label === 'editor' || $label === 'editors' ) {
175 1
				$values[] = $dataValue->getShortWikiText();
176
177 1
				while ( ( /* SMWDataValue */ $dataValue = $field->getNextDataValue() ) !== false ) {
178 1
					$values[] = $dataValue->getShortWikiText();
179
				}
180
181 1
				$item->set( 'editor', $values );
182
			} else {
183 1
				$item->set( $label, $dataValue->getShortWikiText() );
184
			}
185
		}
186
187 1
		return $item;
188
	}
189
190
}
191