Issues (19)

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.

tests/phpunit/Unit/SemanticTasksMailerTest.php (3 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
namespace ST\Tests;
3
4
use MediaWiki\Diff\ComplexityException;
5
use MWException;
6
use ST\Assignees;
7
use ST\SemanticTasksMailer;
8
use ST\UserMailer;
9
use TextContent;
10
use Title;
11
use User;
12
use WikiPage;
13
14
/**
15
 * @covers SemanticTasksMailer
16
 * @group semantic-tasks
17
 *
18
 * @license GNU GPL v2+
19
 * @since 3.0
20
 */
21
class SemanticTasksMailerTest extends \MediaWikiTestCase {
22
23
	/**
24
	 * Only needed for MW 1.31
25
	 */
26
	public function run( \PHPUnit_Framework_TestResult $result = null ) {
27
		// MW 1.31
28
		$this->setCliArg( 'use-normal-tables', true );
29
		parent::run( $result );
30
	}
31
32
	protected function overrideMwServices( $configOverrides = null, array $services = [] ) {
33
		/**
34
		 * `MediaWikiTestCase` isolates the result with  `MediaWikiTestResult` which
35
		 * ecapsultes the commandline args and since we need to use "real" tables
36
		 * as part of "use-normal-tables" we otherwise end-up with the `CloneDatabase`
37
		 * to create TEMPORARY  TABLE by default as in:
38
		 *
39
		 * CREATE TEMPORARY  TABLE `unittest_smw_di_blob` (LIKE `smw_di_blob`) and
40
		 * because of the TEMPORARY TABLE, MySQL (not MariaDB) will complain
41
		 * about things like:
42
		 *
43
		 * SELECT p.smw_title AS prop, o_id AS id0, o0.smw_title AS v0, o0.smw_namespace
44
		 * AS v1, o0.smw_iw AS v2, o0.smw_sortkey AS v3, o0.smw_subobject AS v4,
45
		 * o0.smw_sort AS v5 FROM `unittest_smw_di_wikipage` INNER JOIN
46
		 * `unittest_smw_object_ids` AS p ON p_id=p.smw_id INNER JOIN
47
		 * `unittest_smw_object_ids` AS o0 ON o_id=o0.smw_id WHERE (s_id='29') AND
48
		 * (p.smw_iw!=':smw') AND (p.smw_iw!=':smw-delete')
49
		 *
50
		 * Function: SMW\SQLStore\EntityStore\SemanticDataLookup::fetchSemanticDataFromTable
51
		 * Error: 1137 Can't reopen table: 'p' ()
52
		 *
53
		 * The reason is that `unittest_smw_object_ids` was created as TEMPORARY TABLE
54
		 * and p is referencing to a TEMPORARY TABLE as well which isn't allowed in
55
		 * MySQL.
56
		 *
57
		 * "You cannot refer to a TEMPORARY table more than once in the same query" [0]
58
		 *
59
		 * [0] https://dev.mysql.com/doc/refman/8.0/en/temporary-table-problems.html
60
		 */
61
		// MW 1.32+
62
		$this->setCliArg( 'use-normal-tables', true );
63
		parent::overrideMwServices( $configOverrides, $services );
64
	}
65
66
	/** @todo: expand tests */
67
	/**
68
	 * @covers SemanticTasksMailer::mailNotification
69
	 * @throws ComplexityException
70
	 * @throws MWException
71
	 */
72
	public function testMailNotification() {
73
		$userMailerMock = $this->createMock( UserMailer::class );
74
75
		$assignees = [ 'someone' ];
76
		$text = '';
77
		$title = new Title();
78
		$user = new \User();
79
		$status = 0; //ST_NEWTASK
80
81
		$userMailerMock->expects( $this->once() )
82
			->method( 'send' )
83
			->with( $assignees, $this->anything(), $this->anything(), $this->anything(), $this->anything() )
84
			->willReturn( \Status::newGood() );
85
86
		SemanticTasksMailer::setUserMailer( $userMailerMock );
87
		SemanticTasksMailer::mailNotification( $assignees, $text, $title, $user, $status );
88
	}
89
90
	/**
91
	 * @covers SemanticTasksMailer::generateDiffBodyTxt
92
	 * @throws ComplexityException
93
	 * @throws MWException
94
	 */
95
	public function testGenerateDiffBodyTxt() {
96
		$namespace = $this->getDefaultWikitextNS();
97
		$title = Title::newFromText( 'Kitten', $namespace );
98
99
		$context = new \RequestContext();
100
		$context->setTitle( $title );
101
102
		$page = WikiPage::factory( $title );
103
		$strings = [ "it is a kitten", "two kittens", "three kittens", "four kittens" ];
104
		$revisions = [];
105
		foreach ( $strings as $string ) {
106
			$content = \ContentHandler::makeContent( $string, $title );
107
			$page->doEditContent( $content, 'edit page' );
108
			$revisions[] = $page->getLatest();
109
		}
110
111
		$returnText = SemanticTasksMailer::generateDiffBodyTxt( $title, $context );
112
		$this->assertNotEquals( '', $returnText, 'Diff should not be empty string.' );
113
	}
114
115
	/**
116
	 * @covers Assignees::saveAssignees
117
	 */
118
	public function testSaveAssignees() {
119
		$title = new Title();
120
		$article = new WikiPage( $title );
121
		$assignees = new Assignees();
122
		$assignees->saveAssignees( $article );
123
	}
124
125
	/** @todo: add more tests or asserts */
126
	/**
127
	 * @covers SemanticTasksMailer::mailAssigneesUpdatedTask
128
	 * @throws MWException
129
	 */
130
	public function testMailAssigneesUpdatedTaskTrueOnMinorEdit() {
131
		$assignees = new Assignees();
132
		$title = new Title();
133
		$article = new WikiPage($title);
134
		$current_user = new User();
135
		$text = new TextContent('test TextContent');
136
		$summary = ''; // unused
137
		$minoredit = true; // or true;
138
		$watchthis = null; // unused
139
		$sectionanchor = null; // unused
140
		$flags = EDIT_NEW; // or other..
141
		$revision = null;
142
		try {
143
			$returnValue = SemanticTasksMailer::mailAssigneesUpdatedTask( $assignees, $article, $current_user, $text,
144
				$summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision );
145
		} catch ( MWException $e ) {
0 ignored issues
show
The class MWException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
146
147
		} catch ( ComplexityException $e ) {
0 ignored issues
show
The class MediaWiki\Diff\ComplexityException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
148
149
		}
150
151
		$this->assertTrue($returnValue);
152
	}
153
154
	public function testGetAssignedUsersFromParserOutput() {
155
		$namespace = $this->getDefaultWikitextNS();
156
		$title = Title::newFromText( 'Some Random Page', $namespace );
157
		$article = WikiPage::factory( $title );
158
		$content = \ContentHandler::makeContent( 'this is some edit', $title );
159
		$article->doEditContent( $content, 'edit page' );
160
		$revision = $article->getRevision();
161
		$current_user = new User();
0 ignored issues
show
$current_user is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
162
		$assignees = new Assignees();
163
		$assignendUsers = $assignees->getCurrentAssignees( $article, $revision );
164
165
		$this->assertEmpty( $assignendUsers );
166
	}
167
168
	/** @todo: fix covers annotation and remove this. */
169
	public function testValidCovers() {
170
		$this->assertTrue( true );
171
	}
172
}
173