Issues (14)

Security Analysis    not enabled

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/SEOGenerator.php (3 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
namespace MeestorHok\Blue;
4
5
use Artesaos\SEOTools\Facades\SEOTools as SEOTools;
6
use Request;
7
use File;
8
use MeestorHok\Blue\Site;
9
10
class SEOGenerator
11
{
12
    public $defaults;
13
    
14
    public function __construct () {
15
        $this->defaults = [
16
            'title' => 'Home',
17
            'title-spacer' => ' &#8211; ',
18
            'title-description' => 'Laravel Blue',
19
            'keywords' => array_collapse([['home'], ['laravel', 'blue', 'cms', 'meestorhok']]),
20
            'description' => 'This amazing site was created by Laravel Blue!',
21
            'images' => [],
22
            'twitter' => '@BlueCMS',
23
            'copyright' => '© 2016 Laravel Blue',
24
            'robots' => 'index,follow',
25
            'colors' => [
26
                'safari_pinned' => '#151e4f',
27
                'ms_tile' => '#ffffff',
28
                'theme' => '#151e4f'
29
            ]
30
        ];
31
    }
32
    
33
    public function generateSEO (array $page)
34
    {
35
        SEOTools::metatags()
36
            ->setTitleDefault($page['title-description'])
37
            ->setTitleSeparator($page['title-spacer'])
38
            ->setTitle($page['title'])
39
            ->setDescription($page['description'])
40
            ->setCanonical(Request::url())
41
            ->addMeta('copyright', $page['copyright'])
42
            ->addMeta('robots', $page['robots'])
43
            ->addMeta('HandheldFriendly', 'True')
44
            ->addMeta('MobileOptimized', '320')
45
            ->addMeta('X-UA-Compatible', 'IE=edge', 'http-equiv')
46
            ->addMeta('viewport', 'width=device-width, initial-scale=1, shrink-to-fit=no');
47
        SEOTools::opengraph()
48
            ->setTitle($page['title'].$page['title-spacer'].$page['title-description'])
49
            ->setDescription($page['description'])
50
            ->setUrl(Request::url())
51
            ->addProperty('locale', 'en_US')
52
            ->addProperty('type', 'website');
53
        SEOTools::twitter()
54
            ->setSite($page['twitter'])
55
            ->setTitle($page['title'].$page['title-spacer'].$page['title-description'])
56
            ->setDescription($page['description'])
57
            ->setType('summary')
58
            ->setUrl(Request::url());
59
        foreach ($page['images'] as $image) {
60
            SEOTools::opengraph()->addImage(asset($image['uri']));
61
            SEOTools::twitter()->addImage(asset($image['uri']));
62
        }
63
        foreach ($page['keywords'] as $keyword) {
64
            SEOTools::metatags()->addKeyword($keyword);
65
        }
66
    }
67
    
68
    public function make (array $details, $view = null)
69
    {
70
        $this->defaults = array_replace($this->defaults, $details);
71
        
72
        $this->generateSEO($this->defaults);
73
        
74
        if (!is_null($view)) {
75
            return view($view);
76
        }
77
    }
78
    
79
    public function get ()
80
    {
81
        return (Site::first()->is_public_site) ? str_replace(PHP_EOL, '', SEOTools::generate()) . $this->getFavicons() : '<meta name="robots" content="noindex,nofollow">'.$this->getFavicons();
82
    }
83
    
84
    public function generateFavicons ($dir = '') 
85
    {
86
        $colors = $this->defaults['colors'];
87
        return
88 View Code Duplication
                insert_if_exists (['60x60', '72x72', '114x114', '120x120', '152x152', '180x180'], function ($insert) use ($dir) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
                        return '<link rel="apple-touch-icon" sizes="' . $insert . '" href="' . asset($dir . '/apple-touch-icon-' . $insert . '.png').'">';
90
                    }, function ($insert) use ($dir) {
91
                        return File::exists(public_path($dir.'/apple-touch-icon-'.$insert.'.png'));
92
                    }) . 
93 View Code Duplication
                insert_if_exists (['16x16', '32x32', '96x96', '194x194'], function ($insert) use ($dir) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
                        return '<link rel="icon" type="image/png" href="' . asset($dir . '/favicon-' . $insert . '.png').'" sizes="'.$insert.'">';
95
                    }, function ($insert) use ($dir) {
96
                        return File::exists(public_path($dir.'/favicon-'.$insert.'.png'));
97
                    }) . 
98 View Code Duplication
                insert_if_exists (['192x192'], function ($insert) use ($dir) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
                        return '<link rel="icon" type="image/png" href="' . asset($dir . '/android-chrome-' . $insert . '.png').'" sizes="'.$insert.'">';
100
                    }, function ($insert) use ($dir) {
101
                        return File::exists(public_path($dir.'/android-chrome-'.$insert.'.png'));
102
                    }) . 
103
                insert_if_exists ($dir.'/manifest.json', function ($insert) {
104
                        return '<link rel="manifest" href="' . asset($insert) . '">';
105
                    }, function ($insert) {
106
                        return File::exists(public_path($insert));
107
                    }) . 
108
                insert_if_exists ($dir.'/safari-pinned-tab.svg', function ($insert) use ($colors) {
109
                        return '<link rel="mask-icon" href="'.asset($insert).'" color="' . insert_if_exists($colors['safari_pinned']) . '">';
110
                    }, function ($insert) {
111
                        return File::exists(public_path($insert));
112
                    }) . 
113
                insert_if_exists ($dir.'/favicon.ico', function ($insert) {
114
                        return '<link rel="shortcut icon" href="'.asset($insert).'">';
115
                    }, function ($insert) {
116
                        return File::exists(public_path($insert));
117
                    }) . 
118
                insert_if_exists ($dir.'/mstile-144x144.png', function ($insert) {
119
                        return '<meta name="msapplication-TileImage" content="'.asset($insert).'">';
120
                    }, function ($insert) {
121
                        return File::exists(public_path($insert));
122
                    }) . 
123
                insert_if_exists ($dir.'/browserconfig.xml', function ($insert) {
124
                        return '<meta name="msapplication-config" content="'.asset($insert).'">';
125
                    }, function ($insert) {
126
                        return File::exists(public_path($insert));
127
                    }) . 
128
                insert_if_exists ($colors['ms_tile'], function ($insert) {
129
                        return '<meta name="msapplication-TileColor" content="'.$insert.'">';
130
                    }) . 
131
                insert_if_exists ($colors['theme'], function ($insert) {
132
                        return '<meta name="theme-color" content="'.$insert.'">';
133
                    });
134
    }
135
    
136
    public function getFavicons () 
137
    {
138
        $site = Site::first();
139
        if (is_null($site)) {
140
            return $this->generateFavicons('/blue/img/icons');
141
        }
142
        return $site->favicons;
143
    }
144
}