Sfoglia il codice sorgente

Fixed a bug where the rulebase path was not determined correctly when license id was provided only through the run-time interface.

Modified the configuration log generator to protect security key information when it is provided through the run-time interface.


git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@19 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 15 anni fa
parent
commit
c73adfe320
1 ha cambiato i file con 28 aggiunte e 6 eliminazioni
  1. 28
    6
      snfCFGmgr.cpp

+ 28
- 6
snfCFGmgr.cpp Vedi File

InitLicenseId = (NULL==LicenseId)?"":LicenseId; // any time load() is called. InitLicenseId = (NULL==LicenseId)?"":LicenseId; // any time load() is called.
InitAuthentication = (NULL==Authentication)?"":Authentication; InitAuthentication = (NULL==Authentication)?"":Authentication;
} }
//// When the license ID and security string come from an OEM application they
//// may not appear in the configuration files. If that is the case we will assume
//// that they developer wants to keep the security string secret by encrypting it
//// in their application and providing it to SNF at runtime. In that case we will
//// not display the security key in the configuration log.
////
//// To prevent hacking attempts, if the authentication information appears to be
//// provided by configuration data then we will build the string from that data.
//// that way an attacker can't trick the application into disclosing the true
//// authentication string -- they will only get out what they put in.
string SecurityKeyDisplayString(snfCFGData& D) { // Returns appropriate SecurityKey: data
string ConfigLogSecurityKey = "************************"; // Start with a masked display.
if(0 < D.node_licenseid.length()) { // If auth info is in the config files then
ConfigLogSecurityKey = D.node_licenseid + D.node_authentication; // build up the key from that data so it
} // can be displayed in the config log.
return ConfigLogSecurityKey;
}


void logCFGData(snfCFGData& D) { // Log interpreted cfg data (debug aid). void logCFGData(snfCFGData& D) { // Log interpreted cfg data (debug aid).


try { try {
string CFGLogPath; // Build the snf_cfg log path. string CFGLogPath; // Build the snf_cfg log path.
CFGLogPath = D.paths_log_path + CFGLogPath = D.paths_log_path +
D.node_licenseid + "_snf_engine_cfg.log";
D.node_licenseid + "_snf_engine_cfg.log";

ofstream cfgl(CFGLogPath.c_str(), ios::trunc); // Open and truncate the cfg log file. ofstream cfgl(CFGLogPath.c_str(), ios::trunc); // Open and truncate the cfg log file.
cfgl // Report important cfg information. cfgl // Report important cfg information.
<< "SNF Engine Configuration" << endl << "SNF Engine Configuration" << endl
<< " License: " << D.node_licenseid << endl << " License: " << D.node_licenseid << endl
<< " ConfigFilePath: " << D.ConfigFilePath << endl << " ConfigFilePath: " << D.ConfigFilePath << endl
<< " IdentityFilePath: " << D.node_identity << endl << " IdentityFilePath: " << D.node_identity << endl
<< " SecurityKey: " << D.SecurityKey << endl
<< " SecurityKey: " << SecurityKeyDisplayString(D) << endl
<< "_____" << endl << "_____" << endl
<< "Paths" << endl << "Paths" << endl
<< " Log Path: " << D.paths_log_path << endl << " Log Path: " << D.paths_log_path << endl
} }


//// The SecurityKey is built from the licenseID and the Authentication //// The SecurityKey is built from the licenseID and the Authentication
if(InitLicenseIdIsProvided) { // If the LicenseID has been provided then if(InitLicenseIdIsProvided) { // If the LicenseID has been provided then
CFGData.SecurityKey = InitLicenseId; // the first part of our security key is that. CFGData.SecurityKey = InitLicenseId; // the first part of our security key is that.
} else { // If it was not provided then we will get } else { // If it was not provided then we will get
CFGData.SecurityKey = CFGData.node_licenseid; // the LicenseID from our config file. CFGData.SecurityKey = CFGData.node_licenseid; // the LicenseID from our config file.
} }
string LicenseIDToUse = CFGData.SecurityKey; // Grab the License ID we want to use.


if(InitAuthenticationIsProvided) { // If the Authentication has been provided then if(InitAuthenticationIsProvided) { // If the Authentication has been provided then
CFGData.SecurityKey += InitAuthentication; // we use it for the second part of our CFGData.SecurityKey += InitAuthentication; // we use it for the second part of our


if(InitPathIsRulebase) { // If the Rulebase path was provided if(InitPathIsRulebase) { // If the Rulebase path was provided
CFGData.RuleFilePath = InitFileName; // then we have our rulebase path. CFGData.RuleFilePath = InitFileName; // then we have our rulebase path.
} else { // If not then we must figure it out...
} else { // If not then we must figure it out...
CFGData.RuleFilePath = // We build the path from the base CFGData.RuleFilePath = // We build the path from the base
CFGData.paths_rulebase_path + // rulebase path concattonated with CFGData.paths_rulebase_path + // rulebase path concattonated with
CFGData.node_licenseid + // the license id concattonated with
SNFExt; // the rulebase extension.
LicenseIDToUse + // the license id concattonated with
SNFExt; // the rulebase extension.
} }


// Once all of the configuration data is correct we make it active. // Once all of the configuration data is correct we make it active.

Loading…
Annulla
Salva