Added Postpone action which allows SNF4CGP to exercise CGPs REJECTED response. Updated SNF4CGP revision numbers appropriately. git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@51 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfcmaster
const string BypassMnemonic = IntAsString(ResultConfiguration::Bypass); | const string BypassMnemonic = IntAsString(ResultConfiguration::Bypass); | ||||
const string DeleteMnemonic = IntAsString(ResultConfiguration::Delete); | const string DeleteMnemonic = IntAsString(ResultConfiguration::Delete); | ||||
const string HoldMnemonic = IntAsString(ResultConfiguration::Hold); | const string HoldMnemonic = IntAsString(ResultConfiguration::Hold); | ||||
const string PostponeMnemonic = IntAsString(ResultConfiguration::Postpone); | |||||
const string RejectMnemonic = IntAsString(ResultConfiguration::Reject); | const string RejectMnemonic = IntAsString(ResultConfiguration::Reject); | ||||
const string SetTrueMnemonic = IntAsString(InputGroup::SetTrue); | const string SetTrueMnemonic = IntAsString(InputGroup::SetTrue); | ||||
const string SetFalseMnemonic = IntAsString(InputGroup::SetFalse); | const string SetFalseMnemonic = IntAsString(InputGroup::SetFalse); | ||||
.Mnemonic("Bypass", BypassMnemonic) | .Mnemonic("Bypass", BypassMnemonic) | ||||
.Mnemonic("Delete", DeleteMnemonic) | .Mnemonic("Delete", DeleteMnemonic) | ||||
.Mnemonic("Hold", HoldMnemonic) | .Mnemonic("Hold", HoldMnemonic) | ||||
.Mnemonic("Postpone", PostponeMnemonic) | |||||
.Mnemonic("Reject", RejectMnemonic) | .Mnemonic("Reject", RejectMnemonic) | ||||
.Mnemonic("allow", AllowMnemonic) | .Mnemonic("allow", AllowMnemonic) | ||||
.Mnemonic("bypass", BypassMnemonic) | .Mnemonic("bypass", BypassMnemonic) | ||||
.Mnemonic("delete", DeleteMnemonic) | .Mnemonic("delete", DeleteMnemonic) | ||||
.Mnemonic("hold", HoldMnemonic) | .Mnemonic("hold", HoldMnemonic) | ||||
.Mnemonic("postpone", PostponeMnemonic) | |||||
.Mnemonic("reject", RejectMnemonic) | .Mnemonic("reject", RejectMnemonic) | ||||
.Attribute("headers", HamInputDefaults.InjectHeaders, InputGroup::NotSet) | .Attribute("headers", HamInputDefaults.InjectHeaders, InputGroup::NotSet) | ||||
.Mnemonic("Yes", SetTrueMnemonic) | .Mnemonic("Yes", SetTrueMnemonic) | ||||
.Mnemonic("Bypass", BypassMnemonic) | .Mnemonic("Bypass", BypassMnemonic) | ||||
.Mnemonic("Delete", DeleteMnemonic) | .Mnemonic("Delete", DeleteMnemonic) | ||||
.Mnemonic("Hold", HoldMnemonic) | .Mnemonic("Hold", HoldMnemonic) | ||||
.Mnemonic("Postpone", PostponeMnemonic) | |||||
.Mnemonic("Reject", RejectMnemonic) | .Mnemonic("Reject", RejectMnemonic) | ||||
.Mnemonic("allow", AllowMnemonic) | .Mnemonic("allow", AllowMnemonic) | ||||
.Mnemonic("bypass", BypassMnemonic) | .Mnemonic("bypass", BypassMnemonic) | ||||
.Mnemonic("delete", DeleteMnemonic) | .Mnemonic("delete", DeleteMnemonic) | ||||
.Mnemonic("hold", HoldMnemonic) | .Mnemonic("hold", HoldMnemonic) | ||||
.Mnemonic("postpone", PostponeMnemonic) | |||||
.Mnemonic("reject", RejectMnemonic) | .Mnemonic("reject", RejectMnemonic) | ||||
.Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet) | .Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet) | ||||
.Mnemonic("Yes", SetTrueMnemonic) | .Mnemonic("Yes", SetTrueMnemonic) | ||||
.Mnemonic("Bypass", BypassMnemonic) | .Mnemonic("Bypass", BypassMnemonic) | ||||
.Mnemonic("Delete", DeleteMnemonic) | .Mnemonic("Delete", DeleteMnemonic) | ||||
.Mnemonic("Hold", HoldMnemonic) | .Mnemonic("Hold", HoldMnemonic) | ||||
.Mnemonic("Postpone", PostponeMnemonic) | |||||
.Mnemonic("Reject", RejectMnemonic) | .Mnemonic("Reject", RejectMnemonic) | ||||
.Mnemonic("allow", AllowMnemonic) | .Mnemonic("allow", AllowMnemonic) | ||||
.Mnemonic("bypass", BypassMnemonic) | .Mnemonic("bypass", BypassMnemonic) | ||||
.Mnemonic("delete", DeleteMnemonic) | .Mnemonic("delete", DeleteMnemonic) | ||||
.Mnemonic("hold", HoldMnemonic) | .Mnemonic("hold", HoldMnemonic) | ||||
.Mnemonic("postpone", PostponeMnemonic) | |||||
.Mnemonic("reject", RejectMnemonic) | .Mnemonic("reject", RejectMnemonic) | ||||
.Attribute("headers", SpamInputDefaults.InjectHeaders, InputGroup::NotSet) | .Attribute("headers", SpamInputDefaults.InjectHeaders, InputGroup::NotSet) | ||||
.Mnemonic("Yes", SetTrueMnemonic) | .Mnemonic("Yes", SetTrueMnemonic) | ||||
.Mnemonic("Bypass", BypassMnemonic) | .Mnemonic("Bypass", BypassMnemonic) | ||||
.Mnemonic("Delete", DeleteMnemonic) | .Mnemonic("Delete", DeleteMnemonic) | ||||
.Mnemonic("Hold", HoldMnemonic) | .Mnemonic("Hold", HoldMnemonic) | ||||
.Mnemonic("Postpone", PostponeMnemonic) | |||||
.Mnemonic("Reject", RejectMnemonic) | .Mnemonic("Reject", RejectMnemonic) | ||||
.Mnemonic("allow", AllowMnemonic) | .Mnemonic("allow", AllowMnemonic) | ||||
.Mnemonic("bypass", BypassMnemonic) | .Mnemonic("bypass", BypassMnemonic) | ||||
.Mnemonic("delete", DeleteMnemonic) | .Mnemonic("delete", DeleteMnemonic) | ||||
.Mnemonic("hold", HoldMnemonic) | .Mnemonic("hold", HoldMnemonic) | ||||
.Mnemonic("postpone", PostponeMnemonic) | |||||
.Mnemonic("reject", RejectMnemonic) | .Mnemonic("reject", RejectMnemonic) | ||||
.Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet) | .Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet) | ||||
.Mnemonic("Yes", SetTrueMnemonic) | .Mnemonic("Yes", SetTrueMnemonic) |
class ResultConfiguration { | class ResultConfiguration { | ||||
public: | public: | ||||
enum ActionType { | enum ActionType { | ||||
Bypass, | |||||
Allow, | Allow, | ||||
Reject, | |||||
Bypass, | |||||
Delete, | Delete, | ||||
Hold | |||||
Hold, | |||||
Postpone, | |||||
Reject, | |||||
}; | }; | ||||
int ResultCode; | int ResultCode; | ||||
case Bypass: return Bypass; break; | case Bypass: return Bypass; break; | ||||
case Delete: return Delete; break; | case Delete: return Delete; break; | ||||
case Hold: return Hold; break; | case Hold: return Hold; break; | ||||
case Postpone: return Postpone; break; | |||||
case Reject: return Reject; break; | case Reject: return Reject; break; | ||||
default: return Bypass; break; | default: return Bypass; break; | ||||
} | } |
void Job::setConfigurationFromScanResult(ScopeScanner& myScanner) { | void Job::setConfigurationFromScanResult(ScopeScanner& myScanner) { | ||||
FaultIfSettingScanResultConfigBeforeScan(NoScanYet == ScanResultCode); | FaultIfSettingScanResultConfigBeforeScan(NoScanYet == ScanResultCode); | ||||
ScanResultConfiguration = Scanners.ConfigurationForResultCode(ScanResultCode); | |||||
/*//// Testing -- forcing scan results | |||||
//// Testing -- force result code | |||||
// ScanResultCode = 20; // Truncate | |||||
// ScanResultCode = 40; // Caution | |||||
// ScanResultCode = 63; // Black | |||||
ScanResultConfiguration.Action = ResultConfiguration::Hold; | |||||
ScanResultConfiguration.HoldPath = "C:\\M\\Projects\\MessageSniffer\\SNF4CGP_Work\\TestEnvironment\\hold\\"; | |||||
ScanResultConfiguration.RejectionReason = "I don't like the look of it -- so there!"; | |||||
ScanResultConfiguration.LogComment = "This is my happy little log comment."; | |||||
ScanResultConfiguration.EmitXMLLog = true; | |||||
ScanResultConfiguration.EmitClassicLog = false; | |||||
ScanResultConfiguration.InjectHeaders = true; | |||||
ScanResultConfiguration = Scanners.ConfigurationForResultCode(ScanResultCode); | |||||
*/////////////////////////////////////////////////////////////////////// | |||||
//// Testing -- forcing scan results | |||||
// ScanResultConfiguration.Action = ResultConfiguration::Hold; | |||||
// ScanResultConfiguration.HoldPath = "C:\\M\\Projects\\MessageSniffer\\SNF4CGP_Work\\TestEnvironment\\hold\\"; | |||||
// ScanResultConfiguration.RejectionReason = "I don't like the look of it -- so there!"; | |||||
// ScanResultConfiguration.LogComment = "This is my happy little log comment."; | |||||
// ScanResultConfiguration.EmitXMLLog = true; | |||||
// ScanResultConfiguration.EmitClassicLog = false; | |||||
// ScanResultConfiguration.InjectHeaders = true; | |||||
if(ScanResultConfiguration.InjectHeaders) HeadersToInject = myScanner.Engine().getXHDRs(); | if(ScanResultConfiguration.InjectHeaders) HeadersToInject = myScanner.Engine().getXHDRs(); | ||||
if(ScanResultConfiguration.EmitXMLLog) XMLLogData = myScanner.Engine().getXMLLog(); | if(ScanResultConfiguration.EmitXMLLog) XMLLogData = myScanner.Engine().getXMLLog(); | ||||
case ResultConfiguration::Bypass : { doBypass(); break; } | case ResultConfiguration::Bypass : { doBypass(); break; } | ||||
case ResultConfiguration::Delete : { doDelete(); break; } | case ResultConfiguration::Delete : { doDelete(); break; } | ||||
case ResultConfiguration::Hold : { doHold(); break; } | case ResultConfiguration::Hold : { doHold(); break; } | ||||
case ResultConfiguration::Postpone : { doPostpone(); break; } | |||||
case ResultConfiguration::Reject : { doReject(); break; } | case ResultConfiguration::Reject : { doReject(); break; } | ||||
default: { throw FaultUhandledScanResultAction; } | default: { throw FaultUhandledScanResultAction; } | ||||
} | } | ||||
else emitOK(); | else emitOK(); | ||||
} | } | ||||
//// Note that CGPs API indicates that ERROR is used to reject a message. | |||||
//// REJECT is used to postpone the scan. That is why our doReject() method | |||||
//// uses emitERROR(). | |||||
void Job::doReject() { | void Job::doReject() { | ||||
emitERROR(ScanResultConfiguration.RejectionReason); | |||||
} | |||||
//// Just like doReject() must use emitERROR to make the CGP API happy, the | |||||
//// doPostpone() method must use emitREJECT. We pull the "Reason" from the | |||||
//// same field in the configuration since this is temporary rejection. | |||||
void Job::doPostpone() { | |||||
emitREJECTED(ScanResultConfiguration.RejectionReason); | emitREJECTED(ScanResultConfiguration.RejectionReason); | ||||
} | } | ||||
void doAction(); | void doAction(); | ||||
void doBypass(); | void doBypass(); | ||||
void doAllow(); | void doAllow(); | ||||
void doPostpone(); | |||||
void doReject(); | void doReject(); | ||||
void doDelete(); | void doDelete(); | ||||
void doHold(); | void doHold(); |
using namespace std; // Introduce standard namespace. | using namespace std; // Introduce standard namespace. | ||||
const string SNF4CGP_VERSION_INFO = "CGPSNF Version 0.1.2 Build: " __DATE__ " " __TIME__; | |||||
const string SNF4CGP_VERSION_INFO = "CGPSNF Version 1.1.0 Build: " __DATE__ " " __TIME__; | |||||
const int ConfigPathArgNumber = 1; | const int ConfigPathArgNumber = 1; | ||||
const int MaxArgcNumber = 2; | const int MaxArgcNumber = 2; |