Escape net-snmp unformatted strings, try 2 (#13584)

* Escape net-snmp unformatted strings, try 2

* Add some tests
This commit is contained in:
Tony Murray
2021-11-30 00:12:42 -06:00
committed by GitHub
parent 4a99b798b5
commit 9d2633bf09
3 changed files with 9 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ class SnmpFetch extends LnmsCommand
$spec = $this->argument('device spec');
$device_ids = Device::query()->when($spec !== 'all', function (Builder $query) use ($spec) {
return $query->where('device_id', $spec)
->orWhere('hostname', 'regexp', $spec);
->orWhere('hostname', 'regexp', "^$spec$");
})->pluck('device_id');
if ($device_ids->isEmpty()) {