| @@ -106,8 +106,11 @@ | ||
| 106 | 106 | |
| 107 | 107 | // Schedule cron events |
| 108 | 108 | self::schedule_events(); |
| 109 | 109 | |
| 110 | + // Capture the self-integrity anchor (A3: manifest fingerprint in DB). | |
| 111 | + self::anchor_self_integrity( $settings ); | |
| 112 | + | |
| 110 | 113 | // Set activation transient for admin notice |
| 111 | 114 | set_transient( 'vigilante_activated', true, 30 ); |
| 112 | 115 | |
| 113 | 116 | // Store activation time |
| @@ -120,8 +123,35 @@ | ||
| 120 | 123 | flush_rewrite_rules(); |
| 121 | 124 | |
| 122 | 125 | // Clean any output that may have been generated |
| 123 | 126 | ob_end_clean(); |
| 127 | + } | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * Anchor the self-integrity check on activation | |
| 131 | + * | |
| 132 | + * The first activation captures the fingerprint of the shipped manifest, | |
| 133 | + * unless WordPress.org distributes something else for that version, so | |
| 134 | + * the self-check has a baseline from the very first run. A | |
| 135 | + * reactivation keeps the anchor it already has and checks against it: | |
| 136 | + * capturing again adopted whatever manifest the folder held at that | |
| 137 | + * moment, a regenerated one included, the same reason the critical files | |
| 138 | + * baseline is not thrown away on reactivation. | |
| 139 | + * | |
| 140 | + * @since 3.0.0 | |
| 141 | + * | |
| 142 | + * @param Vigilante_Settings $settings Settings instance. | |
| 143 | + * @return void | |
| 144 | + */ | |
| 145 | + public static function anchor_self_integrity( $settings ) { | |
| 146 | + if ( ! class_exists( 'Vigilante_Self_Integrity' ) ) { | |
| 147 | + require_once VIGILANTE_INCLUDES_DIR . 'class-self-integrity.php'; | |
| 148 | + } | |
| 149 | + // run_check() captures on the first run itself, but only when | |
| 150 | + // WordPress.org does not contradict the manifest; with an anchor already | |
| 151 | + // there it checks against it. | |
| 152 | + $self_integrity = new Vigilante_Self_Integrity( $settings ); | |
| 153 | + $self_integrity->run_check( 'activation' ); | |
| 124 | 154 | } |
| 125 | 155 | |
| 126 | 156 | /** |
| 127 | 157 | * Idempotent migrations for existing installations. |