Skip to content

Commit e3f1400

Browse files
style(*): Pass through phpcsfixer for scripts folder
1 parent bca6c70 commit e3f1400

File tree

5 files changed

+30
-42
lines changed

5 files changed

+30
-42
lines changed

scripts/auto-prepend/bounce.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
/**
3-
* This script is aimed to be called by an auto-prepend directive
3+
* This script is aimed to be called by an auto-prepend directive.
4+
*
45
* @see docs/USER_GUIDE.md
6+
*
57
* @var $crowdSecStandaloneBouncerConfig
68
*/
79
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -10,10 +12,4 @@
1012
use CrowdSecBouncer\StandaloneBounce;
1113

1214
$bounce = new StandaloneBounce();
13-
// Retro compatibility with crowdsec php lib < 0.14.0
14-
if(isset($crowdSecStandaloneBouncerConfig['bouncing_level']) && $crowdSecStandaloneBouncerConfig['bouncing_level'] === 'normal_boucing'){
15-
$crowdSecStandaloneBouncerConfig['bouncing_level'] = 'normal_bouncing';
16-
}elseif($crowdSecStandaloneBouncerConfig['bouncing_level'] === 'flex_boucing'){
17-
$crowdSecStandaloneBouncerConfig['bouncing_level'] = 'flex_bouncing';
18-
}
19-
$bounce->safelyBounce($crowdSecStandaloneBouncerConfig);
15+
$bounce->safelyBounce($crowdSecStandaloneBouncerConfig);
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
/**
3-
* This script is aimed to be called by an auto-prepend directive
3+
* This script is aimed to be called by an auto-prepend directive.
4+
*
45
* @see docs/USER_GUIDE.md
6+
*
57
* @var $crowdSecStandaloneBouncerConfig
68
*/
79
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -10,13 +12,7 @@
1012
use CrowdSecBouncer\StandaloneBounce;
1113

1214
$bounce = new StandaloneBounce();
13-
// Retro compatibility with crowdsec php lib < 0.14.0
14-
if(isset($crowdSecStandaloneBouncerConfig['bouncing_level']) && $crowdSecStandaloneBouncerConfig['bouncing_level'] === 'normal_boucing'){
15-
$crowdSecStandaloneBouncerConfig['bouncing_level'] = 'normal_bouncing';
16-
}elseif($crowdSecStandaloneBouncerConfig['bouncing_level'] === 'flex_boucing'){
17-
$crowdSecStandaloneBouncerConfig['bouncing_level'] = 'flex_bouncing';
18-
}
1915
$bounce->initLogger($crowdSecStandaloneBouncerConfig);
2016
$bouncer = $bounce->init($crowdSecStandaloneBouncerConfig);
2117
$bouncer->refreshBlocklistCache();
22-
echo 'Cache has been refreshed'.PHP_EOL;
18+
echo 'Cache has been refreshed' . \PHP_EOL;

scripts/auto-prepend/settings.example.php

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
2+
23
// @see ../../docs/USER_GUIDE.md for possible settings details
34
use CrowdSecBouncer\Constants;
45

56
$crowdSecStandaloneBouncerConfig = [
6-
7-
/** Select from 'api_key' and 'tls'
7+
/** Select from 'api_key' and 'tls'.
88
*
99
* Choose if you want to use an API-KEY or a TLS (pki) authentification
1010
* TLS authentication is only available if you use CrowdSec agent with a version superior to 1.4.0
1111
*/
1212
'auth_type' => Constants::AUTH_KEY,
1313

14-
/** Absolute path to the bouncer certificate
14+
/** Absolute path to the bouncer certificate.
1515
*
1616
* Only required if you choose tls as "auth_type"
1717
*/
@@ -29,11 +29,10 @@
2929
* If "tls_verify_peer" is set to true, request handler verifies whether the certificate is authentic.
3030
* This trust is based on a chain of digital signatures,
3131
* rooted in certification authority (CA) certificates you supply using the "tls_ca_cert_path" setting below.
32-
*
3332
*/
3433
'tls_verify_peer' => true,
3534

36-
/** Absolute path to the CA used to process peer verification
35+
/** Absolute path to the CA used to process peer verification.
3736
*
3837
* Only required if you choose tls as "auth_type" and "tls_verify_peer" is true
3938
*/
@@ -43,25 +42,22 @@
4342
*
4443
* Key generated by the cscli (CrowdSec cli) command like "cscli bouncers add bouncer-php-library"
4544
* Only required if you choose api_key as "auth_type"
46-
*
4745
*/
4846
'api_key' => 'YOUR_BOUNCER_API_KEY',
4947

5048
/** Define the URL to your LAPI server, default to http://localhost:8080.
5149
*
5250
* If you have installed the CrowdSec agent on your server, it should be "http://localhost:8080" or
5351
* "https://localhost:8080"
54-
*
5552
*/
56-
'api_url'=> Constants::DEFAULT_LAPI_URL,
53+
'api_url' => Constants::DEFAULT_LAPI_URL,
5754

5855
// In seconds. The timeout when calling LAPI. Must be greater or equal than 1. Defaults to 1 sec.
59-
'api_timeout'=> 1,
56+
'api_timeout' => 1,
6057

6158
/**
6259
* By default, the lib call the REST LAPI using file_get_contents method (allow_url_fopen is required).
63-
* Set 'use_curl' to true in order to use cURL request instead (curl is in then required)
64-
*
60+
* Set 'use_curl' to true in order to use cURL request instead (curl is in then required).
6561
*/
6662
'use_curl' => false,
6763

@@ -74,7 +70,7 @@
7470
*
7571
* Important note: be sur this path won't be publicly accessible
7672
*/
77-
'log_directory_path' => __DIR__.'/.logs',
73+
'log_directory_path' => __DIR__ . '/.logs',
7874

7975
// true to stop the process and display errors if any.
8076
'display_errors' => false,
@@ -89,7 +85,6 @@
8985
*
9086
* If not empty, it will be used instead of the real forwarded ip.
9187
* If set to "no_forward", the x-forwarded-for mechanism will not be used at all.
92-
*
9388
*/
9489
'forced_test_forwarded_ip' => '',
9590

@@ -107,14 +102,14 @@
107102
*
108103
* Handle unknown remediations as.
109104
*/
110-
'fallback_remediation'=> Constants::REMEDIATION_CAPTCHA,
105+
'fallback_remediation' => Constants::REMEDIATION_CAPTCHA,
111106

112107
/** Select from 'bypass' (minimum remediation),'captcha' or 'ban' (maximum remediation).
113108
* Default to 'ban'.
114109
*
115110
* Cap the remediation to the selected one.
116111
*/
117-
'max_remediation_level'=> Constants::REMEDIATION_BAN,
112+
'max_remediation_level' => Constants::REMEDIATION_BAN,
118113

119114
/** If you use a CDN, a reverse proxy or a load balancer, set an array of IPs.
120115
*
@@ -123,18 +118,18 @@
123118
'trust_ip_forward_array' => [],
124119

125120
/**
126-
* array of URIs that will not be bounced
121+
* array of URIs that will not be bounced.
127122
*/
128123
'excluded_uris' => ['/favicon.ico'],
129124

130125
// Select from 'phpfs' (File system cache), 'redis' or 'memcached'.
131126
'cache_system' => Constants::CACHE_SYSTEM_PHPFS,
132127

133-
/** Will be used only if you choose File system as cache_system
128+
/** Will be used only if you choose File system as cache_system.
134129
*
135130
* Important note: be sur this path won't be publicly accessible
136131
*/
137-
'fs_cache_path' => __DIR__.'/.cache',
132+
'fs_cache_path' => __DIR__ . '/.cache',
138133

139134
// Will be used only if you choose Redis cache as cache_system
140135
'redis_dsn' => 'redis://localhost:6379',
@@ -143,16 +138,16 @@
143138
'memcached_dsn' => 'memcached://localhost:11211',
144139

145140
// Set the duration we keep in cache the fact that an IP is clean. In seconds. Defaults to 5.
146-
'clean_ip_cache_duration'=> Constants::CACHE_EXPIRATION_FOR_CLEAN_IP,
141+
'clean_ip_cache_duration' => Constants::CACHE_EXPIRATION_FOR_CLEAN_IP,
147142

148143
// Set the duration we keep in cache the fact that an IP is bad. In seconds. Defaults to 20.
149-
'bad_ip_cache_duration'=> Constants::CACHE_EXPIRATION_FOR_BAD_IP,
144+
'bad_ip_cache_duration' => Constants::CACHE_EXPIRATION_FOR_BAD_IP,
150145

151146
// Set the duration we keep in cache the captcha flow variables for an IP. In seconds. Defaults to 86400.
152-
'captcha_cache_duration'=> Constants::CACHE_EXPIRATION_FOR_CAPTCHA,
147+
'captcha_cache_duration' => Constants::CACHE_EXPIRATION_FOR_CAPTCHA,
153148

154149
// Set the duration we keep in cache a geolocation result for an IP . In seconds. Defaults to 86400.
155-
'geolocation_cache_duration'=> Constants::CACHE_EXPIRATION_FOR_GEO,
150+
'geolocation_cache_duration' => Constants::CACHE_EXPIRATION_FOR_GEO,
156151

157152
/** true to enable stream mode, false to enable the live mode. Default to false.
158153
*
@@ -165,7 +160,7 @@
165160
* visitors. Besides, if your site has a lot of unique visitors at the same time, this will not influence the
166161
* traffic to the API of your CrowdSec instance.
167162
*/
168-
'stream_mode'=> false,
163+
'stream_mode' => false,
169164

170165
// Settings for geolocation remediation (i.e. country based remediation).
171166
'geolocation' => [
@@ -187,10 +182,10 @@
187182
'database_type' => Constants::MAXMIND_COUNTRY,
188183
// Absolute path to the MaxMind database (mmdb file).
189184
'database_path' => '/some/path/GeoLite2-Country.mmdb',
190-
]
185+
],
191186
],
192187

193-
//true to hide CrowdSec mentions on ban and captcha walls.
188+
// true to hide CrowdSec mentions on ban and captcha walls.
194189
'hide_mentions' => false,
195190

196191
// Settings for ban and captcha walls

scripts/public/protected-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
<p>In this example page, if you can see this text, the bouncer considers your IP as clean.</p>
1414
</body>
1515
</html>
16-
';
16+
';

tools/coding-standards/php-cs-fixer/.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
PhpCsFixer\Finder::create()
2424
->in(__DIR__ . '/../../../src')->exclude(['templates'])
2525
->in(__DIR__ . '/../../../tests/Integration')->depth(1)
26+
->in(__DIR__ . '/../../../scripts')
2627
)
2728
;

0 commit comments

Comments
 (0)