Skip to content

Commit

Permalink
Merge pull request #10 from j0k3r/fix/update-project
Browse files Browse the repository at this point in the history
Ditch PHP < 7.4
  • Loading branch information
j0k3r authored Oct 27, 2022
2 parents 7f330e2 + 8c062e5 commit da82156
Show file tree
Hide file tree
Showing 19 changed files with 273 additions and 232 deletions.
11 changes: 8 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF
indent_style = space
end_of_line = lf
charset = utf-8
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4
charset = utf-8

[.github/**.yml]
indent_size = 2
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: j0k3r
73 changes: 73 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
pull_request:
branches:
- "master"
push:
branches:
- "master"

env:
fail-fast: true

jobs:
unit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: "ubuntu-20.04"

strategy:
matrix:
php:
- "7.4"
- "8.0"
- "8.1"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: pecl, composer:v2
extensions: curl
ini-values: "date.timezone=Europe/Paris"
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2

- name: Run PHPUnit
run: php vendor/bin/simple-phpunit -v

cs:
name: PHP-CS-Fxier
runs-on: "ubuntu-20.04"

strategy:
matrix:
php:
- "7.4"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: pecl, composer:v2
extensions: curl
ini-values: "date.timezone=Europe/Paris"
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2

- name: Run PHP-CS-Fxier
run: php vendor/bin/php-cs-fixer fix --verbose --dry-run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
build
.php_cs.cache
.phpunit.result.cache
.php-cs-fixer.cache
20 changes: 10 additions & 10 deletions .php_cs → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?php

return PhpCsFixer\Config::create()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude(['vendor', 'log'])
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
// beacuse of PHP 5.3.3
'array_syntax' => ['syntax' => 'long'],
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'heredoc_to_nowdoc' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => false,
'php_unit_strict' => true,
'phpdoc_order' => true,
// 'psr4' => true,
'strict_comparison' => true,
'strict_param' => true,
'concat_space' => ['spacing' => 'one'],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude(['vendor', 'log'])
->in(__DIR__)
)
->setFinder($finder)
;
9 changes: 0 additions & 9 deletions .scrutinizer.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# SafeCurl

[![Build Status](https://travis-ci.org/j0k3r/safecurl.svg?branch=master)](https://travis-ci.org/j0k3r/safecurl)
[![Code Coverage](https://scrutinizer-ci.com/g/j0k3r/safecurl/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/j0k3r/safecurl/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/j0k3r/safecurl/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/j0k3r/safecurl/?branch=master)
[![CI](https://github.com/j0k3r/safecurl/actions/workflows/tests.yml/badge.svg)](https://github.com/j0k3r/safecurl/actions/workflows/tests.yml)
[![Total Downloads](https://poser.pugx.org/j0k3r/safecurl/downloads)](https://packagist.org/packages/j0k3r/safecurl)
[![License](https://poser.pugx.org/j0k3r/safecurl/license)](https://packagist.org/packages/j0k3r/safecurl)

SafeCurl intends to be a drop-in replacement for the [curl_exec](http://php.net/manual/en/function.curl-exec.php) function in PHP. SafeCurl validates each part of the URL against a white or black list, to help protect against Server-Side Request Forgery attacks.

For more infomation about the project see the blog post ['SafeCurl: SSRF Protection, and a "Capture the Bitcoins"'](http://blog.fin1te.net/post/86235998757/safecurl-ssrf-protection-and-a-capture-the-bitcoins).
For more infomation about the project see the blog post ['SafeCurl: SSRF Protection, and a "Capture the Bitcoins"'](https://whitton.io/articles/safecurl-ssrf-protection-and-a-capture-the-bitcoins/).

## Protections

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
}
],
"require": {
"php": "^7.2|^8.0",
"php": "^7.4|^8.0",
"ext-curl": "*"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0",
"friendsofphp/php-cs-fixer": "~2.0"
"symfony/phpunit-bridge": "^6.0",
"friendsofphp/php-cs-fixer": "~3.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion example/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
$safeCurl = new SafeCurl(curl_init());
$result = $safeCurl->execute('https://fin1te.net');
} catch (Exception $e) {
//Handle exception
// Handle exception
}
14 changes: 7 additions & 7 deletions example/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

try {
$options = new Options();
//Completely clear the whitelist
$options->setList('whitelist', array());
//Completely clear the blacklist
$options->setList('blacklist', array());
//Set the domain whitelist only
$options->setList('whitelist', array('google.com', 'youtube.com'), 'domain');
// Completely clear the whitelist
$options->setList('whitelist', []);
// Completely clear the blacklist
$options->setList('blacklist', []);
// Set the domain whitelist only
$options->setList('whitelist', ['google.com', 'youtube.com'], 'domain');

$safeCurl = new SafeCurl(curl_init());
$result = $safeCurl->execute('http://www.youtube.com');
} catch (Exception $e) {
//Handle exception
// Handle exception
}
4 changes: 2 additions & 2 deletions example/redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

try {
$options = new Options();
//Follow redirects, but limit to 10
// Follow redirects, but limit to 10
$options->enableFollowLocation()->setFollowLocationLimit(10);

$safeCurl = new SafeCurl(curl_init());
$result = $safeCurl->execute('http://fin1te.net');
} catch (Exception $e) {
//Handle exception
// Handle exception
}
2 changes: 1 addition & 1 deletion example/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
try {
$safeUrl = Url::validateUrl('http://google.com', new Options());
} catch (Exception $e) {
//Handle exception
// Handle exception
}
Loading

0 comments on commit da82156

Please sign in to comment.