Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mobula9 committed Dec 3, 2020
1 parent b451a66 commit e886d60
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Tests

on:
push:
pull_request:
# push: TODO P3 No tests on push because it causes an unresolved bug (no space left on device). This Smell a race condition.

jobs:

Expand All @@ -12,7 +12,8 @@ jobs:

strategy:
matrix:
php: ['7.2'] # TODO P1 TRY MORE VERSION (5.6, 7.0, 7.1, 7.3, 7.4)
php: ['7.2', '7.3', '7.4']
# TODO P2 PHP 8 Compatibility: Fix: Error: Class "Memcached" not found (https://github.com/crowdsecurity/php-cs-bouncer/runs/1491476055?check_suite_focus=true)

services:
redis:
Expand Down
2 changes: 1 addition & 1 deletion docs/how-it-works.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TODO reword this text.
TODO P2 reword this text.

Sync Strategy
-------------
Expand Down
9 changes: 8 additions & 1 deletion docs/technical-decisions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ We don't use Swagger Codegen

We were not able to use this client with easen ex: impossible to get
JSON data, it's seemd there is a bug with unserialization, we received
an empty array.
an empty array.

PHP 7.0+ compatibility
----------------------

Why not PHP 5.6? This PHP version is no more supported since december 2018 (not even security fix!).

What about PHP 8? We are working on it. The current problem is that we have some troubles with PHP 8 + Memcached.
4 changes: 2 additions & 2 deletions src/ApiCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function saveDeferred(CacheItem $item, int $ip, string $type, int $expir
Update the cached remediations from these new decisions.
TODO WRITE TESTS P2
TODO P2 WRITE TESTS
0 decisions
3 known remediation type
3 decisions but 1 unknown remediation type
Expand Down Expand Up @@ -186,7 +186,7 @@ private function miss(int $ip): string
private function hit(int $ip): string
{
$remediations = $this->adapter->getItem((string) $ip)->get();
// P2 TODO control before if date is not expired and if true, update cache item.
// TODO P2 control before if date is not expired and if true, update cache item.

// We apply array values first because keys are ids.
$firstRemediation = array_values($remediations)[0];
Expand Down
4 changes: 2 additions & 2 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class Constants
const CAPI_URL = 'https://api.crowdsec.net/v2/'; // TODO P2 get the correct one

/** @var string The user agent used to send request to LAPI or CAPI */
const BASE_USER_AGENT = 'CrowdSec PHP Library/1.0.0'; // P3 TODO get the correct version
const BASE_USER_AGENT = 'CrowdSec PHP Library/1.0.0'; // TODO P3 get the correct version

/** @var int The timeout when calling LAPI or CAPI */
const API_TIMEOUT = 1; // TODO P2 get the correct one

/** @var array The list of each known remediation, sorted by priority */
const ORDERED_REMEDIATIONS = ['ban', 'captcha']; // P2 TODO get the correct one
const ORDERED_REMEDIATIONS = ['ban', 'captcha']; // TODO P2 get the correct one
}
4 changes: 2 additions & 2 deletions src/Remediation.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function sortRemediationByPriority(array $remediations): array
/**
* Parse "duration" entries returned from API to a number of seconds.
*
* TODO TEST P3
* TODO P3 TEST
* 9999h59m56.603445s
* 10m33.3465483s
* 33.3465483s
Expand Down Expand Up @@ -102,7 +102,7 @@ private static function parseDurationToSeconds(string $duration): int
* Format a remediation item of a cache item.
* This format use a minimal amount of data allowing less cache data consumption.
*
* TODO TESTS P3
* TODO P3 TESTS
*/
public static function formatFromDecision(?array $decision): array
{
Expand Down
4 changes: 1 addition & 3 deletions tests/IpVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,14 @@ public function testCanVerifyIpInStreamModeWithCacheSystem(AbstractAdapter $cach
$remediation1stCall = $bouncer->getRemediationForIp($blockedIp);
$this->assertEquals('ban', $remediation1stCall);

// TODO P1 Add and remove decision and try updating cache
// TODO P1 Add and remove decision and try updating cache with refreshBlocklistCache()

// Clear cache
//$cacheAdapter->clear();

// Call the same thing for the second time (now it should be a cache miss)
//$remediation2ndCall = $bouncer->getRemediationForIp($blockedIp);
//$this->assertEquals('ban', $remediation2ndCall);

// TODO ADD new decisions to LAPI and test refreshBlocklistCache()
}

/**
Expand Down

0 comments on commit e886d60

Please sign in to comment.