From 1ae044b91ebcfe47ce3b77f9614a4bbe353d0c2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 08:28:05 +0000 Subject: [PATCH 1/5] Bump codacy/codacy-analysis-cli-action from 1.1.0 to 4.1.0 Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 1.1.0 to 4.1.0. - [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases) - [Commits](https://github.com/codacy/codacy-analysis-cli-action/compare/1.1.0...v4.1.0) --- updated-dependencies: - dependency-name: codacy/codacy-analysis-cli-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codacy-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index f45616b11..92f4029c9 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -36,7 +36,7 @@ jobs: # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@1.1.0 + uses: codacy/codacy-analysis-cli-action@v4.1.0 with: # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository # You can also omit the token and run the tools that support default configurations From 43e370f35a6ef881acb2232f97a3320bc2cf093d Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 8 Jul 2022 16:40:51 -0700 Subject: [PATCH 2/5] Move migrations further up Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 50da12edf..d529c3385 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -1278,6 +1278,12 @@ class SettingsController extends Controller // If it's greater than 300, it probably worked $output = Artisan::output(); + /* Run migrations */ + \Log::debug('Migrating database...'); + Artisan::call('migrate', ['--force' => true]); + $migrate_output = Artisan::output(); + \Log::debug($migrate_output); + if (strlen($output) > 300) { $find_user = DB::table('users')->where('first_name', $user->first_name)->where('last_name', $user->last_name)->exists(); @@ -1287,15 +1293,8 @@ class SettingsController extends Controller $new_user->push(); } - \Log::debug('Logging all users out..'); Artisan::call('snipeit:global-logout', ['--force' => true]); - - /* run migrations */ - \Log::debug('Migrating database...'); - Artisan::call('migrate', ['--force' => true]); - $migrate_output = Artisan::output(); - \Log::debug($migrate_output); DB::table('users')->update(['remember_token' => null]); \Auth::logout(); @@ -1303,7 +1302,6 @@ class SettingsController extends Controller return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.'); } else { return redirect()->route('settings.backups.index')->with('error', $output); - } } else { From e833052e8e4f40556b22bc3004734cebdb5f91da Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 8 Jul 2022 16:46:00 -0700 Subject: [PATCH 3/5] Check for column Signed-off-by: snipe --- ...001334_add_eula_to_checkout_acceptance.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/database/migrations/2022_03_09_001334_add_eula_to_checkout_acceptance.php b/database/migrations/2022_03_09_001334_add_eula_to_checkout_acceptance.php index 07101d169..ac4faa19a 100644 --- a/database/migrations/2022_03_09_001334_add_eula_to_checkout_acceptance.php +++ b/database/migrations/2022_03_09_001334_add_eula_to_checkout_acceptance.php @@ -13,10 +13,12 @@ class AddEulaToCheckoutAcceptance extends Migration */ public function up() { - Schema::table('checkout_acceptances', function (Blueprint $table) { - $table->text('stored_eula')->nullable()->default(null); - $table->string('stored_eula_file')->nullable()->default(null); - }); + if (!Schema::hasColumn('checkout_acceptances', 'stored_eula')) { + Schema::table('checkout_acceptances', function (Blueprint $table) { + $table->text('stored_eula')->nullable()->default(null); + $table->string('stored_eula_file')->nullable()->default(null); + }); + } } /** @@ -26,13 +28,15 @@ class AddEulaToCheckoutAcceptance extends Migration */ public function down() { - Schema::table('checkout_acceptances', function (Blueprint $table) { - if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) { - $table->dropColumn('stored_eula'); - } - if (Schema::hasColumn('checkout_acceptances', 'stored_eula_file')) { - $table->dropColumn('stored_eula_file'); - } - }); + if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) { + Schema::table('checkout_acceptances', function (Blueprint $table) { + if (Schema::hasColumn('checkout_acceptances', 'stored_eula')) { + $table->dropColumn('stored_eula'); + } + if (Schema::hasColumn('checkout_acceptances', 'stored_eula_file')) { + $table->dropColumn('stored_eula_file'); + } + }); + } } } \ No newline at end of file From 2518e2f0ee66641ae104a972e1262e989073477e Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 8 Jul 2022 17:09:56 -0700 Subject: [PATCH 4/5] Removed > 300 Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 32 ++++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index d529c3385..379a32571 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -1284,24 +1284,22 @@ class SettingsController extends Controller $migrate_output = Artisan::output(); \Log::debug($migrate_output); - if (strlen($output) > 300) { - $find_user = DB::table('users')->where('first_name', $user->first_name)->where('last_name', $user->last_name)->exists(); - - if (!$find_user){ - \Log::warning('Attempting to restore user: ' . $user->first_name . ' ' . $user->last_name); - $new_user = $user->replicate(); - $new_user->push(); - } - - \Log::debug('Logging all users out..'); - Artisan::call('snipeit:global-logout', ['--force' => true]); - - DB::table('users')->update(['remember_token' => null]); - \Auth::logout(); - - return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.'); + $find_user = DB::table('users')->where('username', $user->username)->exists(); + if (!$find_user){ + \Log::warning('Attempting to restore user: ' . $user->username); + $new_user = $user->replicate(); + $new_user->push(); } else { - return redirect()->route('settings.backups.index')->with('error', $output); + \Log::debug('User: ' . $user->username .' already exists.'); + } + + \Log::debug('Logging all users out..'); + Artisan::call('snipeit:global-logout', ['--force' => true]); + + DB::table('users')->update(['remember_token' => null]); + \Auth::logout(); + + return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.'); } } else { From bb091760af0e5e50d97edcc224d99f6e56a79140 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 11 Jul 2022 17:11:28 -0700 Subject: [PATCH 5/5] Fixedd unclosed brace Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 379a32571..33afd47f8 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -1285,6 +1285,7 @@ class SettingsController extends Controller \Log::debug($migrate_output); $find_user = DB::table('users')->where('username', $user->username)->exists(); + if (!$find_user){ \Log::warning('Attempting to restore user: ' . $user->username); $new_user = $user->replicate(); @@ -1300,8 +1301,7 @@ class SettingsController extends Controller \Auth::logout(); return redirect()->route('login')->with('success', 'Your system has been restored. Please login again.'); - } - + } else { return redirect()->route('settings.backups.index')->with('error', trans('admin/settings/message.backup.file_not_found')); }