|
|
@@ -35,6 +35,8 @@ const std::string UtilityConfig::SampleIgnoreListFile("C:\\SNF\\GBUdbIgnoreList. |
|
|
|
|
|
|
|
const std::string UtilityConfig::RulebaseDownloadCommand("FIX THIS");
|
|
|
|
|
|
|
|
const std::string UtilityConfig::RulebaseDownloadStatusFile("FIX THIS");
|
|
|
|
|
|
|
|
const std::string ScriptNameKey("FIX THIS"); ///< Text to replace with script name.
|
|
|
|
const std::string SnifferPathKey("FIX THIS"); ///< Text to replace with directory of the rulebase.
|
|
|
|
|
|
|
@@ -54,6 +56,9 @@ const std::string UtilityConfig::RulebaseDownloadCommand |
|
|
|
const std::string ScriptNameKey("SCRIPT"); ///< Text to replace with script name.
|
|
|
|
const std::string SnifferPathKey("SNIFFER_PATH"); ///< Text to replace with directory of the rulebase.
|
|
|
|
|
|
|
|
// SNIFFER_PATH is replaced with the path of the rulebase.
|
|
|
|
const std::string UtilityConfig::RulebaseDownloadStatusFile("SNIFFER_PATH/getRulebase.status");
|
|
|
|
|
|
|
|
#ifdef DEFAULT_DATA_DIR
|
|
|
|
// *nix, DEFAULT_DATA_DIR is specified on the compile command line.
|
|
|
|
const std::string UtilityConfig::SampleIgnoreListFile(DEFAULT_DATA_DIR "/GBUdbIgnoreList.txt.sample");
|
|
|
@@ -103,6 +108,14 @@ const string LicenseIdKey("-id="); |
|
|
|
/// Authentication command-line input.
|
|
|
|
const string AuthenticationKey("-auth=");
|
|
|
|
|
|
|
|
/// String that indicates a successful rulebase download.
|
|
|
|
//
|
|
|
|
// This string must be in the last line of the getRulebase status
|
|
|
|
// file. Note: The getRulebase status file is created by the
|
|
|
|
// getRulebase script, has the name getRulebase.status, and is in the
|
|
|
|
// same directory as the rulebase files.
|
|
|
|
const string SuccessKey("Success");
|
|
|
|
|
|
|
|
const string LicenseSearchString = "LICENSE_ID=";
|
|
|
|
const string AuthSearchString = "AUTHENTICATION=";
|
|
|
|
|
|
|
@@ -607,6 +620,7 @@ UtilityConfig::DownloadRulebase() { |
|
|
|
if (Verbose()) {
|
|
|
|
|
|
|
|
std::cout << "Downloading the rulebase...";
|
|
|
|
std::cout.flush();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -630,10 +644,35 @@ UtilityConfig::DownloadRulebase() { |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string StatusFile; // Construct download status file name.
|
|
|
|
|
|
|
|
StatusFile = RulebaseDownloadStatusFile;
|
|
|
|
|
|
|
|
SnifferPathIndex = StatusFile.find(SnifferPathKey);
|
|
|
|
|
|
|
|
if (SnifferPathIndex != std::string::npos) { // Insert rulebase location?
|
|
|
|
|
|
|
|
StatusFile.replace(SnifferPathIndex, SnifferPathKey.length(), GetRulebasePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Explain()) {
|
|
|
|
|
|
|
|
if (std::system(Command.c_str()) != 0) {
|
|
|
|
if (0 != remove(StatusFile.c_str())) { // Delete the status file.
|
|
|
|
|
|
|
|
if (ENOENT != errno) { // No error if the file doesn't exist.
|
|
|
|
std::ostringstream Temp;
|
|
|
|
|
|
|
|
Temp << "Unable to remove rulebase download status file " << StatusFile
|
|
|
|
<< ": " << strerror(errno) << "\n";
|
|
|
|
|
|
|
|
throw runtime_error(Temp.str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (std::system(Command.c_str()) != 0) { // Download the rulebase.
|
|
|
|
string Temp;
|
|
|
|
|
|
|
|
Temp = "Error running the command '" + Command;
|
|
|
@@ -642,6 +681,37 @@ UtilityConfig::DownloadRulebase() { |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ifstream Input;
|
|
|
|
|
|
|
|
Input.open(StatusFile.c_str()); // Check the status.
|
|
|
|
if (!Input) {
|
|
|
|
string Temp;
|
|
|
|
|
|
|
|
Temp = "Error opening rulebase download scriptstatus file " + StatusFile;
|
|
|
|
Temp += ": ";
|
|
|
|
Temp += strerror(errno);
|
|
|
|
throw runtime_error(Temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
string Line;
|
|
|
|
string PrevLine;
|
|
|
|
string Content;
|
|
|
|
|
|
|
|
while (getline(Input, Line)) { // Read the last line.
|
|
|
|
|
|
|
|
PrevLine = Line;
|
|
|
|
Content += Line + "\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PrevLine.find(SuccessKey) == std::string::npos) { // Check the status.
|
|
|
|
string Temp;
|
|
|
|
|
|
|
|
Temp = "Error downloading the rulebase. Rulebase download status:\n\n" + Content;
|
|
|
|
throw runtime_error(Temp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputVerboseEnd();
|