Skip to content

Commit

Permalink
feat(html): Change html method visibility to enable custom rendering (#…
Browse files Browse the repository at this point in the history
…131)

* feat(html): Change html method visibility to protected to enable custom rendering

* fix(doc): Fix hub link
  • Loading branch information
julienloizelet authored Jun 20, 2024
1 parent 6dec761 commit cb2338b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 21 deletions.
23 changes: 11 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,21 @@
on:
workflow_dispatch:
push:
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 +29,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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


:books: <a href="https://doc.crowdsec.net">Documentation</a>
:diamond_shape_with_a_dot_inside: <a href="https://hub.crowdsec.net">Hub</a>
:diamond_shape_with_a_dot_inside: <a href="https://app.crowdsec.net/hub/">Hub</a>
:speech_balloon: <a href="https://discourse.crowdsec.net">Discourse Forum</a>


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 cb2338b

Please sign in to comment.