Repository navigation
Added
- Adapter contract tests: a template and a pattern,
stubs/contract/(issue #110). A port with several adapters is tested once, against all of them: the adapters are a Pest dataset (one row each), the contract is a file ofit()with->with('adapters'), and a new adapter is a new row; no abstract test class is needed (CONV-12 stays satisfied). The template is a worked example for a toy port (Store) with the three files to copy (Datasets/Contract.php,Datasets/Stores.php,StoreContractTest.php), andcontractCase()for a difference the contract found and nobody has decided yet: the case still runs, is reported as skipped with its reason while it fails, and fails the day it passes, so a fix cannot hide in the list.tests/Unit/ContractStubTest.phpruns a real Pest on the template (passes on good adapters, fails on a bad one, keeps a listed difference as a skip, fails on a listed difference that was fixed). The README has a chapter, the measured cost onmediaand the reason no static rule exists yet. Nothing runs by itself: no job, input or rule changes; a repository adds the suite to itsphpunit.xmlafter copying the files. - Four observed Semgrep rules follow what a request sends to a dangerous call: SEC-10 to SEC-13 (issue #108).
presets/semgrep/observed.ymlis back, with taint rules (inside one function, not across files) that run in a new Security patterns (observed) step ofpollora-qa check, observed by default so that it never blocks (the report has one step more: thejq lengthofci.ymlis now 14).pollora.sec-10.request-redirectreports a request value inwp_redirect(),redirect(),redirect()->away(),Redirect::to()or aLocationheader (open redirect;wp_validate_redirect(),home_url(),admin_url()and the like clear it);pollora.sec-11.request-http-callthe request as the URL ofwp_remote_get/post/head/request(),curl_init(),CURLOPT_URLorHttp::get()(SSRF;wp_safe_remote_*()andwp_http_validate_url()clear it, the body and the headers are not looked at);pollora.sec-12.request-paththe request as the path offile_get_contents(),include,readfile(),unlink(),fopen(),get_template_part()and the other file functions (traversal,php://;basename(),sanitize_file_name()and an allow-list clear it);pollora.sec-13.request-echothe request inecho,printf()orwp_die()withoutesc_*(reflected XSS;sanitize_text_field()is an input filter, not an escape). Sources:$_GET,$_POST,$_REQUEST,$_COOKIE, the request headers and URL of$_SERVER,filter_input(), and a Laravel request ($request->input(),request(), theRequestfacade). Measured over the 45 repositories (2,684 PHP files, Semgrep 1.186.0): 0 report, henceobserved; every use of the request in the ecosystem was read by hand (80 superglobal reads, 9wp_redirect, 10wp_remote_*, 4Http::, 4filter_input(), 12 Laravel reads) and none is an unvalidated flow. Not shipped: the syntactic "superglobal read withoutsanitize_*" rule (6 reports, 6 false positives), and four candidates already covered by SEC-02 (wp_ajax_nopriv_without a nonce), SEC-05 (extract), SEC-10 (header()) or by SEC-13. The fixtures test now runscommon.ymlandobserved.ymltogether, with annotated positive and negative cases for each rule. New:Plan::SEMGREP_OBSERVED, catalogue rules SEC-10 to SEC-13 (observed). - A template can carry an optional
.harness.json, read bytemplate.yml(#107). The skeleton and the themes have no file, so the type coverage floor of CONV-11 (measured: skeleton 88.3 %, theme-apiary 87.3 %) could not be recorded and a drop went unseen.template.ymlgains aRatchet (QA-01)job, last in the file, that looks for.harness.jsonor.github/harness.json(a directory the release archives leave out) and, only when one exists, checks the harness out, installs nikic/php-parser alone (nocomposer installof the template, no autoloader) and runs the newpollora-qa check --template: the ratchet of the file, with themodeinput of the workflow deciding whether a drop blocks (enforce) or reports (observe), andobserved: ratchetreporting it. The profile may be left out of the file (it is thentemplate;projectis accepted, any other is refused), a bad value or key names the file. Compatibility: a template without the file is checked exactly as before (the new job passes at once with a notice, no other job, name,needs,ifor input changes; the new job is skipped steps only). New:Plan::template(),HarnessConfig::loadForTemplate(),loadAny(),locateForTemplate(),TEMPLATE_FILE, and--config=FILEoncheck(with--template),ratchetandinit.ratchet --updaterecords in that file (never addsmode, keeps unknown keys), andinit --profile=templatenow writes only that file with the type coverage floor measured now, rounded down to a tenth, instead of the package scaffolding a template could not use; a package profile is unchanged. See A .harness.json for a template in the README. allow_rulesexempts some classes of a rule, not only the whole rule (classes). CONV-08 has hundreds of open classes in 20 repositories, a few of which are real extension points: exempting the rule would stop judging all of them. An entry may now carry"classes": ["Acme\\Models\\*", "Acme\\Foo"](a fully qualified class name or a namespace prefix ending in\\*, nothing else) for CONV-02, CONV-08 and CONV-09. The classes are removed from the problems of the rule and named (exempted: CONV-08 — <reason> — N classes: …, in a skipped test and in the notes of the Architecture and Tests and architecture gates); a pattern that matches no class, or none that the rule reports, is astale exemptionwarning (an incomplete test, never a failure); an exemption of anobservedrule stays declared, not applied. Several entries may name one rule; an entry limited to classes and a whole-rule entry for the same rule make the file invalid (InvalidConfig::ruleExemptionConflict), as do a bad pattern, an empty list, orclasseson another rule. Compatibility:classesis optional and additive; an entry without it, and every existing.harness.json, behave exactly as before (toArray()writes noclasseskey). New:Config\ClassPattern,Architecture\ClassExemptions,ExemptionEffect,Exempted.- A ratchet metric
exempted_classes: the (rule, class) pairs the per-class exemptions remove, lower is better. It counts a class only when the rule reports it, so afinalclass under an exempted namespace costs nothing and a new open class raises the figure and fails QA-01 against the recorded ceiling: a namespace prefix cannot widen unnoticed.exempted_ruleskeeps counting whole-rule entries only. Measured only in a repository that has aclassesentry or already records the key (unmeasuredotherwise), so an existing.harness.jsonis unchanged;ratchet --updaterecords and lowers it,--metric=exempted_classes:Nworks. - CONV-02 can be exempted (
allow_rules). It joinsRuleExemption::EXEMPTIBLEandPlan::ARCHITECTURE_RULES(the test that keeps them equal still holds); its status staysobserved. promote-reportmeasures many repositories in one run.pollora-qa promote-report <path>...or--root=<dir> [--only=a,b]prints a rule x repository matrix (text) or, with--json,{repositories, matrix}: for each repository the rows of the single report, its statictype_coverageand thefloorto record inratchet.type_coverage(rounded down to 0.1 point so that measurement noise cannot fail the ratchet), and one{rule, repository, verdict, count}cell per rule. A directory withoutcomposer.jsonisnot-applicable; an unreadable directory or an invalid.harness.jsonis named and gives status 1 (never counted clean). Without argument the report of the current repository is unchanged. The promotion study of the 45 repositories is now replayable without an agent.- Integration tests against a real WordPress: an optional
WordPress integrationjob inphp-package.yml. Three new optional inputs, all off or neutral by default:wordpress-integration(the suite directory, for exampletests/Integration; empty, the default, skips the job),wordpress-version(latest,nightlyor a version number) andwordpress-plugins(wordpress.org slugs). The job, namedWordPress integration PHP <version>, installs WordPress with WP-CLI against a digest-pinned MySQL 8.0 service container, caches the downloads, and starts thetest:integrationscript,phpunit.integration.xmlor the directory, on PHP 8.3 and 8.4, with a 20-minute timeout. It is skipped while the input is empty and no other job depends on it: no job name,needs,ifor input of the existing jobs changes.stubs/wordpress/holds the bootstrap, the PHPUnit configuration and a test that proves a real WordPress is loaded; the README explains the cost and when to turn it on.
Changed
- CONV-09, PERF-01 and PERF-07 are
enforced: they block inenforcemode for every repository that raises the harness to the next version. Measured withpromote-report --rootover the 36 directories of the ecosystem that have acomposer.json(read only, thegit statusof the 46 checkouts identical before and after): nowould-blockanywhere,CONV-09 cleanin 34 repositories (1 not applicable),PERF-01andPERF-07cleanin the framework, the only repository that declares budgets, andnot applicablein the 35 others. The framework's four facades (Option::forget(),PostType,Taxonomy,WordPressError) were fixed in its pull request #670, anddevelopreadsCONV-09 clean. CONV-09 passes from the incomplete (observed) block oftests/Arch.phpto the blocking one with the same message as the other rules, andallow_rulesexempts it whole or, withclasses, facade by facade. The Performance budgets step leavesPlan::OBSERVED_BY_DEFAULT: it fails like the other steps inenforcemode (a budget that went up, an invalid budgets file, nightly measures that are not wired), and staysskippedwith its reason, never a failure, in a repository that declares neither. The number of steps ofcheckdoes not change (13); a repository that stays on 0.1.34 is not affected. CONV-02, CONV-08, CONV-11 and CONV-12 stayobserved; the catalogue now counts 35 enforced, 4 observed and 1 planned rule. promote-reporttakes the per-class exemptions into account. The text saysCONV-08 would block (15 found, 12 exempted by allow_rules in 4 classes: 3 remaining)(orcleanwhen nothing remains) and lists the stale patterns. In the JSON,countis what remains after the exemptions (unchanged without any), and each row gainsfound,exempted_problems,exempted_classesandstale.
Fixed
-
The WordPress integration job no longer breaks on two defects found by deploying it on eleven packages. (1) The
wp-config.phpthe job generated definedDISABLE_WP_CRON(and theWP_DEBUG*constants) withoutdefined() ||, while the bootstrap template defines it beforewp-load.php: the Constant DISABLE_WP_CRON already defined warning failed the tests that compare the output of a sub-process and made Pest exit without a test. Every constant of the generatedwp-config.phpis now guarded, and the template guardsWP_USE_THEMEStoo. (2) Pest loadstests/Pest.phpandtests/Helpers/*before the PHPUnit bootstrap, so the doubles of WordPress they declare (WP_Error,wp_parse_args(),WP_CLI...) collided with the real WordPress (Cannot redeclare class WP_Error, exit 255 without a message). Without atest:integrationscript, the job now runspest --test-directory=<wordpress-integration> -c phpunit.integration.xml; the templates carry the command, a newstubs/wordpress/unit-bootstrap.php.stub(where the doubles go:tests/bootstrap.php, referenced byphpunit.xml.dist) and a README chapter on whyPest.phpmust not declare them. The comment ofphpunit.integration.xml.stubis checked as well-formed XML. Compatibility: a repository that does not turn the input on sees no change (same jobs, names,needsandif); one that does and has atest:integrationscript runs the same command as before.tests/Unit/WordPressIntegrationRunTest.phpruns the generatedwp-config.phpconstants, the template bootstrap and the step's command in a project against a fakewp-load.php(three of its tests fail without the correction). -
Per-class exemptions no longer need
ext-mbstring. The label of the test that names an exemption was cut withmb_strimwidth, which the dependency analysis (ARCH-07) reported as a shadow dependency: the harness would have required an extension from every repository it is installed in.Support\Text::shorten()does the same with PCRE only (characters, never half a multi-byte character, invalid UTF-8 returned as it is). -
The WordPress integration template passes PHPStan, and the README says to export-ignore the suite. The first pilot of the job (
Pollora/hook, PHP 8.3 and 8.4 both green in 37 s and 46 s) showed two defects of the template, not of the job:->not->toBe('')inWordPressLoadedTest.php.stubfails PHPStan level 5 on a repository that analyses its tests (Access to an undefined property Pest\Mixins\Expectation::$not), now positive expectations; andphpunit.integration.xmlat the root is a development file that the Distribution archive step (QA-06) reports, so the README now tells to runpollora-qa archive --fix. -
The dependency audits try again when the network fails, and never when they have found something (SEC-09).
composer auditfailed twice in an hour oncurl error 28 while downloading https://packagist.org/api/security-advisories/: Connection timed out, an incident of Packagist unrelated to the code. The Dependency audit step (Check\ComposerAudit) now attempts the call 3 times in all, 5 s then 15 s apart, only when the output is a transport failure (timeout, DNS, refused or reset connection, TLS handshake, HTTP 5xx or 429:Support\TransportErrors); advisories found, a lock file error or any other output fail at once, with no second attempt. An advisory API still unreachable after the attempts FAILS the step (never a pass) withadvisory API unreachable after 3 attempts, a text that says it is a network failure and not a vulnerability. The npm audit (Npm\NpmAudit) does the same for a registry error (EAI_AGAIN,ETIMEDOUT,ECONNRESET, HTTP 5xx and so on); its other failures keep failing at once. New commandpollora-qa composer-audit [--locked], the same code, which the reusable workflowtemplate.ymlnow runs (it checks the harness out as its npm audit job does); the job names and the inputs are unchanged. The other network calls of the workflows (the gitleaks image,pipx install semgrep) are not attempted again. -
initrun again no longer erases settings. It rebuilt the configuration withoutmutation,npm_audit,servicesandslow_step_share. It now keeps every key it does not decide, andHarnessConfig::save()(used byinitandratchet --update) carries over a top-level key this version does not know, as it was.HarnessConfig::withMutation()also droppedperformance. -
pollora-qa helpaligns the commands whatever the length of their names: the column is as wide as the longest (promote-reportoverflowed the fixed 9 characters). -
README: the Status section says the performance budgets are delivered and that integration tests against a real WordPress and adapter contract tests remain.
-
Layers::psr4()no longer reads a missingcomposer.jsonthrough a suppressed warning (a directory without one is simply empty).
Documentation
- CONV-01 stays
planned, and the README says why. Four readings of "the common case needs no configuration" were measured over the 45 repositories (long required parameter lists on public factories and registries, constructors with many scalars, required boolean flags, any public method with 4 or more required parameters): the best one reports 22 methods, 5 real, so no code was added. The figures are in the README, under Status.