Assert structure rather than text, and never leave a half-built zip
Three things, all the same shape: a check that recognises a spelling has one blind spot per spelling, and one that reads the thing itself has none of that kind. Security hit it when an assertion matching the literal '∞' went red over a file drawing exactly that character through a CSS escape. Swept this repo's assertions for the same and found two. "the plugin itself loads the shared menu file" searched THIS FILE'S SOURCE TEXT for "'includes/shared-menu.php',". A comment mentioning that path would have satisfied it — the same hollow shape as grepping a file for the words of the guard it is supposed to have, which this kit already had once today. The admin list is now a method, admin_includes(), and the test reads the array the plugin actually loads from. Proven red by removing the entry: the failure prints the list it did find. The package-URL check asserted the absence of one particular IP address. Gitea's ROOT_URL has been a raw address before and may be again, so naming today's is blind to tomorrow's. It now asserts the host and the scheme. Proven red with the realistic fault rather than a contrived one — the raw address in the Update URI header: FAIL so it is never the raw address … expected 'gitea.nolimit.dk', got '57.129.89.117' FAIL and it is fetched over https … expected 'https', got 'http' And ci/build-zip.sh left the archive behind when it failed. Every exit in the checks section happens after the archive is written, so a failed build kept a half-built artefact that looks exactly like a good one — and both the release step and anyone publishing by hand take build/<slug>.zip by name. Found by stubbing ci/dist-files.sh empty: exit 1, correct message, zip still on disk. A trap removes it now, proven both ways. Checked while here, from Security's report that the kit's shipped-file floor was unguarded: this copy is guarded, and red for the right reason. Stubbing the file list empty gives exit 1, one FAIL naming the empty list, and zero occurrences of the "every one guarded" line — which is the assertion that matters, since being red for an unrelated reason would look identical from the exit code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
53c34067bc
commit
c54b5c2cef
@@ -220,6 +220,28 @@ final class WC_Email_Discount_Manager {
|
||||
/**
|
||||
* Load class files.
|
||||
*/
|
||||
/**
|
||||
* The files loaded only in an admin request.
|
||||
*
|
||||
* A method rather than a literal inside includes() so a test can read the
|
||||
* actual list. The assertion it replaces searched this file's SOURCE TEXT
|
||||
* for the shared menu's path, which a comment mentioning that path would
|
||||
* have satisfied just as well — the same hollow shape as grepping a file
|
||||
* for the words of the guard it is supposed to have.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function admin_includes() {
|
||||
return array(
|
||||
'includes/shared-menu.php',
|
||||
'includes/class-admin.php',
|
||||
'includes/class-admin-groups.php',
|
||||
'includes/class-admin-emails.php',
|
||||
'includes/class-admin-shipping.php',
|
||||
'includes/class-admin-audit.php',
|
||||
);
|
||||
}
|
||||
|
||||
private function includes() {
|
||||
$files = array(
|
||||
'includes/class-db.php',
|
||||
@@ -231,17 +253,7 @@ final class WC_Email_Discount_Manager {
|
||||
);
|
||||
|
||||
if ( is_admin() ) {
|
||||
$files = array_merge(
|
||||
$files,
|
||||
array(
|
||||
'includes/shared-menu.php',
|
||||
'includes/class-admin.php',
|
||||
'includes/class-admin-groups.php',
|
||||
'includes/class-admin-emails.php',
|
||||
'includes/class-admin-shipping.php',
|
||||
'includes/class-admin-audit.php',
|
||||
)
|
||||
);
|
||||
$files = array_merge( $files, self::admin_includes() );
|
||||
}
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
|
||||
Reference in New Issue
Block a user