M3 Security Fixes for scan command pass 33 major code smell fixes and style fixes

This commit is contained in:
Mark Gregory
2026-09-17 11:34:41 +01:00
parent 0a05f05843
commit 0c445f89af
69 changed files with 1786 additions and 1752 deletions
@@ -14,6 +14,7 @@ use Str;
class TwoShipAPIs extends Controller
{
private const SOURCE = 'TwoShipUpdateHold';
private const RESPONSE_TYPE = 'AggStopRsp';
public function TwoShipUpdateHold(Request $request)
@@ -27,6 +28,7 @@ class TwoShipAPIs extends Controller
if ($params === []) {
$this->log($macpkr ?: '000000', $co, $whs, $user, 'X', 'No URL Parameters Sent');
return response()->json(['code' => '405', 'status' => 'Error', 'message' => 'No URL Parameters Sent']);
}
@@ -37,17 +39,20 @@ class TwoShipAPIs extends Controller
$error = $this->responseError($response);
if ($error !== '') {
$this->log($macpkr, $co, $whs, $user, 'X', $response->status() . '-' . $error);
return response()->json(['code' => '405', 'status' => 'error', 'message' => 'Status: ' . $response->status() . '-' . $error]);
}
$this->log($macpkr, $co, $whs, $user, '', $response->body());
$this->markAggregationComplete($orders, $co, $whs);
return response()->json(['code' => '200', 'status' => 'Success']);
} catch (\Throwable $th) {
$message = str_contains($th->getMessage(), 'cURL error')
? 'Curl Error: Communication with 2Ship Timed Out.'
: '2Ship communication failed.';
$this->log($macpkr, $co, $whs, $user, 'X', $message);
return response()->json(['code' => '405', 'status' => 'error', 'message' => $message]);
}
}
@@ -76,6 +81,7 @@ class TwoShipAPIs extends Controller
$orders = DB::connection(config('m3.connection', 'pgsql'))->table('icm688m1')
->where('A4SHPAGGCD', $aggregation)->where('A4SHPAGGCD', '<>', 0)->where('A4CONCMPLT', '<>', 'y')
->where('A4CO', $co)->where('A4WHS', $whs)->pluck('A4MACPKR')->all();
return $orders !== [] ? $orders : [$macpkr];
}
@@ -87,6 +93,7 @@ class TwoShipAPIs extends Controller
'FindBy' => 'ByMultipleOrderNumbers',
'DataToBeUpdated' => ['UpdateAggregationSettings' => true, 'OrderAggregationSettingsInfo' => ['NotConsideredAggregation' => true]],
];
return Http::acceptJson()->asJson()->timeout((int) Config::get('arrays.PHPTimeOut'))
->post(Config::get('arrays.2Ship.end_point') . Config::get('arrays.2Ship.hold_update'), $payload);
}
@@ -97,6 +104,7 @@ class TwoShipAPIs extends Controller
return 'Error: No Response from 2Ship';
}
$body = $response->json();
return ($body['Success'] ?? true) === false ? '2Ship Error: ' . ($body['GlobalError'] ?? 'Unknown error') : '';
}