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
@@ -17,6 +17,10 @@ use Str;
// use Request;
class CloseShipment extends Controller
{
private const ZERO_PAD = '000000';
private const JSON_CONTENT_TYPE = 'application/json';
private const NULL_M3_RESPONSE = 'M3 API responded with null value';
// CloseShipmentCoChargeAPI : with URL PARAMS COCharge
public static function CloseShipmentCoChargeAPI(Request $request)
{
@@ -49,7 +53,7 @@ class CloseShipment extends Controller
$LineAck = [];
// PDF File PATH
$pdfFilePath = Config::get('arrays.PdfPath');
$DELIVERYNO = $MANIFEST != '' ? $MANIFEST : '000000';
$DELIVERYNO = $MANIFEST != '' ? $MANIFEST : self::ZERO_PAD;
// Log::channel('dailyCron')->info("Close Manifest:".$MANIFEST.'-WHS: '.$WHS."-CO:".$COMPANY);
@@ -89,7 +93,7 @@ class CloseShipment extends Controller
$IonToken = isset($tokenData->token) ? $tokenData->token : '';
} else {
$SHDATA = isset($tokenData->message) ? $tokenData->message : '';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
// Write to Logs : Error
$data = [
@@ -439,7 +443,7 @@ class CloseShipment extends Controller
// If billable=Y and a4ratetcp(FREIGHT)>0 and a4ratem3=blank, then call the freight API CoCharge
if ($BILLABLE == 'Y' && $FREIGHT > 0 && $A4RATEM3 == '') {
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
if ($SHIPTYPE == 'LTL') {
$shippingToBill = $FREIGHT * (100.00 - Config::get('arrays.misc.discountCarrierRateForCustomerPriceLTL')) / 100;
@@ -496,6 +500,9 @@ class CloseShipment extends Controller
$ContentLabel = route('m3.M3GetPDFFromCache.index', ['MACPKR' => $AYMACPKR, 'DOCTYPE' => $DOCTYPE]);
}
break;
default:
break;
}
}
@@ -602,7 +609,7 @@ class CloseShipment extends Controller
// No Errors Proceed in Calling M3 CLose API
if ($ErrorMsgs == '') {
// Write to Logs Out : Send JSON Request To M3
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
// dump($DELIVERYNO);
// MAK : Log JSON Manifest # and MACKPKR #
// Log::channel('dailyCron')->info('1 >>> JSON Sent for Manifest: '.$MANIFEST.' ,Macpicker: '.$AYMACPKR);
@@ -624,12 +631,12 @@ class CloseShipment extends Controller
Helper::logToICM699M($data);
$response = Http::withHeaders([
'accept' => 'application/json',
'Content-Type' => 'application/json',
'Connection' => 'close',
])
'accept' => self::JSON_CONTENT_TYPE,
'Content-Type' => self::JSON_CONTENT_TYPE,
'Connection' => 'close',
])
->withToken($token)
->withBody($JSONCS, 'application/json')
->withBody($JSONCS, self::JSON_CONTENT_TYPE)
->timeout(Config::get('arrays.curlTimeOut'))
->retry(3, 100)
->post($endPointURL);
@@ -683,8 +690,8 @@ class CloseShipment extends Controller
}
} else {
$M3APIRESULT = 'Error';
$responseMsg = 'M3 API responded with null value';
$M3APIRESULTMsg = 'M3 API responded with null value';
$responseMsg = self::NULL_M3_RESPONSE;
$M3APIRESULTMsg = self::NULL_M3_RESPONSE;
$responseResult = '';
$M3Errors = $responseStatusCode;
}
@@ -692,7 +699,7 @@ class CloseShipment extends Controller
// If you get a successful response
if ($M3APIRESULT != 'Error') {
// Write to Logs Out : Success
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -718,7 +725,7 @@ class CloseShipment extends Controller
->update(['A4PICKSTS' => 'a']);
// Write to Logs Out : Error
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -743,7 +750,7 @@ class CloseShipment extends Controller
// Write to Logs : Error
// Clear Duplicate messages
$ErrorMsgsC = Helper::removeDuplicateSubstrings($ErrorMsgs);
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -831,7 +838,7 @@ class CloseShipment extends Controller
]);
// Write to Logs Out : JSON Request To M3
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -848,12 +855,12 @@ class CloseShipment extends Controller
Helper::logToICM699M($data);
$response = Http::withHeaders([
'accept' => 'application/json',
'Content-Type' => 'application/json',
'Connection' => 'close',
])
'accept' => self::JSON_CONTENT_TYPE,
'Content-Type' => self::JSON_CONTENT_TYPE,
'Connection' => 'close',
])
->withToken($token)
->withBody($JSONCS, 'application/json')
->withBody($JSONCS, self::JSON_CONTENT_TYPE)
->timeout(Config::get('arrays.curlTimeOut'))
->retry(2, 100)
->post($endPointURL);
@@ -884,14 +891,14 @@ class CloseShipment extends Controller
} else {
$M3APIRESULT = 'Error';
$responseMsg = 'M3 API responded with null value';
$M3APIRESULTMsg = 'M3 API responded with null value';
$responseMsg = self::NULL_M3_RESPONSE;
$M3APIRESULTMsg = self::NULL_M3_RESPONSE;
}
// If you get a successful response
if ($M3APIRESULT != 'Error') {
// Write to Logs Out : Success
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -918,7 +925,7 @@ class CloseShipment extends Controller
->update(['A4PICKSTS' => 'a']);
// Write to Logs Out : Error
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -968,7 +975,7 @@ class CloseShipment extends Controller
}
// ## End Zero Pick
else {
$DELIVERYNO = isset($MANIFEST) ? $MANIFEST : '000000';
$DELIVERYNO = isset($MANIFEST) ? $MANIFEST : self::ZERO_PAD;
// # Set SHDATA Message
$SHDATAMSG = 'No records found in ICM695M1,or URL parameters incomplete';
// count($ICM695M1TMP)==0 ? 'MacPkr already closed' :
@@ -1000,7 +1007,7 @@ class CloseShipment extends Controller
}
} else {
// Write to Logs Out : Error
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),
@@ -1051,7 +1058,7 @@ class CloseShipment extends Controller
]);
} else {
// Write to Logs Out : Error
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : '000000';
$DELIVERYNO = isset($AYMACPKR) ? $AYMACPKR : self::ZERO_PAD;
$data = [
'SHMACPKR' => $DELIVERYNO,
'SHDT' => date('Y-m-d'),