elementor / static-html-output

Static HTML Output Plugin for WordPress
https://statichtmloutput.com
The Unlicense
124 stars 34 forks source link

Consider doing Sanity check before attempt of crawling & deployment #56

Open thegulshankumar opened 4 years ago

thegulshankumar commented 4 years ago

A user (like me) who want to accept guest post and comment wont hesitate keeping http-auth/IP protected development area and proxied with CF, there are some areas where things can improve

1. WP2Static should check if Development Area is reachable or not

For Cloudflare proxied Development Site

(But, why? There are chances when CF WAF settings can prevent crawling. If I am not wrong, they use Maxmind IP geo data. image It was considering Russia but my original Server Location was Singapore.

And, I had a rule to force JavaScript validation for all Russian visitors because so many incoming spam.

Result: I accidently blocked my server and caused failure of crawling message. Intrestingly, crawling was still in the progress (as I seen NGINX logs, it was just browser end failure of loading ajax requests) image

or, this can be avoided by hardcoded IP in the hosts file.

Hinting user to set up whitelist will allow free-road for crawling.

image

*example.com/wp-content/uploads/WP-STATIC-PROGRESS.txt* image

2. Is development site HTTP Auth protected?

3. Validate Deployment Credential before starting 'crawling ...' before user click on "Deploy" button

4. Validate Permission to ensure "Delete button" works

5. Introduce better error message when unable to deploy

root@example:/var/log/nginx# tail -f error.log
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>ngin (truncated...)
 in /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create()
#1 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#2 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler()
#3 /var/www/wordpress/wp-content/plugins/static-html-ou" while reading response header from upstream, client: MY.IP.ADD.RESS, server: example.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/wp-admin/admin.php?page=statichtmloutput"
2020/08/25 20:24:30 [error] 45280#45280: *212 FastCGI sent in stderr: "PHP message: WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query INSERT INTO flyingpress_statichtmloutput_crawl_log (url, note, status) VALUES  made by do_action('wp_ajax_wp_static_html_output_ajax'), WP_Hook->do_action, WP_Hook->apply_filters, static_html_output_ajax, StaticHTMLOutput\Controller->prepare_for_export, StaticHTMLOutput\Exporter->generateModifiedFileList, StaticHTMLOutput\CrawlLog::addUrlsPHP message: WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query INSERT INTO flyingpress_statichtmloutput_urls (url) VALUES  made by do_action('wp_ajax_wp_static_html_output_ajax'), WP_Hook->do_action, WP_Hook->apply_filters, static_html_output_ajax, StaticHTMLOutput\Controller->prepare_for_export, StaticHTMLOutput\Exporter->generateModifiedFileList, StaticHTMLOutput\CrawlQueue::addUrls" while reading response header from upstream, client: MY.IP.ADD.RESS, server: example.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/wp-admin/admin.php?page=statichtmloutput"

I feel this suggestion will help beginners to avoid client and proxy side common pitfalls.

Thanks

leonstafford commented 4 years ago

I initially had something like this in WP2Static V7 diagnostics, but removed it as wasn't smoothly implemented. So, I am in the same mindset of wanting such a check.

Related issue in WP2Static: https://github.com/WP2Static/wp2static/issues/309

I think that's still useful and captures the rate limiting issues. ie, rate limiting won't fail in the beginning, but after n requests in succession, so n successive failures seems a good point to throw this error. Either n successive or first n requests all failing.