Issues (57)

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.

Grafizzi/Graph/Tests/RendererTest.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
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\RendererTest: a component of the Grafizzi library.
6
 *
7
 * (c) 2012 Frédéric G. MARAND <[email protected]>
8
 *
9
 * Grafizzi is free software: you can redistribute it and/or modify it under the
10
 * terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * Grafizzi is distributed in the hope that it will be useful, but WITHOUT ANY
15
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
 * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with Grafizzi, in the COPYING.LESSER.txt file.  If not, see
21
 * <http://www.gnu.org/licenses/>
22
 */
23
24
namespace Grafizzi\Graph\Tests;
25
26
require 'vendor/autoload.php';
27
28
use Grafizzi\Graph\Renderer;
29
use \ErrorException;
30
31
/**
32
 * Renderer test case.
33
 *
34
 * Note: at least in PHP3.7, when passing, expectOutputString is not
35
 * included in the assertions count, but it is included when failing.
36
 */
37
class RendererTest extends BaseGraphTest {
38
39
  const ERASABLE = 'input should be overwritten';
40
41
  /**
42
   *
43
   * @var Renderer
44
   */
45
  private $renderer;
46
47
  /**
48
   * Prepares the environment before running a test.
49
   */
50
  protected function setUp() : void {
51
    parent::setUpExtended();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setUpExtended() instead of setUp()). Are you sure this is correct? If so, you might want to change this to $this->setUpExtended().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
52
    $this->renderer = new Renderer($this->dic);
53
    $this->renderer->pipe = $this->Graph->build();
54
  }
55
56
  /**
57
   * Cleans up the environment after running a test.
58
   */
59
  protected function tearDown() : void {
60
    $this->renderer = null;
61
    parent::tearDown();
62
  }
63
64
  /**
65
   * Tests Renderer::getFormats()
66
   */
67
  public function testGetFormats() {
68
    $dic = $this->dic;
69
    $dic['use_exceptions'] = false;
70
    $formats = Renderer::getFormats($dic);
71
    $this->assertTrue(is_array($formats), 'Renderer::getFormats() returns an array when exceptions are not used.');
72
73
    $dic['use_exceptions'] = true;
74
    try {
75
      $formats = Renderer::getFormats($dic);
76
      $this->assertTrue(is_array($formats) && !empty($formats), 'Renderer::getFormats() returns a non-empty array when exceptions are used.');
77
    }
78
    catch (ErrorException $e) {
0 ignored issues
show
The class ErrorException 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...
79
      $this->fail('Renderer::getFormats() could not find dot and threw an ErrorException.');
80
    }
81
  }
82
83
  /**
84
   * Test use of magic __call() with non existent filter.
85
   *
86
   * - must throw DomainException
87
   * - must not overwrite source data
88
   */
89
  public function test__call() {
90
    $expected = $out = 'Some data';
91
    try {
92
      $out = call_user_func(array($this->renderer, 'nonexistent'));
93
    }
94
    catch (\DomainException $e) {
95
      $this->assertInstanceOf('\\DomainException', $e, 'Rendering non existent filter throws DomainException');
96
    }
97
    $this->assertEquals($expected, $out, 'Output is not overwritten by non existent filter.');
98
  }
99
100
  /**
101
   * Tests rendering with a single filter.
102
   */
103
  public function testRenderOneFilter() {
104
    // Callback can be a closure.
105
    $callback = function ($x) {
106
      return strrev($x);
107
    };
108
109
    // The value of this string should be overwritten by the filter.
110
    $output = self::ERASABLE;
111
112
    $expected = $callback($this->renderer->pipe);
113
114
    // Invoke filter via renderer, overwriting output and pipe.
115
    call_user_func(array($this->renderer, 'string'), array(
116
      'out' => &$output,
117
      'callback' => $callback,
118
    ));
119
120
    $pipe = $this->renderer->pipe;
121
    $this->assertIsString($pipe, "String filter returns string output");
122
    $this->assertEquals($expected, $this->renderer->pipe, "Filter with closure works on renderer pipe.");
123
124
    // No error output.
125
    $this->expectOutputString("");
126
  }
127
128
  /**
129
   * Test the fluent filter interface.
130
   */
131
  public function testRenderChainedFilters() {
132
    $callback = 'strrev';
133
134
    // The value of this string should be overwritten by the filter.
135
    $output1 = $output2 = $output3 = self::ERASABLE;
136
137
    $input = $this->renderer->pipe;
138
    $step1 = call_user_func(array($this->renderer, 'string'), array(
139
      'out' => &$output1,
140
      'callback' => $callback,
141
    ));
142
143
    $r = call_user_func(array($step1, 'string'), array(
144
      'out' => &$output2,
145
      'callback' => $callback,
146
    ));
147
148
    $this->assertEquals($input, $this->renderer->pipe, "Chained filters with strrev work.");
149
150
    // Test a filter chain: string, then sink.
151
    $pipe_input = $this->renderer->pipe;
152
153
    $r->string(array(
154
      'out' => &$output3,
155
      'callback' => $callback,
156
    ))->sink();
157
158
    $this->assertEquals($callback($pipe_input), $output3, "String filter updates argument.");
159
    $pipe = $this->renderer->pipe;
160
    $this->assertEmpty($pipe, 'Sink filter drops content from stdout.');
161
162
    // No error output from either filter.
163
    $this->expectOutputString("");
164
  }
165
}
166
167