Issues (36)

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.

phpunit/Unit/ByHttpRequest/QueryResultTest.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
namespace SEQL\ByHttpRequest\Tests;
4
5
use SEQL\ByHttpRequest\QueryResult;
6
use SMW\DIWikiPage;
7
8
/**
9
 * @covers \SEQL\ByHttpRequest\QueryResult
10
 * @group semantic-external-query-lookup
11
 *
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class QueryResultTest extends \PHPUnit_Framework_TestCase {
18
19
	private $store;
20
21
	protected function setUp() {
22
23
		$this->store = $this->getMockBuilder( '\SMW\Store' )
24
			->disableOriginalConstructor()
25
			->getMockForAbstractClass();
26
	}
27
28
	public function testCanConstruct() {
29
30
		$query = $this->getMockBuilder( '\SMWQuery' )
31
			->disableOriginalConstructor()
32
			->getMock();
33
34
		$printRequests = array();
35
		$results = array();
36
37
		$this->assertInstanceOf(
38
			'\SEQL\ByHttpRequest\QueryResult',
39
			new QueryResult( $printRequests, $query, $results, $this->store, false )
40
		);
41
	}
42
43
	public function testGetNext() {
44
45
		$jsonResponseParser = $this->getMockBuilder( '\SEQL\ByHttpRequest\JsonResponseParser' )
46
			->disableOriginalConstructor()
47
			->getMock();
48
49
		$query = $this->getMockBuilder( '\SMWQuery' )
50
			->disableOriginalConstructor()
51
			->getMock();
52
53
		$printRequest = $this->getMockBuilder( '\SMW\Query\PrintRequest' )
54
			->disableOriginalConstructor()
55
			->getMock();
56
57
		$printRequests = array(
58
			$printRequest
59
		);
60
61
		$results = array(
62
			new DIWikiPage( 'Foo', NS_MAIN )
63
		);
64
65
		$instance = new QueryResult( $printRequests, $query, $results, $this->store, false );
66
		$instance->setJsonResponseParser( $jsonResponseParser );
67
68
		foreach ( $instance->getNext() as $result ) {
0 ignored issues
show
The expression $instance->getNext() of type false|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
69
			$this->assertInstanceOf(
70
				'\SEQL\ByHttpRequest\CannedResultArray',
71
				$result
72
			);
73
		}
74
	}
75
76
	public function testToArray() {
77
78
		$expected = array(
79
			'Foo'
80
		);
81
82
		$query = $this->getMockBuilder( '\SMWQuery' )
83
			->disableOriginalConstructor()
84
			->getMock();
85
86
		$printRequest = $this->getMockBuilder( '\SMW\Query\PrintRequest' )
0 ignored issues
show
$printRequest 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...
87
			->disableOriginalConstructor()
88
			->getMock();
89
90
		$jsonResponseParser = $this->getMockBuilder( '\SEQL\ByHttpRequest\JsonResponseParser' )
91
			->disableOriginalConstructor()
92
			->getMock();
93
94
		$jsonResponseParser->expects( $this->exactly( 2 ) )
95
			->method( 'getRawResponseResult' )
96
			->will( $this->returnValue( $expected ) );
97
98
		$printRequests = array();
99
		$results = array();
100
101
		$instance = new QueryResult( $printRequests, $query, $results, $this->store, false );
102
		$instance->setJsonResponseParser( $jsonResponseParser );
103
104
		$this->assertEquals(
105
			$expected,
106
			$instance->toArray()
107
		);
108
109
		$this->assertEquals(
110
			$expected,
111
			$instance->serializeToArray()
112
		);
113
	}
114
115
	public function testGetLink() {
116
117
		$printRequest = $this->getMockBuilder( '\SMW\Query\PrintRequest' )
118
			->disableOriginalConstructor()
119
			->getMock();
120
121
		$printRequest->expects( $this->once() )
122
			->method( 'getSerialisation' )
123
			->will( $this->returnValue( '?ABC' ) );
124
125
		$query = $this->getMockBuilder( '\SMWQuery' )
126
			->disableOriginalConstructor()
127
			->getMock();
128
129
		$query->expects( $this->any() )
130
			->method( 'getExtraPrintouts' )
131
			->will( $this->returnValue( array( $printRequest ) ) );
132
133
		$printRequests = array();
134
		$results = array();
135
136
		$instance = new QueryResult( $printRequests, $query, $results, $this->store, false );
137
		$instance->setRemoteTargetUrl( 'http://example.org:8080' );
138
139
		$this->assertInstanceOf(
140
			'\SMWInfolink',
141
			$instance->getLink()
142
		);
143
	}
144
145
}
146