Issues (1377)

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.

API/Chart/HighchartsExporting.php (6 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
 * This file is part of the highcharts-bundle package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\HighchartsBundle\API\Chart;
13
14
use JsonSerializable;
15
use WBW\Library\Core\Utility\Argument\ArrayUtility;
16
17
/**
18
 * Highcharts exporting.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\HighchartsBundle\API\Chart
22
 * @version 5.0.14
23
 * @final
24
 */
25
final class HighchartsExporting implements JsonSerializable {
26
27
    /**
28
     * Allow HTML.
29
     *
30
     * @var boolean
31
     * @since 4.1.8
32
     */
33
    private $allowHTML = false;
34
35
    /**
36
     * Buttons.
37
     *
38
     * @var \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons
39
     */
40
    private $buttons;
41
42
    /**
43
     * Chart options.
44
     *
45
     * @var array
46
     */
47
    private $chartOptions;
48
49
    /**
50
     * Enabled.
51
     *
52
     * @var boolean
53
     * @since 2.0
54
     */
55
    private $enabled = true;
56
57
    /**
58
     * Error.
59
     *
60
     * @var string
61
     * @since 5.0.0
62
     */
63
    private $error;
64
65
    /**
66
     * Fallback to export server.
67
     *
68
     * @var boolean
69
     * @since 4.1.8
70
     */
71
    private $fallbackToExportServer = true;
72
73
    /**
74
     * Filename.
75
     *
76
     * @var string
77
     * @since 2.0
78
     */
79
    private $filename = "chart";
80
81
    /**
82
     * Form attributes.
83
     *
84
     * @var array
85
     * @since 3.0.8
86
     */
87
    private $formAttributes;
88
89
    /**
90
     * Lib URL.
91
     *
92
     * @var string
93
     * @since 5.0.0
94
     */
95
    private $libURL = "https://code.highcharts.com/{version}/lib";
96
97
    /**
98
     * Menu item definitions.
99
     *
100
     * @var array
101
     * @since 5.0.13
102
     */
103
    private $menuItemDefinitions;
104
105
    /**
106
     * Print max width.
107
     *
108
     * @var integer
109
     * @since 4.2.5
110
     */
111
    private $printMaxWidth = 780;
112
113
    /**
114
     * Scale.
115
     *
116
     * @var integer
117
     * @since 3.0
118
     */
119
    private $scale = 2;
120
121
    /**
122
     * Source height.
123
     *
124
     * @var integer
125
     * @since 3.0
126
     */
127
    private $sourceHeight;
128
129
    /**
130
     * Source width.
131
     *
132
     * @var integer
133
     * @since 3.0
134
     */
135
    private $sourceWidth;
136
137
    /**
138
     * Type.
139
     *
140
     * @var string
141
     * @since 2.0
142
     */
143
    private $type = "image/png";
144
145
    /**
146
     * Url.
147
     *
148
     * @var string
149
     * @since 2.0
150
     */
151
    private $url = "https://export.highcharts.com";
152
153
    /**
154
     * Width.
155
     *
156
     * @var integer
157
     * @since 2.0
158
     */
159
    private $width;
160
161
    /**
162
     * Constructor.
163
     *
164
     * @param boolean $ignoreDefaultValues Ignore the default values.
165
     */
166
    public function __construct($ignoreDefaultValues = true) {
167
        if (true === $ignoreDefaultValues) {
168
            $this->clear();
169
        }
170
    }
171
172
    /**
173
     * Clear.
174
     *
175
     * @return void
176
     */
177
    public function clear() {
178
179
        // Clear the allow HTML.
180
        $this->allowHTML = null;
181
182
        // Clear the buttons.
183
        if (null !== $this->buttons) {
184
            $this->buttons->clear();
185
        }
186
187
        // Clear the chart options.
188
        $this->chartOptions = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $chartOptions.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
189
190
        // Clear the enabled.
191
        $this->enabled = null;
192
193
        // Clear the error.
194
        $this->error = null;
195
196
        // Clear the fallback to export server.
197
        $this->fallbackToExportServer = null;
198
199
        // Clear the filename.
200
        $this->filename = null;
201
202
        // Clear the form attributes.
203
        $this->formAttributes = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $formAttributes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
204
205
        // Clear the lib URL.
206
        $this->libURL = null;
207
208
        // Clear the menu item definitions.
209
        $this->menuItemDefinitions = null;
0 ignored issues
show
Documentation Bug introduced by
It seems like null of type null is incompatible with the declared type array of property $menuItemDefinitions.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
210
211
        // Clear the print max width.
212
        $this->printMaxWidth = null;
213
214
        // Clear the scale.
215
        $this->scale = null;
216
217
        // Clear the source height.
218
        $this->sourceHeight = null;
219
220
        // Clear the source width.
221
        $this->sourceWidth = null;
222
223
        // Clear the type.
224
        $this->type = null;
225
226
        // Clear the url.
227
        $this->url = null;
228
229
        // Clear the width.
230
        $this->width = null;
231
    }
232
233
    /**
234
     * Get the allow HTML.
235
     *
236
     * @return boolean Returns the allow HTML.
237
     */
238
    public function getAllowHTML() {
239
        return $this->allowHTML;
240
    }
241
242
    /**
243
     * Get the buttons.
244
     *
245
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons Returns the buttons.
246
     */
247
    public function getButtons() {
248
        return $this->buttons;
249
    }
250
251
    /**
252
     * Get the chart options.
253
     *
254
     * @return array Returns the chart options.
255
     */
256
    public function getChartOptions() {
257
        return $this->chartOptions;
258
    }
259
260
    /**
261
     * Get the enabled.
262
     *
263
     * @return boolean Returns the enabled.
264
     */
265
    public function getEnabled() {
266
        return $this->enabled;
267
    }
268
269
    /**
270
     * Get the error.
271
     *
272
     * @return string Returns the error.
273
     */
274
    public function getError() {
275
        return $this->error;
276
    }
277
278
    /**
279
     * Get the fallback to export server.
280
     *
281
     * @return boolean Returns the fallback to export server.
282
     */
283
    public function getFallbackToExportServer() {
284
        return $this->fallbackToExportServer;
285
    }
286
287
    /**
288
     * Get the filename.
289
     *
290
     * @return string Returns the filename.
291
     */
292
    public function getFilename() {
293
        return $this->filename;
294
    }
295
296
    /**
297
     * Get the form attributes.
298
     *
299
     * @return array Returns the form attributes.
300
     */
301
    public function getFormAttributes() {
302
        return $this->formAttributes;
303
    }
304
305
    /**
306
     * Get the lib URL.
307
     *
308
     * @return string Returns the lib URL.
309
     */
310
    public function getLibURL() {
311
        return $this->libURL;
312
    }
313
314
    /**
315
     * Get the menu item definitions.
316
     *
317
     * @return array Returns the menu item definitions.
318
     */
319
    public function getMenuItemDefinitions() {
320
        return $this->menuItemDefinitions;
321
    }
322
323
    /**
324
     * Get the print max width.
325
     *
326
     * @return integer Returns the print max width.
327
     */
328
    public function getPrintMaxWidth() {
329
        return $this->printMaxWidth;
330
    }
331
332
    /**
333
     * Get the scale.
334
     *
335
     * @return integer Returns the scale.
336
     */
337
    public function getScale() {
338
        return $this->scale;
339
    }
340
341
    /**
342
     * Get the source height.
343
     *
344
     * @return integer Returns the source height.
345
     */
346
    public function getSourceHeight() {
347
        return $this->sourceHeight;
348
    }
349
350
    /**
351
     * Get the source width.
352
     *
353
     * @return integer Returns the source width.
354
     */
355
    public function getSourceWidth() {
356
        return $this->sourceWidth;
357
    }
358
359
    /**
360
     * Get the type.
361
     *
362
     * @return string Returns the type.
363
     */
364
    public function getType() {
365
        return $this->type;
366
    }
367
368
    /**
369
     * Get the url.
370
     *
371
     * @return string Returns the url.
372
     */
373
    public function getUrl() {
374
        return $this->url;
375
    }
376
377
    /**
378
     * Get the width.
379
     *
380
     * @return integer Returns the width.
381
     */
382
    public function getWidth() {
383
        return $this->width;
384
    }
385
386
    /**
387
     * Serialize this instance.
388
     *
389
     * @return array Returns an array representing this instance.
390
     */
391
    public function jsonSerialize() {
392
        return $this->toArray();
393
    }
394
395
    /**
396
     * Create a new buttons.
397
     *
398
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons Returns the buttons.
399
     */
400
    public function newButtons() {
401
        $this->buttons = new \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons();
402
        return $this->buttons;
403
    }
404
405
    /**
406
     * Set the allow HTML.
407
     *
408
     * @param boolean $allowHTML The allow HTML.
409
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
410
     */
411
    public function setAllowHTML($allowHTML) {
412
        $this->allowHTML = $allowHTML;
413
        return $this;
414
    }
415
416
    /**
417
     * Set the buttons.
418
     *
419
     * @param \WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons $buttons The buttons.
420
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
421
     */
422
    public function setButtons(\WBW\Bundle\HighchartsBundle\API\Chart\Exporting\HighchartsButtons $buttons = null) {
423
        $this->buttons = $buttons;
424
        return $this;
425
    }
426
427
    /**
428
     * Set the chart options.
429
     *
430
     * @param array $chartOptions The chart options.
431
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
432
     */
433
    public function setChartOptions(array $chartOptions = null) {
434
        $this->chartOptions = $chartOptions;
0 ignored issues
show
Documentation Bug introduced by
It seems like $chartOptions can be null. However, the property $chartOptions is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
435
        return $this;
436
    }
437
438
    /**
439
     * Set the enabled.
440
     *
441
     * @param boolean $enabled The enabled.
442
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
443
     */
444
    public function setEnabled($enabled) {
445
        $this->enabled = $enabled;
446
        return $this;
447
    }
448
449
    /**
450
     * Set the error.
451
     *
452
     * @param string $error The error.
453
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
454
     */
455
    public function setError($error) {
456
        $this->error = $error;
457
        return $this;
458
    }
459
460
    /**
461
     * Set the fallback to export server.
462
     *
463
     * @param boolean $fallbackToExportServer The fallback to export server.
464
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
465
     */
466
    public function setFallbackToExportServer($fallbackToExportServer) {
467
        $this->fallbackToExportServer = $fallbackToExportServer;
468
        return $this;
469
    }
470
471
    /**
472
     * Set the filename.
473
     *
474
     * @param string $filename The filename.
475
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
476
     */
477
    public function setFilename($filename) {
478
        $this->filename = $filename;
479
        return $this;
480
    }
481
482
    /**
483
     * Set the form attributes.
484
     *
485
     * @param array $formAttributes The form attributes.
486
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
487
     */
488
    public function setFormAttributes(array $formAttributes = null) {
489
        $this->formAttributes = $formAttributes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $formAttributes can be null. However, the property $formAttributes is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
490
        return $this;
491
    }
492
493
    /**
494
     * Set the lib URL.
495
     *
496
     * @param string $libURL The lib URL.
497
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
498
     */
499
    public function setLibURL($libURL) {
500
        $this->libURL = $libURL;
501
        return $this;
502
    }
503
504
    /**
505
     * Set the menu item definitions.
506
     *
507
     * @param array $menuItemDefinitions The menu item definitions.
508
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
509
     */
510
    public function setMenuItemDefinitions(array $menuItemDefinitions = null) {
511
        $this->menuItemDefinitions = $menuItemDefinitions;
0 ignored issues
show
Documentation Bug introduced by
It seems like $menuItemDefinitions can be null. However, the property $menuItemDefinitions is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
512
        return $this;
513
    }
514
515
    /**
516
     * Set the print max width.
517
     *
518
     * @param integer $printMaxWidth The print max width.
519
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
520
     */
521
    public function setPrintMaxWidth($printMaxWidth) {
522
        $this->printMaxWidth = $printMaxWidth;
523
        return $this;
524
    }
525
526
    /**
527
     * Set the scale.
528
     *
529
     * @param integer $scale The scale.
530
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
531
     */
532
    public function setScale($scale) {
533
        $this->scale = $scale;
534
        return $this;
535
    }
536
537
    /**
538
     * Set the source height.
539
     *
540
     * @param integer $sourceHeight The source height.
541
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
542
     */
543
    public function setSourceHeight($sourceHeight) {
544
        $this->sourceHeight = $sourceHeight;
545
        return $this;
546
    }
547
548
    /**
549
     * Set the source width.
550
     *
551
     * @param integer $sourceWidth The source width.
552
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
553
     */
554
    public function setSourceWidth($sourceWidth) {
555
        $this->sourceWidth = $sourceWidth;
556
        return $this;
557
    }
558
559
    /**
560
     * Set the type.
561
     *
562
     * @param string $type The type.
563
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
564
     */
565
    public function setType($type) {
566
        switch ($type) {
567
            case "application/pdf":
568
            case "image/jpeg":
569
            case "image/png":
570
            case "image/svg+xml":
571
            $this->type = $type;
572
            break;
573
        }
574
        return $this;
575
    }
576
577
    /**
578
     * Set the url.
579
     *
580
     * @param string $url The url.
581
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
582
     */
583
    public function setUrl($url) {
584
        $this->url = $url;
585
        return $this;
586
    }
587
588
    /**
589
     * Set the width.
590
     *
591
     * @param integer $width The width.
592
     * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsExporting Returns the highcharts exporting.
593
     */
594
    public function setWidth($width) {
595
        $this->width = $width;
596
        return $this;
597
    }
598
599
    /**
600
     * Convert into an array representing this instance.
601
     *
602
     * @return array Returns an array representing this instance.
603
     */
604
    public function toArray() {
605
606
        // Initialize the output.
607
        $output = [];
608
609
        // Set the allow HTML.
610
        ArrayUtility::set($output, "allowHTML", $this->allowHTML, [null]);
611
612
        // Set the buttons.
613
        if (null !== $this->buttons) {
614
            ArrayUtility::set($output, "buttons", $this->buttons->toArray(), []);
615
        }
616
617
        // Set the chart options.
618
        ArrayUtility::set($output, "chartOptions", $this->chartOptions, [null]);
619
620
        // Set the enabled.
621
        ArrayUtility::set($output, "enabled", $this->enabled, [null]);
622
623
        // Set the error.
624
        ArrayUtility::set($output, "error", $this->error, [null]);
625
626
        // Set the fallback to export server.
627
        ArrayUtility::set($output, "fallbackToExportServer", $this->fallbackToExportServer, [null]);
628
629
        // Set the filename.
630
        ArrayUtility::set($output, "filename", $this->filename, [null]);
631
632
        // Set the form attributes.
633
        ArrayUtility::set($output, "formAttributes", $this->formAttributes, [null]);
634
635
        // Set the lib URL.
636
        ArrayUtility::set($output, "libURL", $this->libURL, [null]);
637
638
        // Set the menu item definitions.
639
        ArrayUtility::set($output, "menuItemDefinitions", $this->menuItemDefinitions, [null]);
640
641
        // Set the print max width.
642
        ArrayUtility::set($output, "printMaxWidth", $this->printMaxWidth, [null]);
643
644
        // Set the scale.
645
        ArrayUtility::set($output, "scale", $this->scale, [null]);
646
647
        // Set the source height.
648
        ArrayUtility::set($output, "sourceHeight", $this->sourceHeight, [null]);
649
650
        // Set the source width.
651
        ArrayUtility::set($output, "sourceWidth", $this->sourceWidth, [null]);
652
653
        // Set the type.
654
        ArrayUtility::set($output, "type", $this->type, [null]);
655
656
        // Set the url.
657
        ArrayUtility::set($output, "url", $this->url, [null]);
658
659
        // Set the width.
660
        ArrayUtility::set($output, "width", $this->width, [null]);
661
662
        // Return the output.
663
        return $output;
664
    }
665
666
}
667