Skip to content

Commit 15b37f4

Browse files
Merge pull request #82 from julienloizelet/feature/clean-sources-update-doc-avoid-cli
feat(*): Do not bounce CLI and refactor all docs
2 parents 5ee7113 + 6ddc040 commit 15b37f4

File tree

91 files changed

+897
-7214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+897
-7214
lines changed

.distignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
/.cache
22
/.git
33
/.github
4-
/.vagrant
5-
/.vscode
6-
/docker
4+
/.githooks
75
/docs
86
/node_modules
9-
/scripts
107
/tests
118
/vendor/crowdsec/bouncer/vendor
129
/vendor/crowdsec/bouncer/tools
@@ -24,23 +21,16 @@
2421
/vendor/crowdsec/bouncer/phpstan.neon
2522
/vendor/crowdsec/bouncer/.github
2623
/vendor/crowdsec/.bouncer-key
27-
.editorconfig
28-
.env
29-
.env.example
3024
.gitignore
3125
.composer.json
3226
.composer.lock
33-
docker-compose.yml
3427
*.sh
3528
*.log
3629
README.md
3730
CHANGELOG.md
38-
.DS_Store
3931
composer.json
4032
composer.lock
4133
/logs/**
4234
**/*Test.php
43-
Vagrantfile
4435
.distignore
4536
.gitignore
46-
prettier.config.js

.editorconfig

Lines changed: 0 additions & 9 deletions
This file was deleted.

.env.example

Lines changed: 0 additions & 9 deletions
This file was deleted.

.githooks/commit-msg

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$1" ]; then
4+
echo "Missing argument (commit message). Did you try to run this manually?"
5+
exit 1
6+
fi
7+
8+
commitTitle="$(cat $1 | head -n1)"
9+
10+
# ignore merge
11+
if echo "$commitTitle" | grep -qE "^Merge"; then
12+
echo "Commit hook: ignoring merge"
13+
exit 0
14+
fi
15+
16+
# check commit message
17+
REGEX='^(feat|fix|docs|style|refactor|ci|test|chore|comment)\(.*\)\:.*'
18+
if ! echo "$commitTitle" | grep -qE ${REGEX}; then
19+
echo "Your commit title '$commitTitle' did not follow conventional commit message rules:"
20+
echo "Please comply with the regex ${REGEX}"
21+
exit 1
22+
fi
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: End-to-end auto-prepend-file mode test suite
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '**.md'
8+
workflow_dispatch:
9+
10+
jobs:
11+
end-to-end-auto-prepend-file-mode-test-suite:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
wp-version: [ "4.9", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8", "5.9" ]
16+
php-version: [ "7.2", "7.4", "8.0" ]
17+
exclude:
18+
- { php-version: "7.4", wp-version: "4.9" }
19+
- { php-version: "7.4", wp-version: "5.0" }
20+
- { php-version: "7.4", wp-version: "5.1" }
21+
- { php-version: "7.4", wp-version: "5.2" }
22+
- { php-version: "8.0", wp-version: "4.9" }
23+
- { php-version: "8.0", wp-version: "5.0" }
24+
- { php-version: "8.0", wp-version: "5.1" }
25+
- { php-version: "8.0", wp-version: "5.2" }
26+
- { php-version: "8.0", wp-version: "5.3" }
27+
- { php-version: "8.0", wp-version: "5.4" }
28+
- { php-version: "8.0", wp-version: "5.5" }
29+
30+
name: End-to-end auto-prepend-file mode test suite
31+
runs-on: ubuntu-latest
32+
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
33+
34+
env:
35+
EXTENSION_NAME: "CrowdSec_Bouncer"
36+
EXTENSION_PATH: "crowdsec-bouncer"
37+
38+
steps:
39+
40+
- name: Clone DDEV files
41+
uses: actions/checkout@v2
42+
with:
43+
path: .ddev
44+
repository: julienloizelet/ddev-wp
45+
46+
- name: Install DDEV
47+
env:
48+
DDEV_VERSION: v1.19.1
49+
run: |
50+
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
51+
sudo apt-get -qq update
52+
sudo apt-get -qq -y install libnss3-tools
53+
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
54+
bash install_ddev.sh ${{ env.DDEV_VERSION }}
55+
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
56+
rm install_ddev.sh
57+
58+
- name: Set WP_VERSION_CODE env
59+
# used in some directory path and conventional file naming
60+
# Example : 5.6.5 => wp565
61+
run: |
62+
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
63+
64+
65+
- name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
66+
run: |
67+
cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
68+
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
69+
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
70+
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71+
ddev start
72+
sudo chmod -R 777 ${{ github.workspace }}/wp-content
73+
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
74+
75+
- name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
76+
run: |
77+
wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
78+
tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
79+
cp -r wordpress/. ${{ github.workspace }}
80+
rm -rf wordpress
81+
rm wordpress-${{ matrix.wp-version }}.tar.gz
82+
83+
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
84+
run: |
85+
ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
86+
87+
88+
- name: Clone ${{ env.EXTENSION_NAME }} files
89+
uses: actions/checkout@v2
90+
with:
91+
path: my-own-modules/${{ env.EXTENSION_PATH }}
92+
93+
- name: Prepare for playwright test
94+
run: |
95+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
96+
chmod +x test-init.sh
97+
./test-init.sh
98+
chmod +x run-tests.sh
99+
100+
- name: Run Plugin activation tests
101+
run: |
102+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
103+
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
104+
105+
- name: Prepare auto-prepend-file mode test suite
106+
run: |
107+
cd ${{ github.workspace }}/.ddev
108+
ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
109+
ddev exec -s crowdsec cscli decisions delete --all
110+
111+
- name: Verify auto_prepend_file directive
112+
run: |
113+
cd ${{ github.workspace }}
114+
cp .ddev/custom_files/phpinfo.php phpinfo.php
115+
PREPENDVERIF=$(curl https://${{ env.WP_VERSION_CODE }}.ddev.site/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
116+
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#" ]]
117+
then
118+
echo "AUTO PREPEND FILE OK"
119+
else
120+
echo "AUTO PREPEND FILE KO"
121+
echo $PREPENDVERIF
122+
exit 1
123+
fi
124+
125+
- name: Run auto prepend mode test suite
126+
run: |
127+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
128+
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js ./__tests__/4-live-mode-cache.js ./__tests__/5-stream-mode.js ./__tests__/6-redis.js ./__tests__/7-memcached.js"

.github/workflows/end-to-end-test-suite.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ on:
55
- main
66
paths-ignore:
77
- '**.md'
8-
pull_request:
9-
branches:
10-
- main
11-
paths-ignore:
12-
- '**.md'
138
workflow_dispatch:
149

1510
jobs:
@@ -50,7 +45,7 @@ jobs:
5045

5146
- name: Install DDEV
5247
env:
53-
DDEV_VERSION: v1.18.2
48+
DDEV_VERSION: v1.19.1
5449
run: |
5550
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
5651
sudo apt-get -qq update
@@ -73,6 +68,7 @@ jobs:
7368
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
7469
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
7570
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71+
mkdir wp-content
7672
ddev start
7773
sudo chmod -R 777 ${{ github.workspace }}/wp-content
7874
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
@@ -134,11 +130,4 @@ jobs:
134130
- name: Run Memcached tests
135131
run: |
136132
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
137-
./run-tests.sh ci "./__tests__/7-memcached.js"
138-
139-
- name: Run auto prepend mode test suite
140-
run: |
141-
cd ${{ github.workspace }}/.ddev
142-
ddev crowdsec-prepend-nginx
143-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
144-
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js ./__tests__/4-live-mode-cache.js ./__tests__/5-stream-mode.js ./__tests__/6-redis.js ./__tests__/7-memcached.js"
133+
./run-tests.sh ci "./__tests__/7-memcached.js"

.github/workflows/markdown.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
workflow_dispatch:
3+
4+
name: Markdown files test and update
5+
jobs:
6+
markdown-test-and-update:
7+
name: Markdown files test and update
8+
runs-on: ubuntu-latest
9+
steps:
10+
11+
- name: Clone sources
12+
uses: actions/checkout@v2
13+
with:
14+
path: extension
15+
16+
- name: Launch localhost server
17+
run: |
18+
sudo npm install --global http-server
19+
http-server ./extension &
20+
21+
- name: Set up Ruby 2.6
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: 2.6
25+
26+
- name: Check links in Markdown files
27+
run: |
28+
gem install awesome_bot
29+
cd extension
30+
awesome_bot --files README.md --allow-dupe --allow 401 --skip-save-results --white-list ddev.site,crowdsec --base-url http://localhost:8080/
31+
awesome_bot docs/*.md --skip-save-results --allow-dupe --allow 401 --white-list ddev.site,crowdsec --base-url http://localhost:8080/docs/
32+
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

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
![CrowdSec WordPress Bouncer](https://github.com/crowdsecurity/cs-wordpress-bouncer/raw/main/.wordpress-org/banner-1544x500.png "CrowdSec WordPress Bouncer")
44

5-
# Installation
5+
This WordPress plugin allows you to apply decisions from CrowdSec directly within the WordPress application.
66

7-
Please follow the [official documentation](https://docs.crowdsec.net/docs/next/bouncers/wordpress).
7+
8+
## Usage
9+
10+
See [User Guide](./docs/USER_GUIDE.md)
11+
12+
## Installation
13+
14+
See [Installation Guide](./docs/INSTALLATION_GUIDE.md)
15+
16+
17+
## Technical notes
18+
19+
See [Technical notes](./docs/TECHNICAL_NOTES.md)
20+
21+
## Developer guide
22+
23+
See [Developer guide](./docs/DEVELOPER.md)
24+
25+
26+
## License
27+
28+
[MIT](https://github.com/crowdsecurity/php-cs-bouncer/blob/main/LICENSE)

0 commit comments

Comments
 (0)