Skip to content

Fix the findings of the code review - #332

Merged
codeling merged 1 commit into
mainfrom
ccr-22effcac-l12906
Nov 21, 2026
Merged

codeling merged 1 commit into
mainfrom
ccr-22effcac-l12906

Conversation

@codeling

Copy link
Copy Markdown
Owner

This fixes all the findings of a review of the plugin, library, component, package and CI code. It has tests for each fix. Four larger refactors are left out on purpose and tracked as #328, #329, #330 and #331.

Bugs

  • Unblock mail with an empty token: UnblockTokenRepository::add() returns null when it fails, and the plugin used to mail …&token= anyway. It now sends no mail and logs an error. A failure of random_bytes() is caught too.
  • Email logins and other spellings: failed logins typed with the account's email address, or in another case (PostgreSQL), now get the account's unblock mail. The new UserRepository::accountByLogin() matches as accountExists() and Joomla do; a disabled account gets no mail. The account's successful login now also marks those failures as handled (markHandled() takes several names and ignores case).
  • "All" showed nothing: in the list of the .htaccess file, "All" (limit 0) shows every entry now instead of none.
  • Error logged on every block: without a notification address, blocks no longer log an ERROR, and the notifier no longer counts anything.
  • Negative block durations: a duration below 0 is unlimited everywhere, as BlockPolicy::realDuration() already said. Before, the lookup took it for a block that was never active. BlockTable::check() refuses a duration below 0 minutes or one that isn't a whole number, and a start that isn't a date.
  • Settings page crash: an empty or broken manifest_cache no longer throws a TypeError there (VersionHelper::getVersion()).
  • Error pages from list tasks: the list controllers are BaseControllers now. The publish, delete, checkin… tasks they inherited from AdminController called methods the list models don't have.
  • .htaccess form:
    • "Save" and "New" are offered by the same check the save makes (HtblockController::mayAdd(): core.create and core.admin).
    • The form validates with its own fields (htblock, not block).
    • Entries are stored in canonical form.

Hardening

  • Removed TokenunblockModel::unblock(): it unblocked without confirmation and without the address check.
  • Hand-written <If> blocks in the block section are kept intact by every change and by the uninstallation. Before, any <If> line was taken for one of the plugin's own. A test checks that the copy of this logic in updatescript.php agrees with HtaccessHelper.
  • README: a section on what the delays and the account throttle can and can't do against parallel attackers.
  • dependencies.yml: composer runs in a job without write permissions. A separate job opens the issue, and only when a check found something, not on a network error.

Clean-up

  • Setting defaults: every default is in Settings::Defaults, read with Settings::get(), int(), bool() or string(). Unknown names throw. SettingsDefaultsTest compares the defaults with the form in both directions and fails on any inline default.
  • Lock files: all six places name their files through LockHelper::file(), slot() and directory().
  • Form rules return their error as the exception Joomla's Form shows, instead of posting a message on top of Joomla's own. The phpstan baseline entries for this pattern are replaced by one documented ignoreErrors rule.
  • Removed dead code: edit403Message() and remove403Message(), DateRule, UnblockTokenRepository::exists(), the unused block-state helpers in the .htaccess list view, and the backend's Itemid.
  • Duplicates removed: the component now uses the library's Origin::name() and IpHelper::prefixMask().
  • Smaller fixes:
    • An update that can't migrate the settings tells the administrator; it used to swallow the exception silently.
    • Known addresses are upserted, so two logins at once no longer race into a unique-key error.
    • Group notifications skip disabled accounts.
    • The log sorts priorities by severity, not alphabetically.
    • plugin/deploy.sh copies every language, not just two.

Requirements and CI

  • PHP 8.2 is the minimum: install scripts, update server php_minimum, composer platform and lock, phpstan phpVersion, README, and the unit-test matrix (which now runs the unit tests on the minimum too).
  • Database images pinned by digest: a new digest field in tests/ci/matrix.json, checked by check-joomla-checksums.php. PostgreSQL 15 replaces the end-of-life 12. MySQL 8.0 stays because it is Joomla 5.4's minimum.

Testing

  • Locally, on Joomla 6.2.0 with PostgreSQL 16 and PHP 8.3: the full phpunit suite passes, 714 tests with 14 skipped for environment reasons (no php-cgi, MySQL-only, running as root, upgrade suite). The site was installed from the package package/build.sh built.
  • phpstan finds no errors. The language, workflow, version and checksum lints pass, as does composer validate --strict.
  • MySQL/MariaDB, Joomla 5.4 and the Apache job only run in CI.

Translations for the three new language strings are included for all ten languages.


Generated by Claude Code

Bugs
- The unblock mail is no longer sent with an empty token when the token
  can't be stored (or made).
- Failed logins typed with the email address or in another case get the
  account's unblock mail (UserRepository::accountByLogin(), matched as
  accountExists() and Joomla do; none for a disabled account) and are
  marked handled by the account's successful login.
- "All" in the list of the .htaccess file shows every entry, not none.
- Without a notification address, blocks no longer log an error (and
  count nothing).
- A block duration below 0 is unlimited everywhere, as
  BlockPolicy::realDuration() has it; the block form takes 0 or more
  minutes and a valid start.
- A broken manifest cache no longer breaks the settings page.
- The list controllers are BaseControllers: AdminController's tasks
  called methods the list models haven't got.
- "Save"/"New" of the .htaccess form are offered by the permissions the
  save needs; the form validates with its own fields and stores the entry
  in canonical form.

Hardening
- TokenunblockModel::unblock() (no confirmation, no address check) is gone.
- Hand-written <If> blocks in the block section are kept intact by every
  change and by the uninstallation.
- README: what the delays can and can't do.
- dependencies.yml runs composer without write permissions; only a check
  that found something opens the issue.

Clean-up
- Every setting's default is in Settings::Defaults, read with
  Settings::get()/int()/bool()/string() (a test checks the form both ways
  and that no code has a default of its own).
- Lock files are named by LockHelper::file()/slot() in one place.
- Form rules return their error instead of posting it.
- Removed: HtaccessHelper::edit403Message()/remove403Message(), DateRule,
  UnblockTokenRepository::exists(), the dead block-state helpers of the
  .htaccess list view, the Itemid of the backend links; the component
  uses the library's Origin::name() and network masks.
- An update which can't migrate the settings tells the administrator;
  known addresses are upserted; group notifications skip disabled
  accounts; the log sorts by severity; deploy.sh copies every language.

Requirements and CI
- PHP 8.2 is the minimum (install scripts, update server, composer, CI).
- The database images of the matrix are pinned by digest (checked by the
  lint), PostgreSQL 15 instead of the end-of-life 12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFJFMPAZ5sdZ5QCeaJpmfk
@codeling
codeling merged commit 053e2f0 into main Nov 21, 2026
20 checks passed
@codeling
codeling deleted the ccr-22effcac-l12906 branch November 21, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants