浏览代码

cleaned up namespace and dropped inline snfCFGmgr

master
Pete McNeil 4 年前
父节点
当前提交
bb37eb00c3
共有 3 个文件被更改,包括 217 次插入226 次删除
  1. 172
    130
      snfCFGmgr.cpp
  2. 45
    50
      snfCFGmgr.hpp
  3. 0
    46
      snfCFGmgr.inline.hpp

+ 172
- 130
snfCFGmgr.cpp 查看文件

@@ -1,5 +1,5 @@
// snfCFGmgr.cpp
// Copyright (C) 2006 - 2009 Arm Research Labs, LLC
// Copyright (C) 2006 - 2020 Arm Research Labs, LLC
// See www.armresearch.com for the copyright terms.
//

@@ -8,6 +8,48 @@
#include "snfCFGmgr.hpp"
#include <iostream>

namespace cd = codedweller;

//// IntegerSetHandler /////////////////////////////////////////////////////////

bool IntegerSetHandler::isListed(int x) { // How to check if an int is listed.
return (IntegerSet.end() != IntegerSet.find(x));
}


//// snfCFGmgr /////////////////////////////////////////////////////////////////

snfCFGmgr::snfCFGmgr() : // We construct a CFGmgr this way...
AisActive(false), // So that A is active after 1st load()
InitFileName(""), // and all of the Init strings are
InitLicenseId(""), // empty.
InitAuthentication(""),
ConfigurationPath("") {
}

void snfCFGmgr::swapCFGData() { // This swaps the active dataset.
AisActive = (AisActive)?false:true;
}

snfCFGData& snfCFGmgr::ActiveData() { // This returns the active dataset.
return (AisActive) ? A : B;
}

snfCFGData& snfCFGmgr::InactiveData() { // This returns the inactive dataset.
return (AisActive) ? B : A;
}

std::string snfCFGmgr::RuleFilePath() { // Rulebase file path
return ActiveData().RuleFilePath;
}

std::string snfCFGmgr::SecurityKey() { // Security key for rulebase
return ActiveData().SecurityKey;
}

snfCFGData* snfCFGmgr::ActiveConfiguration() { // Pointer to active configuration
return &(ActiveData());
}

//// RangeHandler //////////////////////////////////////////////////////////////

@@ -16,7 +58,7 @@ bool RangeHandler::isInBlack(RangePoint& x) {
return false; // there is no map so there is
} // no side to be on.
// If there are points we will need
set<RangePoint>::iterator iRangePoint; // to examine them.
std::set<RangePoint>::iterator iRangePoint; // to examine them.
iRangePoint = EdgeMap.begin(); // What is the first point.

if(x < (*iRangePoint)) { // If x is below that then
@@ -67,7 +109,7 @@ bool RangeHandler::isInWhite(RangePoint& x) {
return false; // there is no map so there is
} // no side to be on.
// If ther are points then we
set<RangePoint>::iterator iRangePoint; // need to examine them.
std::set<RangePoint>::iterator iRangePoint; // need to examine them.
iRangePoint = EdgeMap.begin(); // What is the first point.

if(x < (*iRangePoint)) { // If x is below that then
@@ -466,7 +508,7 @@ snfCFGData::snfCFGData() :
.End("snf");
}

void fixPathTermination(string& s) { // Ensure s ends in a / or a \ as needed.
void fixPathTermination(std::string& s) { // Ensure s ends in a / or a \ as needed.

if(0 == s.length()) return; // If the string is empty we do nothing.

@@ -474,7 +516,7 @@ void fixPathTermination(string& s) {
// see what separator has already been used.

char Terminator; // This will be our terminator.
if(string::npos == s.find('\\')) { // If we're not using a backslash then
if(std::string::npos == s.find('\\')) { // If we're not using a backslash then
Terminator = '/'; // we will use the forward slash.
} else { // If we are using the backslash then
Terminator = '\\'; // we will remain consistent and terminate
@@ -573,8 +615,8 @@ void snfCFGmgr::initialize(
//// 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.
std::string SecurityKeyDisplayString(snfCFGData& D) { // Returns appropriate SecurityKey: data
std::string ConfigLogSecurityKey = "************************"; // Start with a masked display.
if(0 < D.node_authentication.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.
@@ -584,51 +626,51 @@ string SecurityKeyDisplayString(snfCFGData& D) {
void logCFGData(snfCFGData& D) { // Log interpreted cfg data (debug aid).

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

ofstream cfgl(CFGLogPath.c_str(), ios::trunc); // Open and truncate the cfg log file.
std::ofstream cfgl(CFGLogPath.c_str(), std::ios::trunc); // Open and truncate the cfg log file.
cfgl // Report important cfg information.
<< "SNF Engine Configuration" << endl
<< "____________" << endl
<< "Fundamentals" << endl
<< " License: " << D.node_licenseid << endl
<< " ConfigFilePath: " << D.ConfigFilePath << endl
<< " IdentityFilePath: " << D.node_identity << endl
<< " SecurityKey: " << SecurityKeyDisplayString(D) << endl
<< "_____" << endl
<< "Paths" << endl
<< " Log Path: " << D.paths_log_path << endl
<< " Rulebase Path: " << D.paths_rulebase_path << endl
<< " Workspace Path: " << D.paths_workspace_path << endl
<< " RuleFilePath: " << D.RuleFilePath << endl
<< "____" << endl
<< "Logs" << endl
<< endl
<< " Rotation-Midnight: " << ((D.Logs_Rotation_LocalTime_OnOff)? "Local" : "UTC") << endl
<< " ______" << endl
<< " Status" << endl
<< "SNF Engine Configuration" << std::endl
<< "____________" << std::endl
<< "Fundamentals" << std::endl
<< " License: " << D.node_licenseid << std::endl
<< " ConfigFilePath: " << D.ConfigFilePath << std::endl
<< " IdentityFilePath: " << D.node_identity << std::endl
<< " SecurityKey: " << SecurityKeyDisplayString(D) << std::endl
<< "_____" << std::endl
<< "Paths" << std::endl
<< " Log Path: " << D.paths_log_path << std::endl
<< " Rulebase Path: " << D.paths_rulebase_path << std::endl
<< " Workspace Path: " << D.paths_workspace_path << std::endl
<< " RuleFilePath: " << D.RuleFilePath << std::endl
<< "____" << std::endl
<< "Logs" << std::endl
<< std::endl
<< " Rotation-Midnight: " << ((D.Logs_Rotation_LocalTime_OnOff)? "Local" : "UTC") << std::endl
<< " ______" << std::endl
<< " Status" << std::endl
<< " PerSecond: "
<< ((D.Status_SecondReport_Log_OnOff)? "yes, " : "no, ")
<< "Append: "
<< ((D.Status_SecondReport_Append_OnOff)? "yes" : "no")
<< endl
<< std::endl
<< " PerMinute: "
<< ((D.Status_MinuteReport_Log_OnOff)? "yes, " : "no, ")
<< "Append: "
<< ((D.Status_MinuteReport_Append_OnOff)? "yes" : "no")
<< endl
<< std::endl
<< " PerHour: "
<< ((D.Status_HourReport_Log_OnOff)? "yes, " : "no, ")
<< "Append: "
<< ((D.Status_HourReport_Append_OnOff)? "yes" : "no")
<< endl
<< " ____" << endl
<< " Scan" << endl
<< std::endl
<< " ____" << std::endl
<< " Scan" << std::endl
<< " Identifier: "
<< ((D.Scan_Identifier_Force_Message_Id)? "Force RFC822 Message-ID" : "Use Provided Identifier")
<< endl
<< std::endl
<< " Classic: Output-"
<< ((LogOutputMode_None == D.Scan_Classic_Mode)? "None, " :
((LogOutputMode_API == D.Scan_Classic_Mode)? "API, " :
@@ -637,7 +679,7 @@ void logCFGData(snfCFGData& D) {
<< ((D.Scan_Classic_Matches == ScanLogMatches_None) ? "No Mathes":
((D.Scan_Classic_Matches == ScanLogMatches_Unique) ? "Unique Matches":
((D.Scan_Classic_Matches == ScanLogMatches_All) ? "All Matches" : "Error!")))
<< endl
<< std::endl
<< " XML: Output-"
<< ((LogOutputMode_None == D.Scan_XML_Mode)? "None, " :
((LogOutputMode_API == D.Scan_XML_Mode)? "API, " :
@@ -648,134 +690,134 @@ void logCFGData(snfCFGData& D) {
((D.Scan_XML_Matches == ScanLogMatches_All) ? "All Matches, " : "Match Error! ")))
<< ((D.Scan_XML_Performance)? "Performance Metrics, " : "No Performance Metrics, ")
<< ((D.Scan_XML_GBUdb)? "GBUdb Data" : "No GBUdb Data")
<< endl
<< " XHeaders:" << endl
<< std::endl
<< " XHeaders:" << std::endl
<< " Output: "
<< ((LogOutputMode_None == D.XHDROutput_Mode) ? "None" :
((LogOutputMode_API == D.XHDROutput_Mode) ? "API" :
((LogOutputMode_File == D.XHDROutput_Mode) ? "File" :
((LogOutputMode_Inject == D.XHDROutput_Mode)? "Inject" : "Error!"))))
<< endl
<< std::endl
<< " Version: "
<< ((D.XHDRVersion_OnOff)? "On, " : "Off, ")
<< D.XHDRVersion_Header
<< endl
<< std::endl
<< " License: "
<< ((D.XHDRLicense_OnOff)? "On, " : "Off, ")
<< D.XHDRLicense_Header
<< endl
<< std::endl
<< " Rulebase: "
<< ((D.XHDRRulebase_OnOff)? "On, " : "Off, ")
<< D.XHDRRulebase_Header
<< endl
<< std::endl
<< " Identifier: "
<< ((D.XHDRIdentifier_OnOff)? "On, " : "Off, ")
<< D.XHDRIdentifier_Header
<< endl
<< std::endl
<< " GBUdb: "
<< ((D.XHDRGBUdb_OnOff)? "On, " : "Off, ")
<< D.XHDRGBUdb_Header
<< endl
<< std::endl
<< " Result: "
<< ((D.XHDRResult_OnOff)? "On, " : "Off, ")
<< D.XHDRResult_Header
<< endl
<< std::endl
<< " Matches: "
<< ((D.XHDRMatches_OnOff)? "On, " : "Off, ")
<< D.XHDRMatches_Header
<< endl
<< std::endl
<< " Black: "
<< ((D.XHDRBlack_OnOff)? "On, " : "Off, ")
<< D.XHDRBlack_Header
<< endl
<< std::endl
<< " White: "
<< ((D.XHDRWhite_OnOff)? "On, " : "Off, ")
<< D.XHDRWhite_Header
<< endl
<< std::endl
<< " Clean: "
<< ((D.XHDRClean_OnOff)? "On, " : "Off, ")
<< D.XHDRClean_Header
<< endl;
<< std::endl;

for(
set<XHDRSymbol>::iterator iH = D.XHDRSymbolHeaders.SymbolHeaders.begin();
std::set<XHDRSymbol>::iterator iH = D.XHDRSymbolHeaders.SymbolHeaders.begin();
iH != D.XHDRSymbolHeaders.SymbolHeaders.end(); iH++
) {
cfgl
<< " Symbol: "
<< (*iH).Symbol << ", "
<< (*iH).Header
<< endl;
<< std::endl;
}

cfgl
<< "_______" << endl
<< "Network" << endl
<< " Sync Host: " << D.network_sync_host << endl
<< " Sync Port: " << D.network_sync_port << endl
<< " Sync Secs: " << D.network_sync_secs << endl
<< " _____________" << endl
<< " Update-Script" << endl
<< " On-Off: " << ((D.update_script_on_off) ? "On" : "Off") << endl
<< " Script: " << D.update_script_call << endl
<< " Guard-Time: " << D.update_script_guard_time << " seconds" << endl
<< "___" << endl
<< "XCI" << endl
<< " " << ((D.XCI_OnOff)? "Enabled" : "Disabled") << endl
<< " Port: " << D.XCI_Port << endl
<< "_____" << endl
<< "GBUdb" << endl
<< " ____________" << endl
<< " Condensation" << endl
<< " Minimum-Seconds-Between = " << D.gbudb_database_condense_minimum_seconds_between << endl
<< "_______" << std::endl
<< "Network" << std::endl
<< " Sync Host: " << D.network_sync_host << std::endl
<< " Sync Port: " << D.network_sync_port << std::endl
<< " Sync Secs: " << D.network_sync_secs << std::endl
<< " _____________" << std::endl
<< " Update-Script" << std::endl
<< " On-Off: " << ((D.update_script_on_off) ? "On" : "Off") << std::endl
<< " Script: " << D.update_script_call << std::endl
<< " Guard-Time: " << D.update_script_guard_time << " seconds" << std::endl
<< "___" << std::endl
<< "XCI" << std::endl
<< " " << ((D.XCI_OnOff)? "Enabled" : "Disabled") << std::endl
<< " Port: " << D.XCI_Port << std::endl
<< "_____" << std::endl
<< "GBUdb" << std::endl
<< " ____________" << std::endl
<< " Condensation" << std::endl
<< " Minimum-Seconds-Between = " << D.gbudb_database_condense_minimum_seconds_between << std::endl
<< " Time-Trigger: "
<< ((D.gbudb_database_condense_time_trigger_on_off)? "on, " : "off, ")
<< D.gbudb_database_condense_time_trigger_seconds << " seconds" << endl
<< D.gbudb_database_condense_time_trigger_seconds << " seconds" << std::endl
<< " Posts-Trigger: "
<< ((D.gbudb_database_condense_posts_trigger_on_off)? "on, " : "off, ")
<< D.gbudb_database_condense_posts_trigger_posts << " posts" << endl
<< D.gbudb_database_condense_posts_trigger_posts << " posts" << std::endl
<< " Records-Trigger: "
<< ((D.gbudb_database_condense_records_trigger_on_off) ? "on, " : "off, ")
<< D.gbudb_database_condense_records_trigger_records << " records" << endl
<< D.gbudb_database_condense_records_trigger_records << " records" << std::endl
<< " Size-Trigger: "
<< ((D.gbudb_database_condense_size_trigger_on_off) ? "on, " : "off, ")
<< D.gbudb_database_condense_size_trigger_megabytes << " megabytes" << endl
<< " __________" << endl
<< " Checkpoint" << endl
<< D.gbudb_database_condense_size_trigger_megabytes << " megabytes" << std::endl
<< " __________" << std::endl
<< " Checkpoint" << std::endl
<< " Checkpoint: "
<< ((D.gbudb_database_checkpoint_on_off) ? "on, " : "off, ")
<< D.gbudb_database_checkpoint_secs << " seconds" << endl
<< " ______" << endl
<< " Ranges" << endl
<< D.gbudb_database_checkpoint_secs << " seconds" << std::endl
<< " ______" << std::endl
<< " Ranges" << std::endl
<< " White: "
<< ((D.WhiteRangeHandler.On_Off) ? "on, " : "off, ")
<< "Symbol " << D.WhiteRangeHandler.Symbol << endl
<< "Symbol " << D.WhiteRangeHandler.Symbol << std::endl
<< " Auto-Panic: "
<< ((D.gbudb_regions_white_panic_on_off) ? "on, " : "off, ")
<< "Range " << D.gbudb_regions_white_panic_rule_range << endl
<< endl
<< "Range " << D.gbudb_regions_white_panic_rule_range << std::endl
<< std::endl
<< " Caution: "
<< ((D.CautionRangeHandler.On_Off) ? "on, " : "off, ")
<< "Symbol " << D.CautionRangeHandler.Symbol << endl
<< endl
<< "Symbol " << D.CautionRangeHandler.Symbol << std::endl
<< std::endl
<< " Black: "
<< ((D.BlackRangeHandler.On_Off) ? "on, " : "off, ")
<< "Symbol " << D.BlackRangeHandler.Symbol << endl
<< "Symbol " << D.BlackRangeHandler.Symbol << std::endl
<< " Truncate: "
<< ((D.gbudb_regions_black_truncate_on_off) ? "on, " : "off, ")
<< "Probability " << D.gbudb_regions_black_truncate_probability << ", "
<< "Peek-One-In " << D.gbudb_regions_black_truncate_peek_one_in << ", "
<< "Symbol " << D.gbudb_regions_black_truncate_symbol << endl
<< "Symbol " << D.gbudb_regions_black_truncate_symbol << std::endl
<< " Sample: "
<< ((D.gbudb_regions_black_sample_on_off) ? "on, " : "off, ")
<< "Probability: " << D.gbudb_regions_black_sample_probability << ", "
<< "Grab-One-In: " << D.gbudb_regions_black_sample_grab_one_in << ", " << endl
<< "Grab-One-In: " << D.gbudb_regions_black_sample_grab_one_in << ", " << std::endl
<< " Passthrough: "
<< ((D.gbudb_regions_black_sample_passthrough) ? "yes, " : "no, ")
<< "Passthrough Symbol " << D.gbudb_regions_black_sample_passthrough_symbol << endl
<< endl
<< " Range Map - [W]hite [B]lack [C]aution [ ]undefined" << endl << endl
<< " |-9876543210123456789+|" << endl;
<< "Passthrough Symbol " << D.gbudb_regions_black_sample_passthrough_symbol << std::endl
<< std::endl
<< " Range Map - [W]hite [B]lack [C]aution [ ]undefined" << std::endl << std::endl
<< " |-9876543210123456789+|" << std::endl;

// Output GBUdb Range Map

@@ -795,20 +837,20 @@ void logCFGData(snfCFGData& D) {
cfgl << " "; // Otherwise put in a space.
}
}
cfgl << "|" << c << endl;
cfgl << "|" << c << std::endl;
}
cfgl << " |---------------------|" << endl;
cfgl << " |---------------------|" << std::endl;

cfgl
<< endl
<< " ________" << endl
<< " Training" << endl
<< std::endl
<< " ________" << std::endl
<< " Training" << std::endl
<< " GBUdb Updates: "
<< ((D.GBUdbTrainingOn_Off)? "Enabled" : "Disabled") << endl
<< endl;
<< ((D.GBUdbTrainingOn_Off)? "Enabled" : "Disabled") << std::endl
<< std::endl;

cfgl
<< " Source Header Directives: " << endl;
<< " Source Header Directives: " << std::endl;
for(
HeaderDirectiveSet::iterator iD = D.HeaderDirectivesHandler.HeaderDirectives.begin();
iD != D.HeaderDirectivesHandler.HeaderDirectives.end(); iD++
@@ -820,20 +862,20 @@ void logCFGData(snfCFGData& D) {
<< "Context " << Dx.Context << " is a "
<< Dx.Header << " header at"
<< " Ordinal " << Dx.Ordinal
<< " that Contains " << Dx.Contains << endl;
<< " that Contains " << Dx.Contains << std::endl;
} else
if(HeaderDirectiveSource == Dx.Directive) {
cfgl
<< " "
<< "Context " << Dx.Context << " Source ip is in "
<< Dx.Header << " header at"
<< " Ordinal " << Dx.Ordinal << endl;
<< " Ordinal " << Dx.Ordinal << std::endl;
}
}
cfgl << endl;
cfgl << std::endl;

cfgl
<< " Drilldown Header Directives: " << endl;
<< " Drilldown Header Directives: " << std::endl;
for(
HeaderDirectiveSet::iterator iD = D.HeaderDirectivesHandler.HeaderDirectives.begin();
iD != D.HeaderDirectivesHandler.HeaderDirectives.end(); iD++
@@ -844,13 +886,13 @@ void logCFGData(snfCFGData& D) {
<< " "
<< Dx.Header << " header at"
<< " Ordinal " << Dx.Ordinal
<< " Contains " << Dx.Contains << endl;
<< " Contains " << Dx.Contains << std::endl;
}
}
cfgl << endl;
cfgl << std::endl;

cfgl
<< " Bypass Header Directives: " << endl;
<< " Bypass Header Directives: " << std::endl;
for(
HeaderDirectiveSet::iterator iD = D.HeaderDirectivesHandler.HeaderDirectives.begin();
iD != D.HeaderDirectivesHandler.HeaderDirectives.end(); iD++
@@ -861,13 +903,13 @@ void logCFGData(snfCFGData& D) {
<< " "
<< Dx.Header << " header at"
<< " Ordinal " << Dx.Ordinal
<< " Contains " << Dx.Contains << endl;
<< " Contains " << Dx.Contains << std::endl;
}
}
cfgl << endl;
cfgl << std::endl;

cfgl
<< " White Rule Header Directives: " << endl;
<< " White Rule Header Directives: " << std::endl;
for(
HeaderDirectiveSet::iterator iD = D.HeaderDirectivesHandler.HeaderDirectives.begin();
iD != D.HeaderDirectivesHandler.HeaderDirectives.end(); iD++
@@ -878,10 +920,10 @@ void logCFGData(snfCFGData& D) {
<< " "
<< Dx.Header << " header at"
<< " Ordinal " << Dx.Ordinal
<< " Contains " << Dx.Contains << endl;
<< " Contains " << Dx.Contains << std::endl;
}
}
cfgl << endl;
cfgl << std::endl;

cfgl
<< " White Rule Symbols: ";
@@ -889,7 +931,7 @@ void logCFGData(snfCFGData& D) {
// Output white rule symbols

for(
set<int>::iterator ix = D.TrainingWhiteRuleHandler.IntegerSet.begin();
std::set<int>::iterator ix = D.TrainingWhiteRuleHandler.IntegerSet.begin();
ix != D.TrainingWhiteRuleHandler.IntegerSet.end();
ix ++) {
if(D.TrainingWhiteRuleHandler.IntegerSet.begin() != ix) {
@@ -897,47 +939,47 @@ void logCFGData(snfCFGData& D) {
}
cfgl << (*ix);
}
cfgl << endl;
cfgl << std::endl;

// Rule Panics

cfgl
<< "___________" << endl
<< "Rule-Panics" << endl;
<< "___________" << std::endl
<< "Rule-Panics" << std::endl;

for(
set<int>::iterator ix = D.RulePanicHandler.IntegerSet.begin();
std::set<int>::iterator ix = D.RulePanicHandler.IntegerSet.begin();
ix != D.RulePanicHandler.IntegerSet.end();
ix ++) {
cfgl << " Rule ID: " << (*ix) << endl;
cfgl << " Rule ID: " << (*ix) << std::endl;
}
cfgl << endl;
cfgl << std::endl;

cfgl
<< "___________" << endl
<< "Integration" << endl
<< endl
<< "___________" << std::endl
<< "Integration" << std::endl
<< std::endl
<< " Message Format: "
<< ((D.MessageFileTypeCGP_on_off)? "CGP" : "RFC822")
<< endl;
<< std::endl;

#ifdef __BIG_ENDIAN__

cfgl << " Rulebase Conversion: BIG ENDIAN" << endl;
cfgl << " Rulebase Conversion: BIG ENDIAN" << std::endl;

#else

cfgl << " Rulebase Conversion: LITTLE ENDIAN" << endl;
cfgl << " Rulebase Conversion: LITTLE ENDIAN" << std::endl;

#endif

cfgl
<< "________" << endl
<< "Platform" << endl
<< "________" << std::endl
<< "Platform" << std::endl
<< D.PlatformElementContents
<< endl;
<< std::endl;

cfgl << endl; // End with a new line.
cfgl << std::endl; // End with a new line.
cfgl.close(); // Close the cfg log file.
} catch (...) {} // Ignore any errors.
}
@@ -955,8 +997,8 @@ void snfCFGmgr::load() {
int PathLength = InitFileName.length(); // How long is the path?
const int MinimumPathLength = 12; // Must be at least licensid.snf long.
if(MinimumPathLength > PathLength) throw LoadFailure(); // Path length is impossible? throw!
const string SNFExt = ".snf"; // The extension we are looking for.
const string CFGExt = ".xml"; // The default cfg extension.
const std::string SNFExt = ".snf"; // The extension we are looking for.
const std::string CFGExt = ".xml"; // The default cfg extension.
const int SNFExtLength = SNFExt.length(); // The length of the extension.
int SNFExtPosition = InitFileName.rfind(SNFExt,PathLength); // Find the extension at the end.

@@ -1006,7 +1048,7 @@ void snfCFGmgr::load() {
CFGData.SecurityKey = CFGData.node_licenseid; // the LicenseID from our config file.
}

string LicenseIDToUse = CFGData.SecurityKey; // Grab the License ID we want to use.
std::string LicenseIDToUse = CFGData.SecurityKey; // Grab the License ID we want to use.

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

+ 45
- 50
snfCFGmgr.hpp 查看文件

@@ -1,13 +1,12 @@
// snfCFGmgr.hpp
// Copyright (C) 2006 - 2009 Arm Research Labs, LLC
// Copyright (C) 2006 - 2020 Arm Research Labs, LLC
// See www.armresearch.com for the copyright terms.
//
// SNF Configuration manager.

//// Begin include only once

#ifndef included_snfCFGmgr_hpp
#define included_snfCFGmgr_hpp
#pragma once

#include "GBUdb.hpp"
#include "snf_HeaderFinder.hpp"
@@ -198,7 +197,7 @@ class RangeHandler : public cd::Configurator {
int Priority; // They have an evaluation priority.

RangePoint EdgeInput; // This EdgePoint is set, and added using ().
set<RangePoint> EdgeMap; // This contains the set of EdgePoints.
std::set<RangePoint> EdgeMap; // This contains the set of EdgePoints.

bool isInWhite(RangePoint& x); // True if x is inside the -P of the EdgeMap.
bool isInBlack(RangePoint& x); // True if x is inside the +P of the EdgeMap.
@@ -232,7 +231,7 @@ class IntegerSetHandler : public cd::Configurator {
}

int IntegerInput; // The input port.
set<int> IntegerSet; // The set itself.
std::set<int> IntegerSet; // The set itself.

bool isListed(int x); // How to check if an int is listed.

@@ -260,8 +259,8 @@ class IntegerSetInitializer : public cd::Configurator {
class XHDRSymbol { // XHeader associated with a Symbol
public:
int Symbol; // The integer symbol.
string Header; // The header to associate.
XHDRSymbol(int FreshSymbol, string FreshHeader) : // Creating the object requires both.
std::string Header; // The header to associate.
XHDRSymbol(int FreshSymbol, std::string FreshHeader) : // Creating the object requires both.
Symbol(FreshSymbol),
Header(FreshHeader) {}

@@ -272,22 +271,22 @@ class XHDRSymbol {

class XHDRSymbolsHandler : public cd::Configurator { // XHDRSymbol hander.
public:
set<XHDRSymbol> SymbolHeaders; // Carries a set of Symbol Headers.
std::set<XHDRSymbol> SymbolHeaders; // Carries a set of Symbol Headers.

void reset() { SymbolHeaders.clear(); } // Is reset by clearing the set.

string HeaderForSymbol(int S) { // Can return a Header for symbol.
string MatchingHeader = ""; // Starting with an empty string,
set<XHDRSymbol>::iterator iS = SymbolHeaders.find(XHDRSymbol(S,"")); // we look up the symbol and
if(SymbolHeaders.end() != iS) { // if we find it then we will
MatchingHeader = (*iS).Header; // return the matching header
} // string. If not then we return
return MatchingHeader; // the empty string.
} // Coded in-line on purpose.
std::string HeaderForSymbol(int S) { // Can return a Header for symbol.
std::string MatchingHeader = ""; // Starting with an empty string,
std::set<XHDRSymbol>::iterator iS = SymbolHeaders.find(XHDRSymbol(S,"")); // we look up the symbol and
if(SymbolHeaders.end() != iS) { // if we find it then we will
MatchingHeader = (*iS).Header; // return the matching header
} // string. If not then we return
return MatchingHeader; // the empty string.
} // Coded in-line on purpose.

bool OnOff; // Input OnOff value.
int Symbol; // Input Symbol value.
string Header; // Input Header value.
std::string Header; // Input Header value.

void operator()(cd::ConfigurationElement& E, cd::ConfigurationData& D) { // The operator() inserts an XHDRSymbol
if(OnOff) { // if the header entry is turned on and
@@ -348,21 +347,21 @@ class snfCFGData {

// Here are the derived data elements...

string ConfigFilePath; // Configuration file path
string RuleFilePath; // Rulebase file path
string SecurityKey; // Security key for rulebase
std::string ConfigFilePath; // Configuration file path
std::string RuleFilePath; // Rulebase file path
std::string SecurityKey; // Security key for rulebase

// Here are the basic data elements...

string node_identity;
string node_licenseid;
string node_authentication;
std::string node_identity;
std::string node_licenseid;
std::string node_authentication;

//// paths

string paths_workspace_path;
string paths_rulebase_path;
string paths_log_path;
std::string paths_workspace_path;
std::string paths_rulebase_path;
std::string paths_log_path;

//// logging

@@ -392,50 +391,50 @@ class snfCFGData {
int XHDROutput_Mode;

bool XHDRVersion_OnOff;
string XHDRVersion_Header;
std::string XHDRVersion_Header;

bool XHDRLicense_OnOff;
string XHDRLicense_Header;
std::string XHDRLicense_Header;

bool XHDRRulebase_OnOff;
string XHDRRulebase_Header;
std::string XHDRRulebase_Header;

bool XHDRIdentifier_OnOff;
string XHDRIdentifier_Header;
std::string XHDRIdentifier_Header;

bool XHDRGBUdb_OnOff;
string XHDRGBUdb_Header;
std::string XHDRGBUdb_Header;

bool XHDRResult_OnOff;
string XHDRResult_Header;
std::string XHDRResult_Header;

bool XHDRMatches_OnOff;
string XHDRMatches_Header;
std::string XHDRMatches_Header;

bool XHDRBlack_OnOff;
string XHDRBlack_Header;
std::string XHDRBlack_Header;

bool XHDRWhite_OnOff;
string XHDRWhite_Header;
std::string XHDRWhite_Header;

bool XHDRClean_OnOff;
string XHDRClean_Header;
std::string XHDRClean_Header;

XHDRSymbolsHandler XHDRSymbolHeaders;
XHDRSymbolsInitializer XHDRSymbolHeadersInitializer;

//// platform

string PlatformElementContents;
std::string PlatformElementContents;

//// network

int network_sync_secs;
string network_sync_host;
std::string network_sync_host;
int network_sync_port;

bool update_script_on_off;
string update_script_call;
std::string update_script_call;
int update_script_guard_time;

//// gbudb
@@ -508,7 +507,7 @@ class snfCFGmgr {

private:

Mutex myMutex; // Serialize control during updates.
cd::Mutex myMutex; // Serialize control during updates.

snfCFGData A; // This is where we store one copy.
snfCFGData B; // This is where we store the other.
@@ -519,11 +518,11 @@ class snfCFGmgr {
snfCFGData& ActiveData(); // This returns the active dataset.
snfCFGData& InactiveData(); // This returns the inactive dataset.

string InitFileName; // Initilization parameters are reused
string InitLicenseId; // any time load() is called.
string InitAuthentication;
std::string InitFileName; // Initilization parameters are reused
std::string InitLicenseId; // any time load() is called.
std::string InitAuthentication;

string ConfigurationPath; // Path to active configuration file.
std::string ConfigurationPath; // Path to active configuration file.

public:

@@ -541,14 +540,10 @@ class snfCFGmgr {

//// Access methods for config data...

string RuleFilePath(); // Rulebase file path
string SecurityKey(); // Security key for rulebase
std::string RuleFilePath(); // Rulebase file path
std::string SecurityKey(); // Security key for rulebase

snfCFGData* ActiveConfiguration(); // Pointer to active configuration

};

#include "snfCFGmgr.inline.hpp"

#endif
// End include only once

+ 0
- 46
snfCFGmgr.inline.hpp 查看文件

@@ -1,46 +0,0 @@
// snfCFGmgr.inline.hpp
//
// (C) Copyright 2006 - 2009 ARM Research Labs, LLC.
//
// Inline functions/methods for snfCFGmgr module.

//// IntegerSetHandler /////////////////////////////////////////////////////////

inline bool IntegerSetHandler::isListed(int x) { // How to check if an int is listed.
return (IntegerSet.end() != IntegerSet.find(x));
}


//// snfCFGmgr /////////////////////////////////////////////////////////////////

inline snfCFGmgr::snfCFGmgr() : // We construct a CFGmgr this way...
AisActive(false), // So that A is active after 1st load()
InitFileName(""), // and all of the Init strings are
InitLicenseId(""), // empty.
InitAuthentication(""),
ConfigurationPath("") {
}

inline void snfCFGmgr::swapCFGData() { // This swaps the active dataset.
AisActive = (AisActive)?false:true;
}

inline snfCFGData& snfCFGmgr::ActiveData() { // This returns the active dataset.
return (AisActive) ? A : B;
}

inline snfCFGData& snfCFGmgr::InactiveData() { // This returns the inactive dataset.
return (AisActive) ? B : A;
}

inline string snfCFGmgr::RuleFilePath() { // Rulebase file path
return ActiveData().RuleFilePath;
}

inline string snfCFGmgr::SecurityKey() { // Security key for rulebase
return ActiveData().SecurityKey;
}

inline snfCFGData* snfCFGmgr::ActiveConfiguration() { // Pointer to active configuration
return &(ActiveData());
}

正在加载...
取消
保存