Skip to content

Commit

Permalink
Merge pull request #7 from j0k3r/fix/allow-php8
Browse files Browse the repository at this point in the history
Allow PHP 8 installation
  • Loading branch information
j0k3r authored Jun 26, 2020
2 parents 3c65388 + 65412b5 commit b60e806
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 231 deletions.
7 changes: 1 addition & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
.editorconfig export-ignore
.gitattributes export-ignore
.github/ export-ignore
.gitignore export-ignore
.php_cs export-ignore
.scrutinizer.yml export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
phpspec.yml.ci export-ignore
phpspec.yml.dist export-ignore
phpunit.xml.dist export-ignore
spec/ export-ignore
tests/ export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/phpunit.xml
/vendor/
.php_cs.cache
.phpunit.result.cache
7 changes: 7 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ filter:
tools:
external_code_coverage:
timeout: 600

build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
19 changes: 13 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
dist: xenial
os: linux
language: php


# avoid double Travis build when the PR is created on upstream
if: |
type = pull_request OR \
branch = master
cache:
directories:
- $HOME/.composer/cache
- $HOME/.composer/cache/files

php:
- 7.1
- 7.2
- 7.3
- 7.4
Expand All @@ -16,25 +23,25 @@ matrix:
allow_failures:
- php: nightly
include:
- php: 7.1
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.2
env: CS_FIXER=run COVERAGE=run

before_install:
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
- travis_retry composer self-update

install:
- travis_retry composer update ${COMPOSER_FLAGS} --no-progress --no-interaction
- composer update ${COMPOSER_FLAGS} --no-progress --no-interaction -o --no-suggest
- php vendor/bin/simple-phpunit install

before_script:
- if [ "$COVERAGE" = "run" ]; then PHPUNIT_FLAGS="--coverage-clover coverage.clover"; fi;

script:
- php vendor/bin/simple-phpunit -v $PHPUNIT_FLAGS
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/php-cs-fixer fix --verbose --dry-run ; fi;
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/phpstan analyse src tests --no-progress --level 7 ; fi;
- if [ "$CS_FIXER" = "run" ]; then php vendor/bin/phpstan analyse ; fi;


after_success:
Expand Down
95 changes: 48 additions & 47 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
{
"name": "j0k3r/httplug-ssrf-plugin",
"description": "Server-Side Request Forgery (SSRF) protection plugin for HTTPlug",
"type": "library",
"license": "MIT",
"keywords": ["ssrf", "security", "http", "httplug", "plugin"],
"homepage": "https://github.com/j0k3r/httplug-ssrf-plugin",
"authors": [
{
"name": "Jeremy Benoist",
"email": "jeremy.benoist@gmail.com"
"name": "j0k3r/httplug-ssrf-plugin",
"description": "Server-Side Request Forgery (SSRF) protection plugin for HTTPlug",
"type": "library",
"license": "MIT",
"keywords": ["ssrf", "security", "http", "httplug", "plugin"],
"homepage": "https://github.com/j0k3r/httplug-ssrf-plugin",
"authors": [
{
"name": "Jeremy Benoist",
"email": "jeremy.benoist@gmail.com"
},
{
"name": "aaa2000",
"email": "adev2000@gmail.com"
},
{
"name": "Jack W",
"email": "jack@fin1te.net",
"role": "Developer (SafeCurl original version)"
}
],
"require": {
"php": ">=7.2.9",
"php-http/client-common": "^2.0",
"php-http/message": "^1.7",
"php-http/message-factory": "^1.0.2",
"php-http/discovery": "^1.5"
},
{
"name": "aaa2000",
"email": "adev2000@gmail.com"
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"guzzlehttp/psr7": "^1.0",
"php-http/guzzle6-adapter": "^2.0",
"php-http/mock-client": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"symfony/phpunit-bridge": "~5.0"
},
{
"name": "Jack W",
"email": "jack@fin1te.net",
"role": "Developer (SafeCurl original version)"
}
],
"require": {
"php": "^7.1",
"php-http/client-common": "^2.0",
"php-http/message": "^1.7",
"php-http/message-factory": "^1.0.2",
"php-http/discovery": "^1.5"
},
"require-dev": {
"symfony/phpunit-bridge": "~3.4.19|~4.0",
"friendsofphp/php-cs-fixer": "^2.14",
"php-http/mock-client": "^1.0",
"php-http/guzzle6-adapter": "^2.0",
"guzzlehttp/psr7": "^1.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11"
},
"autoload": {
"psr-4": {
"Graby\\HttpClient\\Plugin\\ServerSideRequestForgeryProtection\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Graby\\HttpClient\\Plugin\\ServerSideRequestForgeryProtection\\": "tests/"
"autoload": {
"psr-4": {
"Graby\\HttpClient\\Plugin\\ServerSideRequestForgeryProtection\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Graby\\HttpClient\\Plugin\\ServerSideRequestForgeryProtection\\": "tests/"
}
},
"config": {
"sort-packages": true
}
},
"scripts": {
"test": "vendor/bin/simple-phpunit"
}
}
16 changes: 11 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: 7
paths:
- src
- tests

# https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288
autoload_files:
- vendor/bin/.phpunit/phpunit-7.5-0/vendor/autoload.php
- vendor/bin/.phpunit/phpunit-8.3-0/vendor/autoload.php

inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false

ignoreErrors:
# Fix PHPUnit\Framework\TestCase::expectException() custom typehint
- '#class\-string\<Throwable\>#'
6 changes: 1 addition & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
</php>

<testsuites>
<testsuite name="Httplug SSRF plugin Test Suite">
<testsuite name="Httplug SSRF plugin">
<directory>./tests</directory>
</testsuite>
</testsuites>
Expand Down
13 changes: 4 additions & 9 deletions src/Exception/InvalidOptionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Graby\HttpClient\Plugin\ServerSideRequestForgeryProtection\Exception;

class InvalidOptionException extends \Exception implements SsrfException
final class InvalidOptionException extends \Exception implements SsrfException
{
/**
* @param string $type
*
* @return static
*/
public static function invalidType($type, array $expectedTypes)
public static function invalidType($type, array $expectedTypes): self
{
$expectedTypesList = '"' . implode('", "', \array_slice($expectedTypes, 0, -1))
. '" or "' . $expectedTypes[\count($expectedTypes) - 1] . '"';
Expand All @@ -22,18 +22,13 @@ public static function invalidType($type, array $expectedTypes)
*
* @return static
*/
public static function invalidListName($listName)
public static function invalidListName($listName): self
{
return new static(sprintf('Provided list "%s" must be "whitelist" or "blacklist"', $listName));
}

public static function emptyValues()
public static function emptyValues(): self
{
return new static('Provided values cannot be empty');
}

public static function invalidValues($values)
{
return new static(sprintf('Provided values must be an array, "%s" given', \gettype($values)));
}
}
Loading

0 comments on commit b60e806

Please sign in to comment.