Issues (1)

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/CareerbuilderProvider.php (1 issue)

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 CareerbuilderProvider 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 10
    public function createJobObject($payload = [])
15
    {
16 10
        $job = new Job([
17 10
            'description' => $payload['DescriptionTeaser'],
18 10
            'employmentType' => $payload['EmploymentType'],
19 10
            'title' => $payload['JobTitle'],
20 10
            'name' => $payload['JobTitle'],
21 10
            'url' => $payload['JobDetailsURL'],
22 10
            'educationRequirements' => $payload['EducationRequired'],
23 10
            'experienceRequirements' => $payload['ExperienceRequired'],
24 10
            'sourceId' => $payload['DID'],
25 10
        ]);
26
27 10
        $pay = $this->parseSalariesFromString($payload['Pay']);
28
29 10
        $job->setOccupationalCategoryWithCodeAndTitle(
30 10
            $payload['OnetCode'],
31 10
            $payload['ONetFriendlyTitle']
32 10
        )->setCompany($payload['Company'])
33 10
            ->setCompanyUrl($payload['CompanyDetailsURL'])
34 10
            ->setLocation(
35 10
                $this->parseLocationElement($payload['City'])
36 10
                .', '.
37 10
                $this->parseLocationElement($payload['State'])
38 10
            )
39 10
            ->setCity($this->parseLocationElement($payload['City']))
40 10
            ->setState($this->parseLocationElement($payload['State']))
41 10
            ->setDatePostedAsString($payload['PostedDate'])
42 10
            ->setCompanyLogo($payload['CompanyImageURL'])
43 10
            ->setMinimumSalary($pay['min'])
44 10
            ->setMaximumSalary($pay['max']);
45
46 10
        if (isset($payload['Skills']['Skill'])) {
47 10
            $job->setSkills($this->parseSkillSet($payload['Skills']['Skill']));
48 10
        }
49
50 10
        return $job;
51
    }
52
53
    /**
54
     * Job response object default keys that should be set
55
     *
56
     * @return  string
57
     */
58 4
    public function getDefaultResponseFields()
59
    {
60
        return [
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array('Company', ...nyImageURL', 'Skills'); (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...
61 4
            'Company',
62 4
            'CompanyDetailsURL',
63 4
            'DescriptionTeaser',
64 4
            'DID',
65 4
            'OnetCode',
66 4
            'ONetFriendlyTitle',
67 4
            'EmploymentType',
68 4
            'EducationRequired',
69 4
            'ExperienceRequired',
70 4
            'JobDetailsURL',
71 4
            'Location',
72 4
            'City',
73 4
            'State',
74 4
            'PostedDate',
75 4
            'Pay',
76 4
            'JobTitle',
77 4
            'CompanyImageURL',
78 4
            'Skills',
79 4
        ];
80
    }
81
82
    /**
83
     * Get data format
84
     *
85
     * @return string
86
     */
87 4
    public function getFormat()
88
    {
89 4
        return 'xml';
90
    }
91
92
    /**
93
     * Get listings path
94
     *
95
     * @return string
96
     */
97 4
    public function getListingsPath()
98
    {
99 4
        return 'Results.JobSearchResult';
100
    }
101
102
    /**
103
     * Get min and max salary numbers from string
104
     *
105
     * @return array
106
     */
107 22
    public function parseSalariesFromString($input = null)
108
    {
109
        $salary = [
110 22
            'min' => null,
111
            'max' => null
112 22
        ];
113
        $expressions = [
114 22
            'annualRange' => "/^.\d+k\s-\s.\d+k\/year$/",
115 22
            'annualFixed' => "/^.\d+k\/year$/",
116 22
            'hourlyRange' => "/^.\d+.\d+\s-\s.\d+.\d+\/hour$/",
117 22
            'hourlyFixed' => "/^.\d+.\d+\/hour$/",
118 22
        ];
119
120 22
        foreach ($expressions as $key => $expression) {
121 22
            if (preg_match($expression, $input)) {
122 8
                $method = 'parse'.$key;
123 8
                $salary = $this->$method($salary, $input);
124 8
            }
125 22
        }
126
127 22
        return $salary;
128
    }
129
130
    /**
131
     * Parse annual salary range from CB API
132
     *
133
     * @return array
134
     */
135 2
    protected function parseAnnualRange($salary = [], $input = null)
136
    {
137
        preg_replace_callback("/(.\d+k)\s.\s(.\d+k)/", function ($matches) use (&$salary) {
138 2
            $salary['min'] = str_replace('k', '000', $matches[1]);
139 2
            $salary['max'] = str_replace('k', '000', $matches[2]);
140 2
        }, $input);
141
142 2
        return $salary;
143
    }
144
145
    /**
146
     * Parse fixed annual salary from CB API
147
     *
148
     * @return array
149
     */
150 2
    protected function parseAnnualFixed($salary = [], $input = null)
151
    {
152
        preg_replace_callback("/(.\d+k)/", function ($matches) use (&$salary) {
153 2
            $salary['min'] = str_replace('k', '000', $matches[1]);
154 2
        }, $input);
155
156 2
        return $salary;
157
    }
158
159
    /**
160
     * Parse hourly payrate range from CB API
161
     *
162
     * @return array
163
     */
164 2
    protected function parseHourlyRange($salary = [], $input = null)
165
    {
166
        preg_replace_callback("/(.\d+.\d+)\s.\s(.\d+.\d+)/", function ($matches) use (&$salary) {
167 2
            $salary['min'] = $matches[1];
168 2
            $salary['max'] = $matches[2];
169 2
        }, $input);
170
171 2
        return $salary;
172
    }
173
174
    /**
175
     * Parse fixed hourly payrate from CB API
176
     *
177
     * @return array
178
     */
179
    protected function parseHourlyFixed($salary = [], $input = null)
180
    {
181 2
        preg_replace_callback("/(.\d+.\d+)/", function ($matches) use (&$salary) {
182 2
            $salary['min'] = $matches[1];
183 2
        }, $input);
184
185 2
        return $salary;
186
    }
187
188
    /**
189
     * Makes sure that city/state is a string
190
     *
191
     * @param $element mixed
192
     *
193
     * @return string|null
194
     */
195 10
    protected function parseLocationElement($element)
196
    {
197 10
        if (is_string($element)) {
198 10
            return $element;
199
        }
200 2
        return '';
201
    }
202
203
    /**
204
     * Parse skills array into string
205
     *
206
     * @return array
207
     */
208 10
    protected function parseSkillSet($skills)
209
    {
210 10
        if (is_array($skills)) {
211 4
            return implode(', ', $skills);
212 6
        } elseif (is_string($skills)) {
213 2
            return $skills;
214
        }
215 4
        return null;
216
    }
217
}
218