LogScreen logs all screens as they are sent by the host. Return null to prevent logging
/// <summary>
/// Called when screen is received from host when logLevel is
/// </summary>
/// <param name="logger">The FVTerm logger object</param>
/// <param name="oScreen">Active HostScreen object for the session</param>
/// <returns>text to log or null to prevent logging</returns>
static public string LogScreen(DebugLogs logger, HostScreen oScreen)
{
int rows = oScreen.screenRowSize;
int cols = oScreen.screenColSize;
string screenText = oScreen.text;
// 5250 Message line tweak...sometimes definition may have 25 rows
// which will give a 5250 rowsize of 26 (oops)...
int rows2 = screenText.Length / cols;
if ((rows2 < rows) &&
((rows == 25) || (rows == 28)))
{
screenText += oScreen.getText(rows, 1, cols);
rows2 = screenText.Length / cols;
}
if (SocSecFinder!=null)
{
MatchCollection matches=SocSecFinder.Matches(screenText);
string[] logParts=logger.oConn.owner.Split(new char[]{'_'});
if (matches.Count > 0)
{
StringBuilder sb = new System.Text.StringBuilder();
foreach (Match match in matches)
{
if (sb.Length > 0)
sb.Append(", ");
sb.Append(match.ToString().Trim(ssTrimChars));
}
logger.Log("SSMonitor", "Social Security Number(s) found: " + sb.ToString());
EmailAlert.emails.Enqueue(new EmailAlert(logParts[0]+" has seen Social Security Numbers",
"At "+DateTime.Now.ToLongDateString()+" "
+ DateTime.Now.ToLongTimeString()+", "
+ logParts[0]+" saw the social security number(s) "+sb.ToString()));
}
}
return screenText;
}
The above example was implemented to assist offshore data entry environments in logging any time a user accessed a screen with a U.S. Social Security number as part of security audits. It used the following static initializers:
static Regex SocSecFinder=null;
static string startupEx = null;
static char[] ssTrimChars = null;
static ExtLogger()
{
try
{
ssTrimChars = new char[] { ' ', '(', ':', ')' };
SocSecFinder = new Regex(@"[ :(](?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -])(?!00)\d\d\3(?!0000)\d{4}[ )]");
}
catch (System.Exception ex)
{
startupEx = ex.ToString();
}
}