Repository navigation
Index the failed logins; unblock link to the site also after API logins; CI keeps its downloads - #266
Merged
Merged
Conversation
Every failed login counts the failed logins of its address within the
check interval (twice), a block lists them and checks which accounts
they went against, and the adaptive delay counts those of the last
hour - all without an index (only username_logtime existed), on a
table kept at up to 200000 rows.
Measured with the plugin's DatabaseHelper on 200000 rows (50000
addresses, a repeat offender), median of 50 runs, ms:
PostgreSQL 16 MariaDB 10.11
before after before after
count per address 8.87 0.18 21.64 0.32
other accounts of address 8.22 0.18 188.21 0.35
list of address 8.19 0.36 26.86 0.72
count of the last hour 8.07 0.16 18.38 0.15
insert of a failed login 1.37 1.31 0.82 0.88 (mean of 2x1000)
(ipaddress, handled, logtime) was no faster in a way that matters
(0.1 ms on MariaDB) and would have to be updated with every change of
"handled". The indexes are in both install scripts and in the 2.0.0
update (marked CAN FAIL, like username_logtime); tests check that they
exist after an installation and after the update from 1.5.2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
The link was Uri::base() with a trailing "administrator/" cut off. In the API, Uri::base() is .../api/, so an address blocked for failed API logins was mailed a link to api/index.php?option=com_bfstop&..., where there is no unblock page. Uri::root() is the site's address in every application. UnblockLinkTest builds the link in a script in each application's directory run through php-cgi (skipped without it): Joomla derives its addresses from the script name only outside the CLI, and PHP's built-in web server counts as CLI, so the fixtures couldn't show it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
Owner
Author
|
CI is red on this head ( I re-ran the failed jobs once. The first re-run to finish ("Update from the previous release (Joomla 5.4.10, mysql:8.0)") failed again with a 503 on the Joomla download. The rest are still running. The jobs that got past the download passed:
There's no fix for the outage itself. I'll keep watching the PR until all jobs are green. Generated by Claude Code |
Every integration and update job fetched its Joomla package (tens of megabytes) and, for the update, the previous BFStop release from GitHub again. The downloads now go through tests/ci/fetch-verified.sh, which takes a copy from DOWNLOAD_CACHE if its SHA-256 is the expected one (else downloads it again and replaces the copy), and retries a download a few times on transient errors (timeouts, 429, 5xx), honouring Retry-After. CI keeps that directory with actions/cache, per Joomla version (and previous release, for the update). Nothing which doesn't match the checksum is written to the target file, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Index the failed logins (
e29dab8)Every failed login counts the failed logins of its address within the check interval, twice. A block lists them and checks which accounts they went against, and the adaptive delay counts those of the last hour. None of these had an index: only
username_logtimeexisted, on a table kept at up to 200,000 rows.New indexes on
#__bfstop_failedlogin:(ipaddress, logtime)for the per-address lookups;(logtime)for the last hour and the purge by age.They are in both install scripts and in the 2.0.0 update, marked
CAN FAILlikeusername_logtime.Performance
Measured with the plugin's own
DatabaseHelperon 200,000 rows: 50,000 addresses with a few attempts each over 4 weeks, plus one repeat offender with 600 handled attempts and 9 fresh ones. Times in ms, median of 50 runs; inserts are the mean of 2 × 1000:The insert cost doesn't change measurably: the differences are within run-to-run noise. I also tried
(ipaddress, handled, logtime). It was at most 0.1 ms faster, on MariaDB, and that index would have to be updated wheneverhandledchanges.Tests
InstallTest::testLookupsOfFailedLoginsAreIndexedchecks the indexes after an installation, on PostgreSQL and MySQL alike.UpgradeTest::testFailedLoginsAreIndexed(CI) checks them after the update from 1.5.2.CAN FAILcovers).Unblock link from API logins (
bd6f5bd)The unblock mail's link was
Uri::base()with a trailingadministrator/cut off. In the API,Uri::base()is…/api/. So an address blocked for failed API logins (#265) got a link toapi/index.php?option=com_bfstop&view=tokenunblock…, where there is no unblock page. I confirmed this with a real API request throughphp-cgi.Uri::root()is the site's address in every application, so the link now uses that.UnblockLinkTestbuilds the link throughphp-cgiin each application's directory. Joomla only derives its addresses from the script name outside the CLI, and PHP's built-in web server counts as CLI, so the existing fixtures couldn't show the bug. The test fails with the old code for the API and passes now. It is skipped wherephp-cgiisn't installed. The CI runners have it, so it runs in every integration job.CI keeps its downloads (
a50cff5)Every integration and update job downloaded its Joomla package (tens of megabytes) from GitHub again, and the update job also downloaded BFStop 1.5.2. Both now go through the new
tests/ci/fetch-verified.sh:DOWNLOAD_CACHEset, a copy there is used if its SHA-256 is the expected one. Otherwise it is downloaded again and the copy is replaced.Retry-After.CI keeps
~/.cache/bfstop-ciwithactions/cache(pinned, v6.1.0). The key is the Joomla version, plus the hash ofprevious-release.sha256for the update. The component's CI gets the same in codeling/com_bfstop#34.On this PR's first run, every key missed: each job downloaded its packages, and one job per key saved them. The others log "another job may be creating this cache", which is a warning, not a failure. Later runs, and other branches once this is on
main, start from those copies.Checked locally: a cache miss downloads and caches the file. A hit works with the network cut off. A corrupted copy is detected, downloaded again and repaired. A wrong checksum exits 1 and writes no file. Without
DOWNLOAD_CACHEit works as before. A local server answering 503 twice and then the file made curl retry and succeed after theRetry-Afterdelay.The failures of the earlier run were 503/504 gateway errors on GitHub release downloads, not rate limiting. They also hit unrelated single requests from another network at the same time, and rate limiting would show up as 429 or 403.
Not changed
The link still uses the request's host unless Joomla's
$live_siteis set, just like Joomla's own password-reset mails. That needs a decision and is discussed separately.Testing
Local, Joomla 5.4.10 on PostgreSQL 16: 407 tests OK, 3 skipped for environment reasons (
--testsuite unit,integration).check-versions,check-workflows,php -land xmllint pass. CI is green on all 18 checks, including the MySQL/MariaDB sites and the upgrade from 1.5.2.🤖 Generated with Claude Code
https://claude.ai/code/session_01AFJFMPv7CSqgJJ93QJvYfL