Skip to content

Commit

Permalink
feat(html): Change html method visibility to protected to enable cust…
Browse files Browse the repository at this point in the history
…om rendering
  • Loading branch information
julienloizelet committed Jun 20, 2024
1 parent 6dec761 commit 705b310
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/markdown.yml → .github/workflows/doc-links.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

name: Markdown files test and update
permissions:
contents: read

name: Documentation links
jobs:
markdown-test-and-update:
name: Markdown files test and update
markdown-test:
name: Markdown files test
runs-on: ubuntu-latest
steps:

- name: Clone sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: extension

Expand All @@ -23,18 +32,11 @@ jobs:
with:
ruby-version: 2.6


- name: Check links in Markdown files
run: |
gem install awesome_bot
cd extension
awesome_bot --files README.md --allow-dupe --allow 401 --skip-save-results --white-list ddev.site --base-url http://localhost:8080/
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/
- name: Generate table of contents
uses: technote-space/toc-generator@v4
with:
MAX_HEADER_LEVEL: 5
COMMIT_NAME: CrowdSec Dev Bot
TARGET_PATHS: 'docs/*.md'
CHECK_ONLY_DEFAULT_BRANCH: true
CREATE_PR: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ scripts/auto-prepend/.cache
scripts/**/*.log

# MaxMind databases
*.mmdb
*.mmdb
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/) and th

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.

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.

---

## [2.2.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v2.2.0) - 2024-06-20
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v2.1.0...v2.2.0)


### Changed

- Change the visibility of `AbstractBouncer::getBanHtml` and `AbstractBouncer::getCaptchaHtml` to `protected` to enable custom html rendering implementation


---


Expand Down
23 changes: 21 additions & 2 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- [Use the web container to call LAPI](#use-the-web-container-to-call-lapi)
- [Commit message](#commit-message)
- [Allowed message `type` values](#allowed-message-type-values)
- [Update documentation table of contents](#update-documentation-table-of-contents)
- [Release process](#release-process)

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


```bash
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
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
```

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

## Update documentation table of contents

To update the table of contents in the documentation, you can use [the `doctoc` tool](https://github.com/thlorenz/doctoc).

First, install it:

```bash
npm install -g doctoc
```

Then, run it in the documentation folder:

```bash
doctoc docs/*
```


## Release process

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

Note that the GitHub action will fail if the tag `tag_name` already exits.


6 changes: 3 additions & 3 deletions src/AbstractBouncer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class AbstractBouncer
public function __construct(
array $configs,
AbstractRemediation $remediationEngine,
LoggerInterface $logger = null
?LoggerInterface $logger = null
) {
// @codeCoverageIgnoreStart
if (!$logger) {
Expand Down Expand Up @@ -513,7 +513,7 @@ private function displayCaptchaWall(string $ip): void
*
* @return string The HTML compiled template
*/
private function getBanHtml(): string
protected function getBanHtml(): string
{
$template = new Template('ban.html.twig');

Expand All @@ -528,7 +528,7 @@ private function getCache(): AbstractCache
/**
* Returns a default "CrowdSec Captcha (401)" HTML template.
*/
private function getCaptchaHtml(
protected function getCaptchaHtml(
bool $error,
string $captchaImageSrc,
string $captchaResolutionFormUrl
Expand Down
4 changes: 2 additions & 2 deletions tools/coding-standards/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"phpstan/phpstan": "^1.8.0",
"phpmd/phpmd": "^2.12.0",
"squizlabs/php_codesniffer": "3.7.1",
"vimeo/psalm": "^4.24.0",
"vimeo/psalm": "^4.24.0 || ^5.25.0",
"phpunit/phpunit": "^9.3",
"phpunit/php-code-coverage": "^9.2.15",
"mikey179/vfsstream": "^1.6.11",
Expand All @@ -22,4 +22,4 @@
"url": "../../"
}
}
}
}

0 comments on commit 705b310

Please sign in to comment.