CompleteRemovedLegacyLogMigration.php
3 years ago
CreateNewLogTable.php
4 years ago
DeleteOldLogTables.php
4 years ago
MigrateExistingLogs.php
9 months ago
RemoveSensitiveLogs.php
4 years ago
RemoveSensitiveLogs.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Give\Log\Migrations; |
| 6 | |
| 7 | use Give\Framework\Database\DB; |
| 8 | use Give\Framework\Migrations\Contracts\Migration; |
| 9 | use Give\Log\Log; |
| 10 | |
| 11 | /** |
| 12 | * Removes logs that contain sensitive information. |
| 13 | * |
| 14 | * @since 2.20.0 |
| 15 | */ |
| 16 | class RemoveSensitiveLogs extends Migration |
| 17 | { |
| 18 | /** |
| 19 | * @inheritdoc |
| 20 | */ |
| 21 | public static function id(): string |
| 22 | { |
| 23 | return 'remove_sensitive_logs'; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @inheritdoc |
| 28 | */ |
| 29 | public static function title(): string |
| 30 | { |
| 31 | return 'Remove logs wth sensitive information'; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @inheritdoc |
| 36 | */ |
| 37 | public static function timestamp() |
| 38 | { |
| 39 | return strtotime('2022-05-04'); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @inheritdoc |
| 44 | */ |
| 45 | public function run() |
| 46 | { |
| 47 | $tableName = DB::prefix('give_log'); |
| 48 | $redactions = implode('|', Log::getRedactionList()); |
| 49 | |
| 50 | DB::query(" DELETE FROM $tableName WHERE data REGEXP '$redactions' "); |
| 51 | } |
| 52 | } |
| 53 |