Skip to content

Commit

Permalink
feat(*): Move log and cache files and add auto_prepend_file mode sett…
Browse files Browse the repository at this point in the history
…ing (#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
  • Loading branch information
julienloizelet authored Mar 14, 2024
1 parent 7b252e4 commit 33ac5c4
Show file tree
Hide file tree
Showing 245 changed files with 2,382 additions and 1,568 deletions.
2 changes: 0 additions & 2 deletions .cache/.gitignore

This file was deleted.

18 changes: 15 additions & 3 deletions .github/workflows/end-to-end-auto-prepend-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ jobs:
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV
run: ddev start
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
shell: bash
command: |
ddev start
- name: Download WordPress
run: ddev wp core download --version=${{ matrix.wp-version }}
Expand All @@ -86,15 +92,15 @@ jobs:
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'
- name: Clone ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.EXTENSION_PATH }}

- name: Prepare for playwright test
run: |
mkdir -p crowdsec/tls
mkdir -p crowdsec/geolocation
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
Expand Down Expand Up @@ -142,6 +148,12 @@ jobs:
exit 1
fi
- name: Enable Plugin auto_prepend_file mode
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
file_path: 10-enable-autoprependfile-mode.js

- name: Run Live mode remediation tests
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/end-to-end-multisite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ jobs:
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV
run: ddev start
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
shell: bash
command: |
ddev start
- name: Download WordPress
run: ddev wp core download --version=${{ matrix.wp-version }}
Expand All @@ -96,15 +102,15 @@ jobs:
ddev wp site create --slug="site2" --title="WordPress Site2"
- name: Clone ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.EXTENSION_PATH }}

- name: Prepare for playwright test
run: |
mkdir -p crowdsec/tls
mkdir -p crowdsec/geolocation
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/end-to-end-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ jobs:
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV
run: ddev start
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
shell: bash
command: |
ddev start
- name: Download WordPress
run: ddev wp core download --version=${{ matrix.wp-version }}
Expand All @@ -86,15 +92,15 @@ jobs:
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'
- name: Clone ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.EXTENSION_PATH }}

- name: Prepare for playwright test
run: |
mkdir -p crowdsec/tls
mkdir -p crowdsec/geolocation
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:

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

Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ jobs:
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV
run: ddev start
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
shell: bash
command: |
ddev start
- name: Download WordPress
run: ddev wp core download --version=${{ matrix.wp-version }}
Expand All @@ -96,15 +102,15 @@ jobs:
- name: Clone files from last release
if: github.event.inputs.check_head_zip != 'true'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: raw_sources
ref: "v${{ env.LAST_TAG }}"
repository: "${{ env.GITHUB_ORIGIN }}"

- name: Clone files from HEAD
if: github.event.inputs.check_head_zip == 'true'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: raw_sources

Expand All @@ -131,7 +137,7 @@ jobs:
run: |
mkdir -p crowdsec/tls
mkdir -p crowdsec/geolocation
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@ jobs:
echo "VERSION_NUMBER=$(echo ${{ github.event.inputs.tag_name }} | sed 's/v//g' )" >> $GITHUB_ENV
- name: Clone sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check standalone-settings exists and is empty
run: |
if [ ! -f inc/standalone-settings.php ]
then
echo "inc/standalone-settings.php does not exist"
exit 1
elif [ -s inc/standalone-settings.php ]
then
echo "inc/standalone-settings.php is not empty"
exit 1
else
echo "inc/standalone-settings.php exists and is empty"
fi
- name: Check version ${{ env.VERSION_NUMBER }} consistency in files
# Check crowdsec.php (2), readme.txt (1), inc/Constants.php (1) and CHANGELOG.md (3)
Expand Down Expand Up @@ -111,7 +125,7 @@ jobs:
fi
- name: Create Tag ${{ github.event.inputs.tag_name }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
Expand Down Expand Up @@ -222,7 +236,13 @@ jobs:
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV
run: ddev start
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
shell: bash
command: |
ddev start
- name: Download WordPress
run: ddev wp core download --version=${{ matrix.wp-version }}
Expand All @@ -236,7 +256,7 @@ jobs:
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
- name: Clone files from last release
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: raw_sources
ref: "v${{ env.LAST_TAG }}"
Expand All @@ -256,7 +276,7 @@ jobs:
run: |
mkdir -p crowdsec/tls
mkdir -p crowdsec/geolocation
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-with-wordpress-load.php cache-actions.php
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City crowdsec/geolocation
ddev maxmind-download DEFAULT GeoLite2-Country crowdsec/geolocation
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ node_modules/

# App
*.log

# auto_prepend_file mode settings
inc/standalone-settings.php
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [2.6.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.6.0) - 2024-03-14
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.5.2...v2.6.0)

### Changed

- Move logs and cache folders to `wp-content/uploads/crowdsec` to avoid deletion on plugin update and pass checksum validation
- Write `standalone-settings.php` file only if the new setting `Enable auto_prepend_file mode` is on.

### Added

- Add a `Enable auto_prepend_file mode` setting.


---


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

0 comments on commit 33ac5c4

Please sign in to comment.