Skip to content

Commit cb2338b

Browse files
feat(html): Change html method visibility to enable custom rendering (#131)
* feat(html): Change html method visibility to protected to enable custom rendering * fix(doc): Fix hub link
1 parent 6dec761 commit cb2338b

File tree

7 files changed

+52
-21
lines changed

7 files changed

+52
-21
lines changed
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
on:
22
workflow_dispatch:
3+
push:
4+
branches:
5+
- main
36

4-
name: Markdown files test and update
7+
permissions:
8+
contents: read
9+
10+
name: Documentation links
511
jobs:
6-
markdown-test-and-update:
7-
name: Markdown files test and update
12+
markdown-test:
13+
name: Markdown files test
814
runs-on: ubuntu-latest
915
steps:
1016

1117
- name: Clone sources
12-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1319
with:
1420
path: extension
1521

@@ -23,18 +29,11 @@ jobs:
2329
with:
2430
ruby-version: 2.6
2531

32+
2633
- name: Check links in Markdown files
2734
run: |
2835
gem install awesome_bot
2936
cd extension
3037
awesome_bot --files README.md --allow-dupe --allow 401 --skip-save-results --white-list ddev.site --base-url http://localhost:8080/
3138
awesome_bot docs/*.md --skip-save-results --allow-dupe --allow 401 --white-list ddev.site,https://crowdsec,php.net/supported-versions.php --base-url http://localhost:8080/docs/
3239
33-
- name: Generate table of contents
34-
uses: technote-space/toc-generator@v4
35-
with:
36-
MAX_HEADER_LEVEL: 5
37-
COMMIT_NAME: CrowdSec Dev Bot
38-
TARGET_PATHS: 'docs/*.md'
39-
CHECK_ONLY_DEFAULT_BRANCH: true
40-
CREATE_PR: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ scripts/auto-prepend/.cache
2424
scripts/**/*.log
2525

2626
# MaxMind databases
27-
*.mmdb
27+
*.mmdb

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/) and th
77

88
The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this library consists of all public or protected methods, properties and constants belonging to the `src` folder.
99

10+
As far as possible, we try to adhere to [Symfony guidelines](https://symfony.com/doc/current/contributing/code/bc.html#working-on-symfony-code) when deciding whether a change is a breaking change or not.
11+
12+
---
13+
14+
## [2.2.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.2.0) - 2024-06-20
15+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v2.1.0...v2.2.0)
16+
17+
18+
### Changed
19+
20+
- Change the visibility of `AbstractBouncer::getBanHtml` and `AbstractBouncer::getCaptchaHtml` to `protected` to enable custom html rendering implementation
21+
22+
1023
---
1124

1225

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
:books: <a href="https://doc.crowdsec.net">Documentation</a>
15-
:diamond_shape_with_a_dot_inside: <a href="https://hub.crowdsec.net">Hub</a>
15+
:diamond_shape_with_a_dot_inside: <a href="https://app.crowdsec.net/hub/">Hub</a>
1616
:speech_balloon: <a href="https://discourse.crowdsec.net">Discourse Forum</a>
1717

1818

docs/DEVELOPER.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- [Use the web container to call LAPI](#use-the-web-container-to-call-lapi)
3939
- [Commit message](#commit-message)
4040
- [Allowed message `type` values](#allowed-message-type-values)
41+
- [Update documentation table of contents](#update-documentation-table-of-contents)
4142
- [Release process](#release-process)
4243

4344
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -197,8 +198,7 @@ Finally, run
197198

198199

199200
```bash
200-
ddev exec BOUNCER_KEY=your-bouncer-key AGENT_TLS_PATH=/var/www/html/cfssl LAPI_URL=https://crowdsec:8080
201-
MEMCACHED_DSN=memcached://memcached:11211 REDIS_DSN=redis://redis:6379 /usr/bin/php ./my-code/crowdsec-bouncer-lib/vendor/bin/phpunit --testdox --colors --exclude-group ignore ./my-code/crowdsec-bouncer-lib/tests/Integration/AbstractBouncerTest.php
201+
ddev exec BOUNCER_KEY=your-bouncer-key AGENT_TLS_PATH=/var/www/html/cfssl LAPI_URL=https://crowdsec:8080 MEMCACHED_DSN=memcached://memcached:11211 REDIS_DSN=redis://redis:6379 /usr/bin/php ./my-code/crowdsec-bouncer-lib/vendor/bin/phpunit --testdox --colors --exclude-group ignore ./my-code/crowdsec-bouncer-lib/tests/Integration/AbstractBouncerTest.php
202202
```
203203

204204
For geolocation Unit Test, you should first put 2 free MaxMind databases in the `tests` folder : `GeoLite2-City.mmdb`
@@ -499,6 +499,23 @@ chmod +x .git/hooks/commit-msg
499499
- style (formatting; no production code change)
500500
- test (adding missing tests, refactoring tests; no production code change)
501501

502+
## Update documentation table of contents
503+
504+
To update the table of contents in the documentation, you can use [the `doctoc` tool](https://github.com/thlorenz/doctoc).
505+
506+
First, install it:
507+
508+
```bash
509+
npm install -g doctoc
510+
```
511+
512+
Then, run it in the documentation folder:
513+
514+
```bash
515+
doctoc docs/*
516+
```
517+
518+
502519
## Release process
503520

504521
We are using [semantic versioning](https://semver.org/) to determine a version number. To verify the current tag,
@@ -530,3 +547,5 @@ gh workflow run release.yml -f tag_name=vx.y.z
530547
```
531548

532549
Note that the GitHub action will fail if the tag `tag_name` already exits.
550+
551+

src/AbstractBouncer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class AbstractBouncer
4545
public function __construct(
4646
array $configs,
4747
AbstractRemediation $remediationEngine,
48-
LoggerInterface $logger = null
48+
?LoggerInterface $logger = null
4949
) {
5050
// @codeCoverageIgnoreStart
5151
if (!$logger) {
@@ -513,7 +513,7 @@ private function displayCaptchaWall(string $ip): void
513513
*
514514
* @return string The HTML compiled template
515515
*/
516-
private function getBanHtml(): string
516+
protected function getBanHtml(): string
517517
{
518518
$template = new Template('ban.html.twig');
519519

@@ -528,7 +528,7 @@ private function getCache(): AbstractCache
528528
/**
529529
* Returns a default "CrowdSec Captcha (401)" HTML template.
530530
*/
531-
private function getCaptchaHtml(
531+
protected function getCaptchaHtml(
532532
bool $error,
533533
string $captchaImageSrc,
534534
string $captchaResolutionFormUrl

tools/coding-standards/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"phpstan/phpstan": "^1.8.0",
66
"phpmd/phpmd": "^2.12.0",
77
"squizlabs/php_codesniffer": "3.7.1",
8-
"vimeo/psalm": "^4.24.0",
8+
"vimeo/psalm": "^4.24.0 || ^5.25.0",
99
"phpunit/phpunit": "^9.3",
1010
"phpunit/php-code-coverage": "^9.2.15",
1111
"mikey179/vfsstream": "^1.6.11",
@@ -22,4 +22,4 @@
2222
"url": "../../"
2323
}
2424
}
25-
}
25+
}

0 commit comments

Comments
 (0)