Language: PHP
Label: vulnerable
CWE: CWE-346 \u2014 Origin Validation Error
The product does not properly verify that the source of data or communication is valid.

Code:
    public function __construct($loop, $baseuri)
    {
        $this->key = \generateKey(32);

        $this->setWebsocket(config('daemon.port'));

        $this->loop    = $loop;
        $this->baseuri = $baseuri;

        DBSession::whereNotNull('id')->delete();

        // API_SOCKET ?
        if (file_exists(CACHE_PATH . 'socketapi.sock')) {
            unlink(CACHE_PATH . 'socketapi.sock');
        }

        array_map('unlink', array_merge(
            glob(PUBLIC_CACHE_PATH . '*.css'),
            glob(PUBLIC_CACHE_PATH . '*.js')
        ));

        $this->registerCleaner();

        // Generate Push Notification
        if (!file_exists(CACHE_PATH . 'vapid_keys.json')) {
            echo colorize("Generate and store the Push Notification VAPID keys", 'green')."\n";
            $keyset = VAPID::createVapidKeys();
            file_put_contents(CACHE_PATH . 'vapid_keys.json', json_encode($keyset));
        }
    }