Issues (3)

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.

src/Model.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
 * Opine\PubSubBuild
4
 *
5
 * Copyright (c)2013, 2014 Ryan Mahoney, https://github.com/Opine-Org <[email protected]>
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated documentation files (the "Software"), to deal
9
 * in the Software without restriction, including without limitation the rights
10
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 * copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in
15
 * all copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
 * THE SOFTWARE.
24
 */
25
namespace Opine\PubSub;
26
27
use Exception;
28
use Symfony\Component\Yaml\Yaml;
29
30
class Model
31
{
32
    private $root;
33
    private $bundleModel;
34
35
    public function __construct($root, $bundleModel)
36
    {
37
        $this->root = $root;
38
        $this->bundleModel = $bundleModel;
39
        $this->cacheFile = $this->root.'/../var/cache/topics.json';
0 ignored issues
show
The property cacheFile does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
    }
41
42
    public function readDiskCache()
43
    {
44
        $topics = [];
0 ignored issues
show
$topics is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
45
        if (!file_exists($this->cacheFile)) {
46
            return [];
47
        }
48
        $topics = json_decode(file_get_contents($this->cacheFile), true);
49
        if (!isset($topics['topics'])) {
50
            return [];
51
        }
52
53
        return $topics['topics'];
54
    }
55
56
    public function build()
57
    {
58
        $topics = $this->topics();
59
        file_put_contents($this->cacheFile, json_encode($topics, JSON_PRETTY_PRINT));
60
61
        return $topics;
62
    }
63
64
    private function topics()
65
    {
66
        $config = [];
67
        $this->topicsInclude(__DIR__.'/../available/topics.yml', $config);
68
        $this->bundleTopicsInclude($config);
69
        foreach (glob($this->root.'/../config/topics/*.yml') as $filename) {
70
            $this->topicsInclude($filename, $config);
71
        }
72
73
        return $config;
74
    }
75
76
    private function topicsInclude($file, &$config)
77
    {
78
        $topics = $this->topicsRead($file);
79
        if (!isset($topics['topics']) || !is_array($topics['topics']) || count($topics['topics']) == 0) {
80
            return;
81
        }
82
        foreach ($topics['topics'] as $name => $topic) {
83
            $config['topics'][$name] = $topic;
84
        }
85
    }
86
87
    private function bundleTopicsInclude(&$config)
88
    {
89
        $bundles = $this->bundleModel->bundles();
90
        if (!is_array($bundles) || count($bundles) == 0) {
91
            return;
92
        }
93
        foreach ($bundles as $bundleName => $bundle) {
94
            foreach (glob($bundle['root'].'/../config/topics/*.yml') as $filename) {
95
                $this->topicsInclude($filename, $config);
96
            }
97
        }
98
    }
99
100
    private function topicsRead($topicConfig)
101
    {
102
        if (!file_exists($topicConfig)) {
103
            return;
104
        }
105
        $config = Yaml::parse(file_get_contents($topicConfig));
106
        if ($config == false) {
107
            throw new Exception('Can not parse YAML file: '.$topicConfig);
108
        }
109
110
        return $config;
111
    }
112
}
113