Issues (8)

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.

highcharts/HighchartsWidget.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
 * HighchartsWidget class file.
5
 *
6
 * @author Milo Schuman <[email protected]>
7
 * @link https://github.com/miloschuman/yii-highcharts/
8
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
9
 */
10
11
/**
12
 * HighchartsWidget encapsulates the {@link http://www.highcharts.com/ Highcharts}
13
 * charting library's Chart object.
14
 *
15
 * To use this widget, you may insert the following code in a view:
16
 * <pre>
17
 * $this->Widget('ext.highcharts.HighchartsWidget', array(
18
 *    'options'=>array(
19
 *       'title' => array('text' => 'Fruit Consumption'),
20
 *       'xAxis' => array(
21
 *          'categories' => array('Apples', 'Bananas', 'Oranges')
22
 *       ),
23
 *       'yAxis' => array(
24
 *          'title' => array('text' => 'Fruit eaten')
25
 *       ),
26
 *       'series' => array(
27
 *          array('name' => 'Jane', 'data' => array(1, 0, 4)),
28
 *          array('name' => 'John', 'data' => array(5, 7, 3))
29
 *       )
30
 *    )
31
 * ));
32
 * </pre>
33
 *
34
 * By configuring the {@link $options} property, you may specify the options
35
 * that need to be passed to the Highcharts JavaScript object. Please refer to
36
 * the demo gallery and documentation on the {@link http://www.highcharts.com/
37
 * Highcharts website} for possible options.
38
 *
39
 * Alternatively, you can use a valid JSON string in place of an associative
40
 * array to specify options:
41
 *
42
 * <pre>
43
 * $this->Widget('ext.highcharts.HighchartsWidget', array(
44
 *    'options'=>'{
45
 *       "title": { "text": "Fruit Consumption" },
46
 *       "xAxis": {
47
 *          "categories": ["Apples", "Bananas", "Oranges"]
48
 *       },
49
 *       "yAxis": {
50
 *          "title": { "text": "Fruit eaten" }
51
 *       },
52
 *       "series": [
53
 *          { "name": "Jane", "data": [1, 0, 4] },
54
 *          { "name": "John", "data": [5, 7,3] }
55
 *       ]
56
 *    }'
57
 * ));
58
 * </pre>
59
 *
60
 * Note: You must provide a valid JSON string (e.g. double quotes) when using
61
 * the second option. You can quickly validate your JSON string online using
62
 * {@link http://jsonlint.com/ JSONLint}.
63
 *
64
 * Note: You do not need to specify the <code>chart->renderTo</code> option as
65
 * is shown in many of the examples on the Highcharts website. This value is
66
 * automatically populated with the id of the widget's container element. If you
67
 * wish to use a different container, feel free to specify a custom value.
68
 */
69
class HighchartsWidget extends CWidget
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
70
{
71
    protected $_constr = 'Chart';
72
    protected $_baseScript = 'highcharts';
73
    public $options = array();
74
    public $htmlOptions = array();
75
    public $setupOptions = array();
76
    public $scripts = array();
77
    public $callback = false;
78
    public $scriptPosition = null;
79
80
    /**
81
     * Renders the widget.
82
     */
83
    public function run()
84
    {
85
        if (isset($this->htmlOptions['id'])) {
86
            $this->id = $this->htmlOptions['id'];
87
        } else {
88
            $this->htmlOptions['id'] = $this->getId();
89
        }
90
91
        echo CHtml::openTag('div', $this->htmlOptions);
92
        echo CHtml::closeTag('div');
93
94
        // check if options parameter is a json string
95
        if (is_string($this->options)) {
96
            if (!$this->options = CJSON::decode($this->options)) {
97
                throw new CException('The options parameter is not valid JSON.');
98
            }
99
        }
100
101
        // merge options with default values
102
        $defaultOptions = array('chart' => array('renderTo' => $this->id));
103
        $this->options = CMap::mergeArray($defaultOptions, $this->options);
104
        array_unshift($this->scripts, $this->_baseScript);
105
106
        $this->registerAssets();
107
    }
108
109
    /**
110
     * Publishes and registers the necessary script files.
111
     */
112
    protected function registerAssets()
113
    {
114
        $basePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
115
        $baseUrl = Yii::app()->getAssetManager()->publish($basePath, false, 1, YII_DEBUG);
116
117
        $cs = Yii::app()->clientScript;
118
        $cs->registerCoreScript('jquery');
119
120
        // register additional scripts
121
        $extension = YII_DEBUG ? '.src.js' : '.js';
122
        foreach ($this->scripts as $script) {
123
            $cs->registerScriptFile("{$baseUrl}/{$script}{$extension}", $this->scriptPosition);
124
        }
125
126
        // highcharts and highstock can't live on the same page
127
        if ($this->_baseScript === 'highstock') {
128
            $cs->scriptMap["highcharts{$extension}"] = "{$baseUrl}/highstock{$extension}";
129
        }
130
131
        // prepare and register JavaScript code block
132
        $jsOptions = CJavaScript::encode($this->options);
133
        $setupOptions = CJavaScript::encode($this->setupOptions);
134
        $js = "Highcharts.setOptions($setupOptions); var chart = new Highcharts.{$this->_constr}($jsOptions);";
135
        $key = __CLASS__ . '#' . $this->id;
136
        if (is_string($this->callback)) {
137
            $callbackScript = "function {$this->callback}(data) {{$js}}";
138
            $cs->registerScript($key, $callbackScript, CClientScript::POS_END);
139
        } else {
140
            $cs->registerScript($key, $js, CClientScript::POS_LOAD);
141
        }
142
    }
143
}
144