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/EdgeTest.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
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\EdgeTest: 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
/** @noinspection PhpIncludeInspection */
27
require 'vendor/autoload.php';
28
29
use Grafizzi\Graph\Attribute;
30
use Grafizzi\Graph\Edge;
31
use Grafizzi\Graph\Node;
32
33
/**
34
 * Edge test case.
35
 */
36
class EdgeTest extends BaseGraphTest {
37
38
  /**
39
   * @var Edge
40
   */
41
  private $Edge;
42
43
  /**
44
   * @var Attribute
45
   */
46
  private $Attribute;
47
48
  /**
49
   * Prepares the environment before running a test.
50
   */
51
  protected function setUp() : void {
52
    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...
53
    $src = new Node($this->dic, 'source');
54
    $dst = new Node($this->dic, 'destination');
55
    $this->Attribute = new Attribute($this->dic, 'label', 'Source to Destination');
56
    $this->Edge = new Edge($this->dic, $src, $dst);
57
    $this->Edge->setAttribute($this->Attribute);
58
    foreach (array($src, $dst, $this->Edge) as $child) {
59
      $this->Graph->addChild($child);
60
    }
61
  }
62
63
  /**
64
   * Cleans up the environment after running a test.
65
   */
66
  protected function tearDown() : void {
67
    $this->Edge = null;
68
    parent::tearDown();
69
  }
70
71
  /**
72
   * Tests Edge->__construct()
73
   */
74
  public function test__construct() {
75
    $this->assertEquals($this->Attribute, $this->Edge->getAttributeByName('label'),
76
      'Edge is correctly labeled');
77
  }
78
79
  /**
80
   * Tests Edge->build()
81
   *
82
   * @TODO test graph build
83
   */
84
  public function testBuild() {
85
    $dot = $this->Edge->build($this->Graph->getDirected());
86
    $this->assertEquals(<<<EOT
87
  source -> destination [ label="Source to Destination" ];
88
89
EOT
90
      , $dot, "Edge builds correctly");
91
  }
92
93
  /**
94
   * Common logic for the testBuild* test methods.
95
   *
96
   * @param string $expected
97
   *   The expected GraphViz output.
98
   * @param array $edges
99
   *
100
   * @internal param array $toSet An array of edges to add.*   An array of edges to add.
101
   */
102
  public function buildTestHelper($expected, array $edges) {
103
    $this->Edge->removeAttribute($this->Attribute);
104
    $toSet = array();
105
    foreach ($edges as $edge) {
106
      list($name, $value) = $edge;
107
      $toSet[] = new Attribute($this->dic, $name, $value);
108
    }
109
    $this->Edge->setAttributes($toSet);
110
    $actual = $this->Edge->build();
111
    $this->assertEquals($expected, $actual);
112
  }
113
114
  public function testBuildAttributesNormal() {
115
    $expected = <<<EOT
116
  source -> destination [ foo=bar, baz=quux ];
117
118
EOT;
119
    $this->buildTestHelper($expected, array(
120
      array('foo', 'bar'),
121
      array('baz', 'quux'),
122
    ));
123
  }
124
125
  // Attribute list with empty title in middle on edge bound to root graph.
126 View Code Duplication
  public function testBuildAttributesEmptyMiddle() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
127
    $expected = <<<EOT
128
  source -> destination [ foo=bar, baz=quux ];
129
130
EOT;
131
132
    $this->buildTestHelper($expected, array(
133
      array('foo', 'bar'),
134
      array('title', ''),
135
      array('baz', 'quux'),
136
    ));
137
  }
138
139
  // Attribute list with empty title as single attribute on edge bound to root graph.
140
  public function testBuildAttributesOnlyEmpty() {
141
    $expected = <<<EOT
142
  source -> destination;
143
144
EOT;
145
146
    $this->buildTestHelper($expected, array(
147
      array('title', ''),
148
    ));
149
  }
150
151
  // Attribute list with empty title as last attribute on edge bound to root graph.
152 View Code Duplication
  public function testBuildAttributesEmptyLast() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
153
    $expected = <<<EOT
154
  source -> destination [ foo=bar, baz=quux ];
155
156
EOT;
157
158
    $this->buildTestHelper($expected, array(
159
      array('foo', 'bar'),
160
      array('baz', 'quux'),
161
      array('title', ''),
162
    ));
163
  }
164
165
  /**
166
   * Tests Edge::getAllowedChildTypes()
167
   */
168
  public function testGetAllowedChildTypes() {
169
    $this->assertEmpty(Edge::getAllowedChildTypes());
170
  }
171
172
  /**
173
   * Tests Edge::getType()
174
   */
175
  public function testGetType() {
176
    $this->assertEquals('edge', $this->Edge->getType());
177
  }
178
}
179
180