Skip to content

Commit 33ac5c4

Browse files
feat(*): Move log and cache files and add auto_prepend_file mode setting (#147)
* feat(log and cache): Move log and cache files in uploads/crowdsec folder * docs(user guide): Update doc for new log and cache directory * feat(multisite): Handle common upload folder for multisite * feat(*): Update composer dependencies * style(constant): Remove obsolete constants and rename one * feat(auto_prepend): Add auto_prepend_file mode option and use it to create the static standalone settings file * feat(auto_prepend-file): Log error in case there is no standalone setting file
1 parent 7b252e4 commit 33ac5c4

File tree

245 files changed

+2382
-1568
lines changed

Some content is hidden

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

245 files changed

+2382
-1568
lines changed

.cache/.gitignore

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

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ jobs:
7676
ddev get julienloizelet/ddev-crowdsec-php
7777
7878
- name: Start DDEV
79-
run: ddev start
79+
uses: nick-fields/retry@v3
80+
with:
81+
timeout_minutes: 5
82+
max_attempts: 3
83+
shell: bash
84+
command: |
85+
ddev start
8086
8187
- name: Download WordPress
8288
run: ddev wp core download --version=${{ matrix.wp-version }}
@@ -86,15 +92,15 @@ jobs:
8692
ddev wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
8793
8894
- name: Clone ${{ env.EXTENSION_NAME }} files
89-
uses: actions/checkout@v3
95+
uses: actions/checkout@v4
9096
with:
9197
path: ${{ env.EXTENSION_PATH }}
9298

9399
- name: Prepare for playwright test
94100
run: |
95101
mkdir -p crowdsec/tls
96102
mkdir -p crowdsec/geolocation
97-
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
103+
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
98104
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
99105
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
100106
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
@@ -142,6 +148,12 @@ jobs:
142148
exit 1
143149
fi
144150
151+
- name: Enable Plugin auto_prepend_file mode
152+
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
153+
with:
154+
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
155+
file_path: 10-enable-autoprependfile-mode.js
156+
145157
- name: Run Live mode remediation tests
146158
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
147159
with:

.github/workflows/end-to-end-multisite.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ jobs:
7878
ddev get julienloizelet/ddev-crowdsec-php
7979
8080
- name: Start DDEV
81-
run: ddev start
81+
uses: nick-fields/retry@v3
82+
with:
83+
timeout_minutes: 5
84+
max_attempts: 3
85+
shell: bash
86+
command: |
87+
ddev start
8288
8389
- name: Download WordPress
8490
run: ddev wp core download --version=${{ matrix.wp-version }}
@@ -96,15 +102,15 @@ jobs:
96102
ddev wp site create --slug="site2" --title="WordPress Site2"
97103
98104
- name: Clone ${{ env.EXTENSION_NAME }} files
99-
uses: actions/checkout@v3
105+
uses: actions/checkout@v4
100106
with:
101107
path: ${{ env.EXTENSION_PATH }}
102108

103109
- name: Prepare for playwright test
104110
run: |
105111
mkdir -p crowdsec/tls
106112
mkdir -p crowdsec/geolocation
107-
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
113+
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
108114
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
109115
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
110116
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ jobs:
7676
ddev get julienloizelet/ddev-crowdsec-php
7777
7878
- name: Start DDEV
79-
run: ddev start
79+
uses: nick-fields/retry@v3
80+
with:
81+
timeout_minutes: 5
82+
max_attempts: 3
83+
shell: bash
84+
command: |
85+
ddev start
8086
8187
- name: Download WordPress
8288
run: ddev wp core download --version=${{ matrix.wp-version }}
@@ -86,15 +92,15 @@ jobs:
8692
ddev wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
8793
8894
- name: Clone ${{ env.EXTENSION_NAME }} files
89-
uses: actions/checkout@v3
95+
uses: actions/checkout@v4
9096
with:
9197
path: ${{ env.EXTENSION_PATH }}
9298

9399
- name: Prepare for playwright test
94100
run: |
95101
mkdir -p crowdsec/tls
96102
mkdir -p crowdsec/geolocation
97-
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
103+
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
98104
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
99105
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
100106
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation

.github/workflows/markdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414

1515
- name: Clone sources
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
with:
1818
path: extension
1919

.github/workflows/release-test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ jobs:
8181
ddev get julienloizelet/ddev-crowdsec-php
8282
8383
- name: Start DDEV
84-
run: ddev start
84+
uses: nick-fields/retry@v3
85+
with:
86+
timeout_minutes: 5
87+
max_attempts: 3
88+
shell: bash
89+
command: |
90+
ddev start
8591
8692
- name: Download WordPress
8793
run: ddev wp core download --version=${{ matrix.wp-version }}
@@ -96,15 +102,15 @@ jobs:
96102
97103
- name: Clone files from last release
98104
if: github.event.inputs.check_head_zip != 'true'
99-
uses: actions/checkout@v3
105+
uses: actions/checkout@v4
100106
with:
101107
path: raw_sources
102108
ref: "v${{ env.LAST_TAG }}"
103109
repository: "${{ env.GITHUB_ORIGIN }}"
104110

105111
- name: Clone files from HEAD
106112
if: github.event.inputs.check_head_zip == 'true'
107-
uses: actions/checkout@v3
113+
uses: actions/checkout@v4
108114
with:
109115
path: raw_sources
110116

@@ -131,7 +137,7 @@ jobs:
131137
run: |
132138
mkdir -p crowdsec/tls
133139
mkdir -p crowdsec/geolocation
134-
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
140+
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
135141
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
136142
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
137143
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation

.github/workflows/release.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,21 @@ jobs:
4141
echo "VERSION_NUMBER=$(echo ${{ github.event.inputs.tag_name }} | sed 's/v//g' )" >> $GITHUB_ENV
4242
4343
- name: Clone sources
44-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
45+
46+
- name: Check standalone-settings exists and is empty
47+
run: |
48+
if [ ! -f inc/standalone-settings.php ]
49+
then
50+
echo "inc/standalone-settings.php does not exist"
51+
exit 1
52+
elif [ -s inc/standalone-settings.php ]
53+
then
54+
echo "inc/standalone-settings.php is not empty"
55+
exit 1
56+
else
57+
echo "inc/standalone-settings.php exists and is empty"
58+
fi
4559
4660
- name: Check version ${{ env.VERSION_NUMBER }} consistency in files
4761
# Check crowdsec.php (2), readme.txt (1), inc/Constants.php (1) and CHANGELOG.md (3)
@@ -111,7 +125,7 @@ jobs:
111125
fi
112126
113127
- name: Create Tag ${{ github.event.inputs.tag_name }}
114-
uses: actions/github-script@v6
128+
uses: actions/github-script@v7
115129
with:
116130
github-token: ${{ github.token }}
117131
script: |
@@ -222,7 +236,13 @@ jobs:
222236
ddev get julienloizelet/ddev-crowdsec-php
223237
224238
- name: Start DDEV
225-
run: ddev start
239+
uses: nick-fields/retry@v3
240+
with:
241+
timeout_minutes: 5
242+
max_attempts: 3
243+
shell: bash
244+
command: |
245+
ddev start
226246
227247
- name: Download WordPress
228248
run: ddev wp core download --version=${{ matrix.wp-version }}
@@ -236,7 +256,7 @@ jobs:
236256
echo "LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/${{ env.GITHUB_ORIGIN }}/releases/latest | grep -oP "\/tag\/v\K(.*)$")" >> $GITHUB_ENV
237257
238258
- name: Clone files from last release
239-
uses: actions/checkout@v3
259+
uses: actions/checkout@v4
240260
with:
241261
path: raw_sources
242262
ref: "v${{ env.LAST_TAG }}"
@@ -256,7 +276,7 @@ jobs:
256276
run: |
257277
mkdir -p crowdsec/tls
258278
mkdir -p crowdsec/geolocation
259-
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
279+
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
260280
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
261281
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
262282
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ node_modules/
1010

1111
# App
1212
*.log
13+
14+
# auto_prepend_file mode settings
1315
inc/standalone-settings.php

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [2.6.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.6.0) - 2024-03-14
9+
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.5.2...v2.6.0)
10+
11+
### Changed
12+
13+
- Move logs and cache folders to `wp-content/uploads/crowdsec` to avoid deletion on plugin update and pass checksum validation
14+
- Write `standalone-settings.php` file only if the new setting `Enable auto_prepend_file mode` is on.
15+
16+
### Added
17+
18+
- Add a `Enable auto_prepend_file mode` setting.
19+
20+
21+
---
22+
823

924
## [2.5.2](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.5.2) - 2023-11-23
1025
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.5.1...v2.5.2)

0 commit comments

Comments
 (0)