Skip to content

Commit 5aae76e

Browse files
committed
Fixes for security findings
1 parent 701066e commit 5aae76e

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/core/Authorize.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,24 @@ public JwtToken GetToken()
112112

113113
private void LogMerchantDetails()
114114
{
115-
// Using Request Target provided in the sample code/merchantconfig
116-
_logger.Trace("Using Request Target:'{0}'", _merchantConfig.RequestTarget);
115+
try
116+
{
117+
// Using Request Target provided in the sample code/merchantconfig
118+
_logger.Trace("Using Request Target:'{0}'", _merchantConfig.RequestTarget);
117119

118-
// logging Authentication type
119-
_logger.Trace("Authentication Type -> {0}", _merchantConfig.AuthenticationType);
120+
// logging Authentication type
121+
_logger.Trace("Authentication Type -> {0}", _merchantConfig.AuthenticationType);
120122

121-
// logging Request Type
122-
_logger.Trace("Request Type -> {0}", _merchantConfig.RequestType);
123+
// logging Request Type
124+
_logger.Trace("Request Type -> {0}", _merchantConfig.RequestType);
123125

124-
// Logging all the Properties of MerchantConfig and their respective Values
125-
_logger.Trace("MERCHCFG > {0}", MerchantConfig.LogAllproperties(_merchantConfig));
126+
// Logging all the Properties of MerchantConfig and their respective Values
127+
_logger.Trace("MERCHCFG > {0}", MerchantConfig.LogAllproperties(_merchantConfig));
128+
}
129+
catch (Exception e)
130+
{
131+
ExceptionUtility.Exception(e.Message, e.StackTrace);
132+
}
126133
}
127134
}
128135
}

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/core/MerchantConfig.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,19 @@ If a dictionary object has been passed use that object
4848

4949
LogUtility.InitLogConfig(EnableLog, LogDirectory, LogFileName, LogfileMaxSize);
5050

51-
// Logger object is ready to Log
52-
Logger.Trace("\n");
53-
Logger.Trace("START> =======================================");
51+
try
52+
{
53+
// Logger object is ready to Log
54+
Logger.Trace("\n");
55+
Logger.Trace("START> =======================================");
5456

55-
// Logging the source of properties' values
56-
Logger.Trace("Reading Merchant Configuration from " + _propertiesSetUsing);
57+
// Logging the source of properties' values
58+
Logger.Trace("Reading Merchant Configuration from " + _propertiesSetUsing);
59+
}
60+
catch (Exception e)
61+
{
62+
ExceptionUtility.Exception(e.Message, e.StackTrace);
63+
}
5764

5865
// Validations
5966
ValidateProperties();
@@ -366,31 +373,31 @@ private void ValidateProperties()
366373
if (string.IsNullOrEmpty(KeyAlias))
367374
{
368375
KeyAlias = MerchantId;
369-
Logger.Warn($"{Constants.WarningPrefix} KeyAlias not provided. Assigning the value of: [MerchantID]");
376+
throw new Exception($"{Constants.WarningPrefix} KeyAlias not provided. Assigning the value of: [MerchantID]");
370377
}
371378

372379
if (!string.Equals(KeyAlias, MerchantId))
373380
{
374381
KeyAlias = MerchantId;
375-
Logger.Warn($"{Constants.WarningPrefix} Incorrect value of KeyAlias provided. Assigning the value of: [MerchantID]");
382+
throw new Exception($"{Constants.WarningPrefix} Incorrect value of KeyAlias provided. Assigning the value of: [MerchantID]");
376383
}
377384

378385
if (string.IsNullOrEmpty(KeyPass))
379386
{
380387
KeyPass = MerchantId;
381-
Logger.Warn($"{Constants.WarningPrefix} KeyPassword not provided. Assigning the value of: [MerchantID]");
388+
throw new Exception($"{Constants.WarningPrefix} KeyPassword not provided. Assigning the value of: [MerchantID]");
382389
}
383390

384391
if (string.IsNullOrEmpty(KeyDirectory))
385392
{
386393
KeyDirectory = Constants.P12FileDirectory;
387-
Logger.Warn($"{Constants.WarningPrefix} KeysDirectory not provided. Using Default Path: {KeyDirectory}");
394+
throw new Exception($"{Constants.WarningPrefix} KeysDirectory not provided. Using Default Path: {KeyDirectory}");
388395
}
389396

390397
if (string.IsNullOrEmpty(KeyfileName))
391398
{
392399
KeyfileName = MerchantId;
393-
Logger.Warn($"{Constants.WarningPrefix} KeyfileName not provided. Assigning the value of: [MerchantId]");
400+
throw new Exception($"{Constants.WarningPrefix} KeyfileName not provided. Assigning the value of: [MerchantId]");
394401
}
395402

396403
P12Keyfilepath = KeyDirectory + "\\" + KeyfileName + ".p12";

0 commit comments

Comments
 (0)