m3 Security Fixes

This commit is contained in:
Mark Gregory
2026-09-17 10:24:14 +01:00
parent 74f2387dfe
commit c9856d58c1
20 changed files with 234 additions and 201 deletions
@@ -13,6 +13,9 @@ use Str;
class M3Controller extends Controller
{
private const FIELD_PREFIX = 'Field: ';
private const M3_LIST_SUFFIX = ' M3-Lis-JSN';
// Split Data and Write to ICM666M2
public function insertToICM666M2($dataSplit, $commentData)
{
@@ -377,18 +380,18 @@ class M3Controller extends Controller
if (! $lengthTest[413] || ! $lengthTest[411] || ! $lengthTest[417]) {
if (! $lengthTest[413]) {
$message[] = ['code' => '413', 'status' => 'error', 'message' => 'Field: ' . $key . ' is larger then expected'];
$message[] = ['code' => '413', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . ' is larger then expected'];
}
if (! $lengthTest[411]) {
$message[] = ['code' => '411', 'status' => 'error', 'message' => 'Field: ' . $key . ' is empty'];
$message[] = ['code' => '411', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . ' is empty'];
}
if (! $lengthTest[417]) {
$message[] = ['code' => '417', 'status' => 'error', 'message' => 'Field: ' . $key . 'type is different then Expected type: ' . $value[2]];
$message[] = ['code' => '417', 'status' => 'error', 'message' => self::FIELD_PREFIX . $key . 'type is different then Expected type: ' . $value[2]];
}
// Write to Logs Out : Error & JSON
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
'SHDATA' => json_encode($message) . ' M3-Lis-JSN' . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
'SHDATA' => json_encode($message) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
Helper::logToICM699M($data);
return response()->json($message);
@@ -485,7 +488,7 @@ class M3Controller extends Controller
if ($PGMERRORS != '') {
// Write to Logs Out : Error & JSON
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-spl',
'SHDATA' => $PGMERRORS . ' M3-Lis-JSN' . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
'SHDATA' => $PGMERRORS . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
Helper::logToICM699M($data);
}
}
@@ -517,7 +520,7 @@ class M3Controller extends Controller
} catch (\Throwable $th) {
// Write to Logs Out : Error & JSON
$data = ['SHMACPKR' => $SHMACPKR, 'SHDT' => date('Y-m-d'), 'SHTIME' => date('H:i:s'), 'SHERROR' => 'X', 'SHINTBOX' => '', 'SHTYPE' => 'M3-Lis-in',
'SHDATA' => 'General Catchable Error - ' . substr($th, 0, 300) . ' M3-Lis-JSN' . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
'SHDATA' => 'General Catchable Error - ' . substr($th, 0, 300) . self::M3_LIST_SUFFIX . json_encode($jsonFile), 'SHUSER' => $REQKPKUS, 'SHSOURCE' => $SHSOURCE, 'SHCO' => $Company, 'SHWHS' => $Warehouse];
Helper::logToICM699M($data);
// Log::error($th);