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/AbstractNamed.php (1 issue)

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\AbstractNamed: 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
namespace Grafizzi\Graph;
24
25
use Pimple\Container;
26
27
abstract class AbstractNamed implements NamedInterface {
28
29
  public $fName = null;
30
31
  /**
32
   * A shortcut to the injected logger.
33
   *
34
   * @var \Psr\Log\LoggerInterface
35
   */
36
  public $logger;
37
38
  /**
39
   * @var \Pimple\Container
40
   */
41
  protected $dic;
42
43 71
  function __construct(Container $dic) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44 71
    $this->dic = $dic;
45 71
    $this->logger = &$dic['logger'];
46 71
  }
47
48
  /**
49
   * Will also handle numbers and booleans, and any object with a __toString().
50
   *
51
   * @param string $string
52
   *   The string to escape.
53
   * @param boolean $pseudoHtml
54
   *   Wrap GraphViz-style pseudo-HTML text.
55
   *
56
   * @return string
57
   */
58 51
  public static function escape($string, $pseudoHtml = false) {
59
    $keywords = array(
60 51
      'digraph',
61
      'edge',
62
      'graph',
63
      'node',
64
      'strict',
65
      'subgraph',
66
    );
67
68 51
    $wrapping = false;
69
70
    // 1. Handle keywords specifically, convert anything else to string.
71 51
    $s = trim(strtolower($string));
72 51
    if (in_array($s, $keywords)) {
73 4
      $wrapping = 'dquote';
74 4
      $s = $string;
75 50
    } elseif (!isset($string)) {
76
      $s = 'false';
77 50
    } elseif (is_bool($string)) {
78 2
      $s = $string ? 'true' : 'false';
79
    } else {
80 50
      $s = (string) $string;
81 50
      if (!self::validateId($s)) {
82 16
        $wrapping = 'dquote';
83
      }
84
    }
85
86
    // 2. Wrap requested pseudo-html if it contains at least one terminated element.
87 51
    if ($pseudoHtml && (strpos($s, '</') !== false || strpos($s, '/>') !== false)) {
88 3
      $wrapping = 'html';
89
    }
90
91
    // 3. Normalize quotes and new lines
92 51
    if ($wrapping != 'html') {
93 51
      $s = str_replace(array("\r\n", "\n", "\r", '"'),
94 51
                       array('\n',   '\n', '\n', '\"'), $s);
95
    }
96
97
    // 4. Wrap in double quotes if needed.
98 51
    switch ($wrapping) {
99 51
      case 'dquote':
100 18
        $s = '"' . $s . '"';
101 18
        break;
102
103 49
      case 'html':
104 3
        $s = "<$s>";
105 3
        break;
106
107
      default:
108
        // Do not wrap.
109
    }
110
111 51
    return $s;
112
  }
113
114
  /**
115
   * Helper for escape(). Validate non-quoted id.
116
   *
117
   * @see escape()
118
   *
119
   * @param string $id
120
   *
121
   * @return boolean
122
   */
123 50
  protected static function validateId($id) {
124 50
    $regex = '^([a-z_][a-z_0-9]*|-?(\.[0-9]+|[0-9]+(\.[0-9]*)?))$';
125 50
    $ret = preg_match("/$regex/i", $id) ? true : false;
126 50
    return $ret;
127
  }
128
129
  /**
130
   * @see NamedInterface::getBuildName()
131
   */
132 38
  public function getBuildName() {
133 38
    return $this->escape($this->getName());
134
  }
135
136
  /**
137
   * @see NamedInterface::getName()
138
   *
139
   * @throws AttributeNameException
140
   */
141 71
  public function getName() {
142 71
    if (!isset($this->fName)) {
143
      $message = 'Getting name for unnamed object.';
144
      $this->logger->error($message);
145
      throw new AttributeNameException($message);
146
    }
147 71
    return $this->fName;
148
  }
149
150
  /**
151
   * @see NamedInterface::setName()
152
   */
153 71
  public function setName($name) {
154 71
    $this->logger->debug($this->getType() . " attribute name set to $name.");
155 71
    $this->fName = $name;
156 71
  }
157
}
158