Issues (16)

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.

Twig/BootstrapIconExtension.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
 * This file is part of BraincraftedBootstrapBundle.
4
 * (c) 2012-2013 by Florian Eckerstorfer
5
 */
6
7
namespace Braincrafted\Bundle\BootstrapBundle\Twig;
8
9
use Twig_Extension;
10
use Twig_SimpleFilter;
11
use Twig_SimpleFunction;
12
13
/**
14
 * BootstrapIconExtension
15
 *
16
 * @package    BraincraftedBootstrapBundle
17
 * @subpackage Twig
18
 * @author     Florian Eckerstorfer <[email protected]>
19
 * @copyright  2012-2013 Florian Eckerstorfer
20
 * @license    http://opensource.org/licenses/MIT The MIT License
21
 * @link       http://bootstrap.braincrafted.com Bootstrap for Symfony2
22
 */
23
class BootstrapIconExtension extends Twig_Extension
24
{
25
    /**
26
     * @var string
27
     */
28
    private $iconPrefix;
29
30
    /**
31
     * @var string
32
     */
33
    private $iconTag;
34
35
    /**
36
     * @param string $iconPrefix
37
     * @param string $iconTag
38
     */
39
    public function __construct($iconPrefix, $iconTag = 'span')
40
    {
41
        $this->iconPrefix = $iconPrefix;
42
        $this->iconTag = $iconTag;
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    public function getFilters()
49
    {
50
        return array(
51
            new Twig_SimpleFilter(
52
                'parse_icons',
53
                array($this, 'parseIconsFilter'),
54
                array('pre_escape' => 'html', 'is_safe' => array('html'))
55
            )
56
        );
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function getFunctions()
63
    {
64
        return array(
65
            new Twig_SimpleFunction(
66
                'icon',
67
                array($this, 'iconFunction'),
68
                array('pre_escape' => 'html', 'is_safe' => array('html'))
69
            )
70
        );
71
    }
72
73
    /**
74
     * Parses the given string and replaces all occurrences of .icon-[name] with the corresponding icon.
75
     *
76
     * @param string $text The text to parse
77
     *
78
     * @return string The HTML code with the icons
79
     */
80
    public function parseIconsFilter($text)
81
    {
82
        $that = $this;
83
84
        return preg_replace_callback(
85
            '/\.([a-z]+)-([a-z0-9+-]+)/',
86
            function ($matches) use ($that) {
87
                return $that->iconFunction($matches[2], $matches[1]);
88
            },
89
            $text
90
        );
91
    }
92
93
    /**
94
     * Returns the HTML code for the given icon.
95
     *
96
     * @param string $icon The name of the icon
97
     * @param string $iconSet The icon-set name
98
     *
99
     * @return string The HTML code for the icon
100
     */
101
    public function iconFunction($icon, $iconSet = 'icon')
102
    {
103
        if ($iconSet == 'icon') $iconSet = $this->iconPrefix;
0 ignored issues
show
Please always use braces to surround the code block of IF statements.
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
104
        $icon = str_replace('+', ' '.$iconSet.'-', $icon);
105
106
        return sprintf('<%1$s class="%2$s %2$s-%3$s"></%1$s>', $this->iconTag, $iconSet, $icon);
107
    }
108
109
    /**
110
     * {@inheritDoc}
111
     */
112
    public function getName()
113
    {
114
        return 'braincrafted_bootstrap_icon';
115
    }
116
}
117