Skip to content
This repository was archived by the owner on Jan 23, 2021. It is now read-only.

Commit 539d559

Browse files
authored
Merge pull request #12 from shochdoerfer/feature/upgrade_securitychecker
Upgrade sensiolabs/security-checker to version 5
2 parents 40c25c8 + 798d1be commit 539d559

6 files changed

Lines changed: 83 additions & 90 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ in your main build.xml file:
3232

3333
```xml
3434
<property name="securitychecker.lockfile" value="composer.lock" />
35-
<property name="securitychecker.endpoint" value="https://security.sensiolabs.org/check_lock" />
35+
<property name="securitychecker.endpoint" value="https://security.symfony.com/check_lock" />
3636
```
3737

3838
Or define the securitychecker task on your own:

clover.xml

Lines changed: 0 additions & 53 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.0",
2020
"phing/phing": "^2.8.0",
21-
"sensiolabs/security-checker": "^4.0"
21+
"sensiolabs/security-checker": "^5.0"
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^6.0",

composer.lock

Lines changed: 69 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bitExpert/Phing/SecurityChecker/SecurityCheckerTask.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function main()
6767
}
6868

6969
$checker = $this->getSecurityChecker();
70+
$vulnerabilities = [];
7071

7172
try {
7273
if (!empty($this->timeout)) {
@@ -77,7 +78,6 @@ public function main()
7778
}
7879

7980
$vulnerabilities = $checker->check($this->lockFile);
80-
8181
foreach ($vulnerabilities as $dependency => $issues) {
8282
$dependencyFullName = $dependency . ' (' . $issues['version'] . ')';
8383
$this->log($dependencyFullName);
@@ -101,7 +101,7 @@ public function main()
101101
throw new \BuildException($e);
102102
}
103103

104-
if ($checker->getLastVulnerabilityCount() > 0) {
104+
if (count($vulnerabilities) > 0) {
105105
throw new \BuildException('Vulnerabilities found!');
106106
}
107107
}

tests/bitExpert/Phing/SecurityChecker/SecurityCheckerTaskUnitTest.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace bitExpert\Phing\SecurityChecker;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use SensioLabs\Security\Crawler\CrawlerInterface;
15+
use SensioLabs\Security\Crawler;
1616
use SensioLabs\Security\SecurityChecker;
1717

1818
/**
@@ -23,7 +23,7 @@
2323
class SecurityCheckerTaskUnitTest extends TestCase
2424
{
2525
/**
26-
* @var CrawlerInterface|TestCase
26+
* @var Crawler|TestCase
2727
*/
2828
private $crawler;
2929
/**
@@ -92,8 +92,9 @@ public function endPointParameterShouldBePassedToSecurityCheckerWhenGiven()
9292

9393
/**
9494
* @test
95+
* @expectedException \BuildException
9596
*/
96-
public function advisoriesIncludingLinkWillCallLogMethodFiveTimes()
97+
public function advisoriesIncludingLinkWillCallLogMethodFiveTimesAndThrowBuildException()
9798
{
9899
$vulnerabilities = [
99100
'my/dependency' => [
@@ -119,8 +120,9 @@ public function advisoriesIncludingLinkWillCallLogMethodFiveTimes()
119120

120121
/**
121122
* @test
123+
* @expectedException \BuildException
122124
*/
123-
public function advisoriesWithEmptyLinkWillCallLogMethodFourTimes()
125+
public function advisoriesWithEmptyLinkWillCallLogMethodFourTimesAndThrowBuildException()
124126
{
125127
$vulnerabilities = [
126128
'my/dependency' => [
@@ -144,20 +146,6 @@ public function advisoriesWithEmptyLinkWillCallLogMethodFourTimes()
144146
$this->checkerTask->main();
145147
}
146148

147-
/**
148-
* @test
149-
* @expectedException \BuildException
150-
*/
151-
public function throwsBuildExceptionWhenVulnerabilitiesFound()
152-
{
153-
$this->checker->expects($this->once())
154-
->method('getLastVulnerabilityCount')
155-
->will($this->returnValue(1));
156-
157-
$this->checkerTask->setLockfile(__FILE__);
158-
$this->checkerTask->main();
159-
}
160-
161149
/**
162150
* Helper method to create all required mock objects and configure the {@link \SensioLabs\Security\SecurityChecker}
163151
* instance to return the given $vulnerabilities.
@@ -166,14 +154,14 @@ public function throwsBuildExceptionWhenVulnerabilitiesFound()
166154
*/
167155
protected function createMockObjects(array $vulnerabilities = [])
168156
{
169-
$this->crawler = $this->createMock(CrawlerInterface::class);
157+
$this->crawler = $this->createMock(Crawler::class);
170158
$this->checker = $this->createMock(SecurityChecker::class);
171159
$this->checker->expects($this->any())
172160
->method('check')
173-
->will($this->returnValue($vulnerabilities));
161+
->willReturn($vulnerabilities);
174162
$this->checker->expects($this->any())
175163
->method('getCrawler')
176-
->will($this->returnValue($this->crawler));
164+
->willReturn($this->crawler);
177165

178166
$this->checkerTask = $this->createPartialMock(
179167
SecurityCheckerTask::class,
@@ -184,7 +172,7 @@ protected function createMockObjects(array $vulnerabilities = [])
184172
);
185173
$this->checkerTask->expects($this->any())
186174
->method('getSecurityChecker')
187-
->will($this->returnValue($this->checker));
175+
->willReturn($this->checker);
188176
$this->checkerTask->setProject(new \Project());
189177
}
190178
}

0 commit comments

Comments
 (0)