Skip to content

Commit 350cc75

Browse files
authored
Merge pull request #33 from WebDecoy/chore/wporg-build
chore: 2.2.1 — WordPress.org-compliant build
2 parents 239bf74 + 360f832 commit 350cc75

8 files changed

Lines changed: 323 additions & 229 deletions

File tree

RELEASING.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ Update the version string in **all** of these:
1515
The SDK `User-Agent` derives from `WEBDECOY_VERSION` automatically — nothing to
1616
bump there.
1717

18+
## Two distribution channels / two builds
19+
20+
There are two builds from one codebase:
21+
22+
- **CDN / self-hosted**`./build.sh <version>``dist/webdecoy-<version>.zip`. Includes the self-hosted updater (`includes/class-webdecoy-updater.php`) and the bundled clearance client (`public/js/webdecoy-clearance.js`). This is what `release.sh` builds and uploads to the CDN.
23+
- **WordPress.org**`./build.sh <version> --org``dist/webdecoy-<version>-wporg.zip`. Strips the self-updater (the directory forbids self-updating plugins) and the minified clearance client, and drops CDN release tooling. This is what you submit to / commit to WordPress.org SVN. Chart.js is bundled locally in both builds.
24+
1825
## 2. Build + prepare CDN metadata
1926

2027
```bash
21-
./release.sh <version> # e.g. ./release.sh 2.2.0
28+
./release.sh <version> # e.g. ./release.sh 2.2.1 (CDN build)
2229
```
2330

2431
This runs `build.sh`, produces `dist/webdecoy-<version>.zip`, and regenerates

admin/js/vendor/chart.umd.min.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.sh

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,36 @@
55
# Creates a distributable ZIP file for the WordPress plugin
66
# that can be uploaded to a CDN or WordPress marketplace.
77
#
8-
# Usage: ./build.sh [version]
9-
# Example: ./build.sh 1.0.0
8+
# Usage: ./build.sh [version] [--org]
9+
# Example: ./build.sh 2.2.0 # CDN / self-hosted build (includes self-updater + clearance client)
10+
# ./build.sh 2.2.0 --org # WordPress.org build (strips both — .org guideline compliance)
1011
#
1112

1213
set -e
1314

1415
# Configuration
1516
PLUGIN_SLUG="webdecoy"
16-
VERSION="${1:-1.0.0}"
1717
BUILD_DIR="./build"
1818
DIST_DIR="./dist"
1919

20-
echo "Building WebDecoy WordPress Plugin v${VERSION}"
20+
# Parse args: a --org flag anywhere selects the WordPress.org variant; the
21+
# remaining positional arg is the version.
22+
ORG_BUILD=0
23+
VERSION="1.0.0"
24+
for arg in "$@"; do
25+
case "$arg" in
26+
--org) ORG_BUILD=1 ;;
27+
*) VERSION="$arg" ;;
28+
esac
29+
done
30+
31+
if [ "$ORG_BUILD" = "1" ]; then
32+
ARTIFACT="${PLUGIN_SLUG}-${VERSION}-wporg"
33+
echo "Building WebDecoy WordPress Plugin v${VERSION} (WordPress.org variant)"
34+
else
35+
ARTIFACT="${PLUGIN_SLUG}-${VERSION}"
36+
echo "Building WebDecoy WordPress Plugin v${VERSION}"
37+
fi
2138
echo "================================================"
2239

2340
# Clean previous builds
@@ -56,30 +73,45 @@ find "${BUILD_DIR}" -name "phpcs.xml*" -exec rm -f {} + 2>/dev/null || true
5673
find "${BUILD_DIR}" -name ".phpcs*" -exec rm -f {} + 2>/dev/null || true
5774
find "${BUILD_DIR}" -name "tests" -type d -exec rm -rf {} + 2>/dev/null || true
5875

59-
# Create ZIP file
76+
# WordPress.org variant: strip the self-hosted update mechanism (forbidden on
77+
# .org) and the bundled minified clearance client, plus CDN release tooling.
78+
if [ "$ORG_BUILD" = "1" ]; then
79+
echo "Applying WordPress.org adjustments (removing self-updater + clearance client + CDN tooling)..."
80+
rm -f "${BUILD_DIR}/${PLUGIN_SLUG}/includes/class-webdecoy-updater.php"
81+
rm -f "${BUILD_DIR}/${PLUGIN_SLUG}/public/js/webdecoy-clearance.js"
82+
rm -rf "${BUILD_DIR}/${PLUGIN_SLUG}/cdn-files"
83+
rm -f "${BUILD_DIR}/${PLUGIN_SLUG}/release.sh"
84+
rm -rf "${BUILD_DIR}/${PLUGIN_SLUG}/bin"
85+
fi
86+
87+
# Create ZIP file (folder inside is always the slug, as WordPress requires)
6088
echo "Creating ZIP archive..."
6189
cd "${BUILD_DIR}"
62-
zip -r "../${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip" "${PLUGIN_SLUG}" -x "*.DS_Store" -x "*__MACOSX*"
90+
zip -r "../${DIST_DIR}/${ARTIFACT}.zip" "${PLUGIN_SLUG}" -x "*.DS_Store" -x "*__MACOSX*"
6391
cd - > /dev/null
6492

6593
# Generate checksums
6694
echo "Generating checksums..."
6795
cd "${DIST_DIR}"
68-
shasum -a 256 "${PLUGIN_SLUG}-${VERSION}.zip" > "${PLUGIN_SLUG}-${VERSION}.zip.sha256"
69-
md5 -q "${PLUGIN_SLUG}-${VERSION}.zip" > "${PLUGIN_SLUG}-${VERSION}.zip.md5"
96+
shasum -a 256 "${ARTIFACT}.zip" > "${ARTIFACT}.zip.sha256"
97+
md5 -q "${ARTIFACT}.zip" > "${ARTIFACT}.zip.md5"
7098
cd - > /dev/null
7199

72100
# Calculate file size
73-
FILE_SIZE=$(ls -lh "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip" | awk '{print $5}')
101+
FILE_SIZE=$(ls -lh "${DIST_DIR}/${ARTIFACT}.zip" | awk '{print $5}')
74102

75103
echo ""
76104
echo "Build complete!"
77105
echo "================================================"
78-
echo "Output: ${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip"
106+
echo "Output: ${DIST_DIR}/${ARTIFACT}.zip"
79107
echo "Size: ${FILE_SIZE}"
80108
echo ""
81109
echo "Checksums:"
82-
cat "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip.sha256"
83-
echo "MD5: $(cat "${DIST_DIR}/${PLUGIN_SLUG}-${VERSION}.zip.md5")"
110+
cat "${DIST_DIR}/${ARTIFACT}.zip.sha256"
111+
echo "MD5: $(cat "${DIST_DIR}/${ARTIFACT}.zip.md5")"
84112
echo ""
85-
echo "Upload to CDN or WordPress.org for distribution"
113+
if [ "$ORG_BUILD" = "1" ]; then
114+
echo "WordPress.org submission ZIP — self-updater + clearance client excluded."
115+
else
116+
echo "Upload to CDN for self-hosted distribution."
117+
fi

cdn-files/plugin-info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "WebDecoy Bot Detection",
33
"slug": "webdecoy",
4-
"version": "2.1.0",
4+
"version": "2.2.1",
55
"author": "<a href=\"https://webdecoy.com\">WebDecoy</a>",
66
"author_profile": "https://webdecoy.com",
77
"requires": "5.6",
88
"tested": "6.7",
99
"requires_php": "7.4",
10-
"download_url": "https://cdn.webdecoy.com/wordpress/webdecoy-2.1.0.zip",
10+
"download_url": "https://cdn.webdecoy.com/wordpress/webdecoy-2.2.1.zip",
1111
"sections": {
1212
"description": "<p>WebDecoy provides enterprise-grade bot detection and fraud protection for WordPress websites. Unlike simple CAPTCHA solutions, WebDecoy uses a layered defense approach that analyzes visitors from multiple angles — including deterministic tripwires that catch scanners with zero false positives.</p><h4>Key Features</h4><ul><li>Deterministic tripwires (hidden honeypot paths) — zero-false-positive bot blocking</li><li>Server-side and client-side bot detection</li><li>Invisible proof-of-work challenge (no external CAPTCHA service)</li><li>Comment, login, and registration spam protection</li><li>WooCommerce carding attack prevention</li><li>60+ good bots automatically allowed</li><li>AI crawler detection and blocking</li><li>Optional WebDecoy Cloud: centralized dashboard and rotation-proof device lockouts</li></ul>",
1313
"installation": "<ol><li>Upload the plugin files to <code>/wp-content/plugins/webdecoy</code></li><li>Activate the plugin through the Plugins menu</li><li>Tripwires and local protection are active out of the box — no API key required</li><li>Optionally go to WebDecoy &gt; Settings &gt; WebDecoy Cloud to connect for centralized monitoring and enforcement</li></ol>",

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*** WebDecoy Bot Detection Changelog ***
22

3+
= 2.2.1 - 2026-07-19 =
4+
* Changed: Chart.js is now bundled with the plugin instead of loaded from a CDN — no external requests for the admin charts
5+
* Changed: Clarified the External Services disclosure in readme
6+
* Internal: Refactored the self-hosted updater into its own module; added a WordPress.org build variant (build.sh --org) that excludes the self-updater and the cloud clearance client for directory-guideline compliance
7+
38
= 2.2.0 - 2026-07-19 =
49
* Added: IP allowlist — IPs or CIDR ranges that bypass all detection and blocking (Settings → Blocking). Previously the check existed internally but had no way to configure it.
510
* Changed: Consolidated onto a single detector path (SDK detector + WordPress-signal wrapper) across front-end, forms, and WooCommerce; removed the unused legacy forms class and a dead scheduled task. No behavior change to detection.
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
if (!defined('ABSPATH')) {
6+
exit;
7+
}
8+
9+
/**
10+
* Self-hosted update mechanism (CDN distribution ONLY).
11+
*
12+
* This lets self-hosted installs receive updates from cdn.webdecoy.com when the
13+
* WEBDECOY_SELF_HOSTED constant is defined. It is deliberately kept in its own
14+
* file and instantiated only under that constant.
15+
*
16+
* IMPORTANT: WordPress.org-distributed copies MUST NOT include this file.
17+
* The .org plugin guidelines prohibit a plugin serving its own updates — .org
18+
* is the sole update source there. `build.sh --org` removes this file, and the
19+
* main plugin guards the require with file_exists(), so its absence cleanly
20+
* disables self-hosted updating.
21+
*/
22+
class WebDecoy_Updater
23+
{
24+
public function __construct()
25+
{
26+
add_filter('pre_set_site_transient_update_plugins', [$this, 'check_for_updates']);
27+
add_filter('plugins_api', [$this, 'plugin_info'], 10, 3);
28+
// Verify the downloaded package's checksum before WordPress installs it.
29+
add_filter('upgrader_pre_download', [$this, 'verify_update_package'], 10, 3);
30+
}
31+
32+
/**
33+
* Check for updates against the CDN update manifest.
34+
*
35+
* @param object $transient Update transient
36+
* @return object Modified transient
37+
*/
38+
public function check_for_updates($transient)
39+
{
40+
if (empty($transient->checked)) {
41+
return $transient;
42+
}
43+
44+
$update_info = get_transient('webdecoy_update_info');
45+
46+
if ($update_info === false) {
47+
$response = wp_remote_get('https://cdn.webdecoy.com/wordpress/update-info.json', [
48+
'timeout' => 10,
49+
'headers' => [
50+
'Accept' => 'application/json',
51+
],
52+
]);
53+
54+
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
55+
return $transient;
56+
}
57+
58+
$update_info = json_decode(wp_remote_retrieve_body($response), true);
59+
60+
if (!$update_info || !isset($update_info['version'])) {
61+
return $transient;
62+
}
63+
64+
set_transient('webdecoy_update_info', $update_info, 12 * HOUR_IN_SECONDS);
65+
}
66+
67+
if (version_compare(WEBDECOY_VERSION, $update_info['version'], '<')) {
68+
// Host-pin the package URL: WordPress installs whatever is at
69+
// `package` with full privileges, so refuse any URL that is not an
70+
// HTTPS link on our own CDN (prevents a tampered manifest → RCE).
71+
$download_url = $update_info['download_url'] ?? '';
72+
if (!$this->is_trusted_package_url($download_url)) {
73+
return $transient;
74+
}
75+
76+
$transient->response[WEBDECOY_PLUGIN_BASENAME] = (object) [
77+
'slug' => 'webdecoy',
78+
'plugin' => WEBDECOY_PLUGIN_BASENAME,
79+
'new_version' => $update_info['version'],
80+
'package' => $download_url,
81+
'url' => $update_info['details_url'] ?? 'https://webdecoy.com/wordpress',
82+
'icons' => $update_info['icons'] ?? [],
83+
'banners' => $update_info['banners'] ?? [],
84+
'tested' => $update_info['tested'] ?? '',
85+
'requires_php' => $update_info['requires_php'] ?? '7.4',
86+
];
87+
}
88+
89+
return $transient;
90+
}
91+
92+
/**
93+
* Whether a package download URL is an HTTPS link on our own CDN host.
94+
*/
95+
private function is_trusted_package_url(string $url): bool
96+
{
97+
if ($url === '') {
98+
return false;
99+
}
100+
$parts = wp_parse_url($url);
101+
if (empty($parts['scheme']) || empty($parts['host'])) {
102+
return false;
103+
}
104+
return strtolower($parts['scheme']) === 'https'
105+
&& strtolower($parts['host']) === 'cdn.webdecoy.com';
106+
}
107+
108+
/**
109+
* Verify the integrity of the self-hosted update package before installation.
110+
*
111+
* @param bool|WP_Error $reply Short-circuit value (false to continue).
112+
* @param string $package The package URL being downloaded.
113+
* @param object $upgrader The upgrader instance.
114+
* @return bool|string|\WP_Error
115+
*/
116+
public function verify_update_package($reply, $package, $upgrader)
117+
{
118+
if (!is_string($package) || !$this->is_trusted_package_url($package)) {
119+
return $reply;
120+
}
121+
122+
$update_info = get_transient('webdecoy_update_info');
123+
$expected = is_array($update_info) ? ($update_info['sha256'] ?? '') : '';
124+
$expected = is_string($expected) ? strtolower(trim($expected)) : '';
125+
126+
if (!preg_match('/^[a-f0-9]{64}$/', $expected)) {
127+
return new \WP_Error(
128+
'webdecoy_no_checksum',
129+
__('WebDecoy update aborted: no valid checksum was provided for the package.', 'webdecoy')
130+
);
131+
}
132+
133+
if (!function_exists('download_url')) {
134+
require_once ABSPATH . 'wp-admin/includes/file.php';
135+
}
136+
137+
$tmp_file = download_url($package);
138+
if (is_wp_error($tmp_file)) {
139+
return $tmp_file;
140+
}
141+
142+
$actual = hash_file('sha256', $tmp_file);
143+
if (!hash_equals($expected, (string) $actual)) {
144+
wp_delete_file($tmp_file);
145+
return new \WP_Error(
146+
'webdecoy_checksum_mismatch',
147+
__('WebDecoy update aborted: package checksum did not match the expected value.', 'webdecoy')
148+
);
149+
}
150+
151+
return $tmp_file;
152+
}
153+
154+
/**
155+
* Plugin information for the update details popup.
156+
*
157+
* @param false|object|array $result
158+
* @param string $action
159+
* @param object $args
160+
* @return false|object
161+
*/
162+
public function plugin_info($result, $action, $args)
163+
{
164+
if ($action !== 'plugin_information' || !isset($args->slug) || $args->slug !== 'webdecoy') {
165+
return $result;
166+
}
167+
168+
$response = wp_remote_get('https://cdn.webdecoy.com/wordpress/plugin-info.json', [
169+
'timeout' => 10,
170+
'headers' => [
171+
'Accept' => 'application/json',
172+
],
173+
]);
174+
175+
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
176+
return $result;
177+
}
178+
179+
$info = json_decode(wp_remote_retrieve_body($response), true);
180+
181+
if (!$info) {
182+
return $result;
183+
}
184+
185+
return (object) [
186+
'name' => $info['name'] ?? 'WebDecoy Bot Detection',
187+
'slug' => 'webdecoy',
188+
'version' => $info['version'] ?? WEBDECOY_VERSION,
189+
'author' => $info['author'] ?? '<a href="https://webdecoy.com">WebDecoy</a>',
190+
'author_profile' => $info['author_profile'] ?? 'https://webdecoy.com',
191+
'requires' => $info['requires'] ?? '5.6',
192+
'tested' => $info['tested'] ?? '',
193+
'requires_php' => $info['requires_php'] ?? '7.4',
194+
'sections' => $info['sections'] ?? [
195+
'description' => 'Protect your WordPress site from bots, spam, and carding attacks.',
196+
'changelog' => $info['changelog'] ?? '',
197+
],
198+
'download_link' => $info['download_url'] ?? '',
199+
'banners' => $info['banners'] ?? [],
200+
'icons' => $info['icons'] ?? [],
201+
];
202+
}
203+
}

0 commit comments

Comments
 (0)