Issues (4)

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/Providers/MuseProvider.php (4 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 namespace JobApis\Jobs\Client\Providers;
2
3
use JobApis\Jobs\Client\Job;
4
5
class MuseProvider extends AbstractProvider
6
{
7
    /**
8
     * Returns the standardized job object
9
     *
10
     * @param array $payload Raw job payload from the API
11
     *
12
     * @return \JobApis\Jobs\Client\Job
13
     */
14 4
    public function createJobObject($payload = [])
15
    {
16 4
        $job = new Job([
17 4
            'title' => $payload['name'],
18 4
            'name' => $payload['name'],
19 4
            'description' => $payload['contents'],
20 4
            'url' => $payload['refs']['landing_page'],
21 4
            'sourceId' => $payload['id'],
22 4
        ]);
23
24
        // categories array
25 4
        $this->setCategories($job, $payload['categories']);
26
27
        // company array
28 4
        $this->setCompany($job, $payload['company']);
29
30
        // levels array
31 4
        $this->setLevels($job, $payload['levels']);
32
33
        // locations array
34 4
        $this->setLocation($job, $payload['locations']);
35
36 4
        return $job;
37
    }
38
39
    /**
40
     * Job response object default keys that should be set
41
     *
42
     * @return  string
43
     */
44 4
    public function getDefaultResponseFields()
45
    {
46
        return [
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array('levels', '...ompany', 'id', 'name'); (string[]) is incompatible with the return type declared by the abstract method JobApis\Jobs\Client\Prov...etDefaultResponseFields of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
47 4
            'levels', // array
48 4
            'locations', // array
49 4
            'tags', // array
50 4
            'categories', // array
51 4
            'publication_date',
52 4
            'short_name',
53 4
            'refs', // array
54 4
            'contents',
55 4
            'type',
56 4
            'model_type',
57 4
            'company', // array
58 4
            'id',
59 4
            'name',
60 4
        ];
61
    }
62
63
    /**
64
     * Get listings path
65
     *
66
     * @return  string
67
     */
68 4
    public function getListingsPath()
69
    {
70 4
        return 'results';
71
    }
72
73
    /**
74
     * Sets the categories on the job using the categories array
75
     *
76
     * @param Job $job
77
     * @param array $categories
78
     *
79
     * @return MuseProvider
80
     */
81 4
    protected function setCategories(Job $job, $categories = [])
82
    {
83 4
        $occupationalCats = [];
84 4
        foreach ($categories as $category) {
85 4
            $occupationalCats[] = $category['name'];
86 4
        }
87 4
        if ($occupationalCats) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $occupationalCats of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
88 4
            $job->setOccupationalCategory(implode(', ', $occupationalCats));
89 4
        }
90 4
        return $this;
91
    }
92
93
    /**
94
     * Sets the company on the job using the company array
95
     *
96
     * @param Job $job
97
     * @param array $company
98
     *
99
     * @return MuseProvider
100
     */
101 4
    protected function setCompany(Job $job, $company = [])
102
    {
103 4
        if ($company && isset($company['name'])) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $company of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
104 4
            $job->setCompany($company['name']);
105 4
        }
106 4
        return $this;
107
    }
108
109
    /**
110
     * Sets the experience levels on the job using the levels array
111
     *
112
     * @param Job $job
113
     * @param array $levels
114
     *
115
     * @return MuseProvider
116
     */
117 4
    protected function setLevels(Job $job, $levels = [])
118
    {
119 4
        $requirements = [];
120 4
        foreach ($levels as $level) {
121 4
            $requirements[] = $level['name'];
122 4
        }
123 4
        if ($requirements) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $requirements of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
124 4
            $job->setExperienceRequirements(implode(', ', $requirements));
125 4
        }
126 4
        return $this;
127
    }
128
129
    /**
130
     * Sets the location on the job using the first location in the array
131
     *
132
     * @param Job $job
133
     * @param array $locations
134
     *
135
     * @return MuseProvider
136
     */
137 4
    protected function setLocation(Job $job, $locations = [])
138
    {
139 4
        if (isset($locations[0]) && isset($locations[0]['name'])) {
140 4
            $job->setLocation($locations[0]['name']);
141 4
        }
142 4
        return $this;
143
    }
144
}
145