A free open source IT asset/license management system
Fixed RB-21854 - make sure the ID is a number
snipea09813884725
diff --git a/routes/web/accessories.php b/routes/web/accessories.phpindex e2ae08204c..01964002b1 100644--- a/routes/web/accessories.php+++ b/routes/web/accessories.php@@ -18,15 +18,21 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function ()[Accessories\AccessoryCheckoutController::class, 'store'])->name('accessories.checkout.store');+ // accessoryID is a numeric auto-increment PK. Constrain at the router+ // so non-numeric garbage (pen-test scanners) 404s here instead of+ // reaching the breadcrumb closure at BreadcrumbsServiceProvider:128+ // which is typed `int $accessoryID` and throws TypeError.Route::get('{accessoryID}/checkin/{backto?}',[Accessories\AccessoryCheckinController::class, 'create']- )->name('accessories.checkin.show');+ )->where('accessoryID', '[0-9]+')+ ->name('accessories.checkin.show');Route::post('{accessoryID}/checkin/{backto?}',[Accessories\AccessoryCheckinController::class, 'store']- )->name('accessories.checkin.store');+ )->where('accessoryID', '[0-9]+')+ ->name('accessories.checkin.store');Route::get('{accessory}/clone',[Accessories\AccessoriesController::class, 'getClone']diff --git a/routes/web/components.php b/routes/web/components.phpindex fa66ab5ad6..040d18b34b 100644--- a/routes/web/components.php+++ b/routes/web/components.php@@ -5,31 +5,41 @@ use Illuminate\Support\Facades\Route;// ComponentsRoute::group(['prefix' => 'components', 'middleware' => ['auth']], function () {+ // Component / componentAsset ids are always numeric auto-increment PKs,+ // so constrain the route parameters at the router. Without this,+ // non-numeric garbage (pen-test scanners hitting things like+ // components/2||(SELECT...) reach the breadcrumb closure which is+ // typed `int $componentID` and throws TypeError, spamming Rollbar.+ // Constraining at the router 404s the request before any controller+ // or breadcrumb runs.Route::get('{componentID}/checkout',[Components\ComponentCheckoutController::class, 'create']- )->name('components.checkout.show');+ )->where('componentID', '[0-9]+')+ ->name('components.checkout.show');Route::post('{componentID}/checkout',[Components\ComponentCheckoutController::class, 'store']- )->name('components.checkout.store');+ )->where('componentID', '[0-9]+')+ ->name('components.checkout.store');Route::get('{componentID}/checkin/{backto?}',[Components\ComponentCheckinController::class, 'create']- )->name('components.checkin.show');+ )->where('componentID', '[0-9]+')+ ->name('components.checkin.show');Route::post('{componentID}/checkin/{backto?}',[Components\ComponentCheckinController::class, 'store']- )->name('components.checkin.store');+ )->where('componentID', '[0-9]+')+ ->name('components.checkin.store');Route::get('{component}/clone',[Components\ComponentsController::class, 'getClone']- )->name('components.clone.create');--+ )->where('component', '[0-9]+')+ ->name('components.clone.create');});diff --git a/routes/web/consumables.php b/routes/web/consumables.phpindex 53ec09425e..92ea7168b6 100644--- a/routes/web/consumables.php+++ b/routes/web/consumables.php@@ -3,27 +3,26 @@use App\Http\Controllers\Consumables;use Illuminate\Support\Facades\Route;--Route::group(['prefix' => 'consumables', 'middleware' => ['auth']], function () {Route::get('{consumablesID}/checkout',[Consumables\ConsumableCheckoutController::class, 'create']- )->name('consumables.checkout.show');+ )->where('consumablesID', '[0-9]+')+ ->name('consumables.checkout.show');Route::post('{consumablesID}/checkout',[Consumables\ConsumableCheckoutController::class, 'store']- )->name('consumables.checkout.store');-+ )->where('consumablesID', '[0-9]+')+ ->name('consumables.checkout.store');Route::get('{consumable}/clone',[Consumables\ConsumablesController::class, 'clone']- )->name('consumables.clone.create');-+ )->where('consumable', '[0-9]+')+ ->name('consumables.clone.create');});-+Route::resource('consumables', Consumables\ConsumablesController::class, ['middleware' => ['auth'],'parameters' => ['consumable' => 'consumable_id'],diff --git a/routes/web/fields.php b/routes/web/fields.phpindex ac4d1fe297..f2f5407411 100644--- a/routes/web/fields.php+++ b/routes/web/fields.php@@ -14,22 +14,26 @@ Route::group(['prefix' => 'fields', 'middleware' => ['auth']], function () {Route::post('required/{fieldset_id}/{field_id}',[CustomFieldsetsController::class, 'makeFieldRequired']- )->name('fields.required');+ )->where(['fieldset_id' => '[0-9]+', 'field_id' => '[0-9]+'])+ ->name('fields.required');Route::post('optional/{fieldset_id}/{field_id}',[CustomFieldsetsController::class, 'makeFieldOptional']- )->name('fields.optional');+ )->where(['fieldset_id' => '[0-9]+', 'field_id' => '[0-9]+'])+ ->name('fields.optional');Route::post('{field_id}/fieldset/{fieldset_id}/disassociate',[CustomFieldsController::class, 'deleteFieldFromFieldset']- )->name('fields.disassociate');+ )->where(['field_id' => '[0-9]+', 'fieldset_id' => '[0-9]+'])+ ->name('fields.disassociate');Route::post('fieldsets/{id}/associate',[CustomFieldsetsController::class, 'associate']- )->name('fieldsets.associate');+ )->where('id', '[0-9]+')+ ->name('fieldsets.associate');Route::resource('fieldsets', CustomFieldsetsController::class, ['parameters' => [diff --git a/routes/web/kits.php b/routes/web/kits.phpindex abd2d75266..f2887552a5 100644--- a/routes/web/kits.php+++ b/routes/web/kits.php@@ -5,7 +5,20 @@ use App\Models\PredefinedKit;use Illuminate\Support\Facades\Route;use Tabuna\Breadcrumbs\Trail;-Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {+// All numeric-PK params inside this group get constrained via the group's+// `where` array so garbage-input requests 404 at the router before hitting+// controllers or breadcrumbs.+Route::group([+ 'prefix' => 'kits/{kit}',+ 'middleware' => ['auth'],+ 'where' => [+ 'kit' => '[0-9]+',+ 'license_id' => '[0-9]+',+ 'model_id' => '[0-9]+',+ 'consumable_id' => '[0-9]+',+ 'accessory_id' => '[0-9]+',+ ],+], function () {// Route::get('licenses',// [Kits\PredefinedKitsController::class, 'indexLicenses']@@ -21,8 +34,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::get('licenses/{license_id}/edit', [Kits\PredefinedKitsController::class, 'editLicense'])->name('kits.licenses.edit')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('settings.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('settings.index')->push(trans('admin/settings/general.backups'), route('kits.licenses.edit')));Route::delete('licenses/{license_id}',@@ -46,7 +58,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {// ConsumablesRoute::put('consumables/{consumable_id}',[Kits\PredefinedKitsController::class, 'updateConsumable']- )/*->parameters([2 => 'kit_id', 1 => 'consumable_id'])*/->name('kits.consumables.update');+ )/* ->parameters([2 => 'kit_id', 1 => 'consumable_id']) */ ->name('kits.consumables.update');Route::get('consumables/{consumable_id}/edit',[Kits\PredefinedKitsController::class, 'editConsumable']@@ -59,7 +71,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {// AccessoriesRoute::put('accessories/{accessory_id}',[Kits\PredefinedKitsController::class, 'updateAccessory']- )/*->parameters([2 => 'kit_id', 1 => 'accessory_id'])*/->name('kits.accessories.update');+ )/* ->parameters([2 => 'kit_id', 1 => 'accessory_id']) */ ->name('kits.accessories.update');Route::get('accessories/{accessory_id}/edit', [Kits\PredefinedKitsController::class, 'editAccessory'])->name('kits.accessories.edit');@@ -69,8 +81,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::get('checkout', [Kits\CheckoutKitController::class, 'showCheckout'])->name('kits.checkout.show')- ->breadcrumbs(fn (Trail $trail, PredefinedKit $kit) =>- $trail->parent('kits.show', $kit)+ ->breadcrumbs(fn (Trail $trail, PredefinedKit $kit) => $trail->parent('kits.show', $kit)->push(trans('general.checkout'), route('kits.checkout.show', $kit)));Route::post('checkout', [Kits\CheckoutKitController::class, 'store'])@@ -81,4 +92,3 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::resource('kits', Kits\PredefinedKitsController::class, ['middleware' => ['auth'],]);-diff --git a/routes/web/licenses.php b/routes/web/licenses.phpindex 64d707651c..4bc34669f1 100644--- a/routes/web/licenses.php+++ b/routes/web/licenses.php@@ -8,9 +8,12 @@ use Tabuna\Breadcrumbs\Trail;// LicensesRoute::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {- Route::get('{licenseId}/clone', [Licenses\LicensesController::class, 'getClone'])->name('clone/license');+ Route::get('{licenseId}/clone', [Licenses\LicensesController::class, 'getClone'])+ ->where('licenseId', '[0-9]+')+ ->name('clone/license');Route::get('{license}/checkout/{seatId?}', [Licenses\LicenseCheckoutController::class, 'create'])+ ->where(['license' => '[0-9]+', 'seatId' => '[0-9]+'])->name('licenses.checkout')->breadcrumbs(fn (Trail $trail, License $license) => $trail->parent('licenses.show', $license)->push(trans('general.checkout'), route('licenses.checkout', $license))@@ -19,9 +22,11 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {Route::post('{licenseId}/checkout/{seatId?}',[Licenses\LicenseCheckoutController::class, 'store']- )->name('licenses.checkout.save');+ )->where(['licenseId' => '[0-9]+', 'seatId' => '[0-9]+'])+ ->name('licenses.checkout.save');Route::get('{licenseSeat}/checkin/{backto?}', [Licenses\LicenseCheckinController::class, 'create'])+ ->where('licenseSeat', '[0-9]+')->name('licenses.checkin')->breadcrumbs(fn (Trail $trail, LicenseSeat $licenseSeat) => $trail->parent('licenses.show', $licenseSeat->license)->push(trans('general.checkin'), route('licenses.checkin', $licenseSeat))@@ -29,12 +34,14 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {Route::post('{licenseId}/checkin/{backto?}',[Licenses\LicenseCheckinController::class, 'store']- )->name('licenses.checkin.save');+ )->where('licenseId', '[0-9]+')+ ->name('licenses.checkin.save');Route::post('{licenseId}/bulkcheckin',[Licenses\LicenseCheckinController::class, 'bulkCheckin']- )->name('licenses.bulkcheckin');+ )->where('licenseId', '[0-9]+')+ ->name('licenses.bulkcheckin');Route::post('bulkcheckin/selected',@@ -44,7 +51,8 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {Route::post('{licenseId}/bulkcheckout',[Licenses\LicenseCheckoutController::class, 'bulkCheckout']- )->name('licenses.bulkcheckout');+ )->where('licenseId', '[0-9]+')+ ->name('licenses.bulkcheckout');Route::get('export',diff --git a/routes/web/locations.php b/routes/web/locations.phpindex 882bd5c92d..bd2dfb7ddd 100644--- a/routes/web/locations.php+++ b/routes/web/locations.php@@ -6,33 +6,37 @@ use Illuminate\Support\Facades\Route;Route::group(['prefix' => 'locations', 'middleware' => ['auth']], function () {Route::post(- 'bulkdelete',- [LocationsController::class, 'postBulkDelete']+ 'bulkdelete',+ [LocationsController::class, 'postBulkDelete'])->name('locations.bulkdelete.show');Route::post(- 'bulkedit',- [LocationsController::class, 'postBulkDeleteStore']+ 'bulkedit',+ [LocationsController::class, 'postBulkDeleteStore'])->name('locations.bulkdelete.store');Route::post(- '{location}/restore',- [LocationsController::class, 'postRestore']- )->name('locations.restore')->withTrashed();+ '{location}/restore',+ [LocationsController::class, 'postRestore']+ )->where('location', '[0-9]+')+ ->name('locations.restore')->withTrashed();Route::get('{locationId}/clone',- [LocationsController::class, 'getClone']- )->name('clone/location');+ [LocationsController::class, 'getClone']+ )->where('locationId', '[0-9]+')+ ->name('clone/location');Route::get(- '{locationId}/printassigned',- [LocationsController::class, 'print_assigned']- )->name('locations.print_assigned');+ '{locationId}/printassigned',+ [LocationsController::class, 'print_assigned']+ )->where('locationId', '[0-9]+')+ ->name('locations.print_assigned');Route::get(- '{locationId}/printallassigned',- [LocationsController::class, 'print_all_assigned']- )->name('locations.print_all_assigned');+ '{locationId}/printallassigned',+ [LocationsController::class, 'print_all_assigned']+ )->where('locationId', '[0-9]+')+ ->name('locations.print_all_assigned');});diff --git a/routes/web/models.php b/routes/web/models.phpindex d16e1ca918..3e92882cd0 100644--- a/routes/web/models.php+++ b/routes/web/models.php@@ -15,7 +15,8 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {AssetModelsController::class,'getClone',]- )->name('models.clone.create')->withTrashed()+ )->where('model', '[0-9]+')+ ->name('models.clone.create')->withTrashed()->breadcrumbs(fn (Trail $trail) => $trail->parent('models.index')->push(trans('admin/models/table.clone'), route('models.index')));@@ -25,9 +26,10 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {AssetModelsController::class,'postCreate',]- )->name('models.clone.store')->withTrashed();+ )->where('model', '[0-9]+')+ ->name('models.clone.store')->withTrashed();- // Legacy URL — predates Route::resource below, which already provides+ // Legacy URL that predates Route::resource below, which already provides// models.show at GET /models/{model}. Kept (pointing at the same controller// method) so old bookmarks / external links don't 404.Route::get(@@ -36,7 +38,8 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {AssetModelsController::class,'show',]- )->name('view/model');+ )->where('model', '[0-9]+')+ ->name('view/model');Route::post('{modelID}/restore',@@ -44,7 +47,8 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {AssetModelsController::class,'getRestore',]- )->name('models.restore.store');+ )->where('modelID', '[0-9]+')+ ->name('models.restore.store');Route::get('{modelId}/custom_fields',@@ -52,7 +56,8 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {AssetModelsController::class,'getCustomFields',]- )->name('custom_fields/model');+ )->where('modelId', '[0-9]+')+ ->name('custom_fields/model');Route::post('bulkedit',diff --git a/routes/web/users.php b/routes/web/users.phpindex 031a00857e..3d879eef39 100644--- a/routes/web/users.php+++ b/routes/web/users.php@@ -64,7 +64,8 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {Users\UsersController::class,'sendPasswordReset',]- )->name('users.password');+ )->where('userId', '[0-9]+')+ ->name('users.password');Route::get('{userId}/print',@@ -72,7 +73,8 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {Users\UsersController::class,'printInventory',]- )->name('users.print');+ )->where('userId', '[0-9]+')+ ->name('users.print');Route::post('{userId}/email',@@ -80,7 +82,8 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {Users\UsersController::class,'emailAssetList',]- )->name('users.email');+ )->where('userId', '[0-9]+')+ ->name('users.email');Route::post('{user}/acceptance-reminder',