Browse Source

Fixed bug where Reject action told CGP REJECTED. Quixotically CGPs API indicates that to Reject a message it needs to see ERROR, and that when it sees REJECTED message processing is actually postponed. A look at CGP logs indicates that REJECTED messages are scanned again later.

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-fa6ab0af3dfc
master
madscientist 14 years ago
parent
commit
f0fb9225aa
5 changed files with 42 additions and 14 deletions
  1. 9
    0
      SNF4CGP/ConfigurationEngine.cpp
  2. 5
    3
      SNF4CGP/ConfigurationEngine.hpp
  3. 26
    10
      SNF4CGP/JobPool.cpp
  4. 1
    0
      SNF4CGP/JobPool.hpp
  5. 1
    1
      SNF4CGP/main.cpp

+ 9
- 0
SNF4CGP/ConfigurationEngine.cpp View File

@@ -97,6 +97,7 @@ void ConfigurationManager::update() {
const string BypassMnemonic = IntAsString(ResultConfiguration::Bypass);
const string DeleteMnemonic = IntAsString(ResultConfiguration::Delete);
const string HoldMnemonic = IntAsString(ResultConfiguration::Hold);
const string PostponeMnemonic = IntAsString(ResultConfiguration::Postpone);
const string RejectMnemonic = IntAsString(ResultConfiguration::Reject);
const string SetTrueMnemonic = IntAsString(InputGroup::SetTrue);
const string SetFalseMnemonic = IntAsString(InputGroup::SetFalse);
@@ -111,11 +112,13 @@ void ConfigurationManager::update() {
.Mnemonic("Bypass", BypassMnemonic)
.Mnemonic("Delete", DeleteMnemonic)
.Mnemonic("Hold", HoldMnemonic)
.Mnemonic("Postpone", PostponeMnemonic)
.Mnemonic("Reject", RejectMnemonic)
.Mnemonic("allow", AllowMnemonic)
.Mnemonic("bypass", BypassMnemonic)
.Mnemonic("delete", DeleteMnemonic)
.Mnemonic("hold", HoldMnemonic)
.Mnemonic("postpone", PostponeMnemonic)
.Mnemonic("reject", RejectMnemonic)
.Attribute("headers", HamInputDefaults.InjectHeaders, InputGroup::NotSet)
.Mnemonic("Yes", SetTrueMnemonic)
@@ -143,11 +146,13 @@ void ConfigurationManager::update() {
.Mnemonic("Bypass", BypassMnemonic)
.Mnemonic("Delete", DeleteMnemonic)
.Mnemonic("Hold", HoldMnemonic)
.Mnemonic("Postpone", PostponeMnemonic)
.Mnemonic("Reject", RejectMnemonic)
.Mnemonic("allow", AllowMnemonic)
.Mnemonic("bypass", BypassMnemonic)
.Mnemonic("delete", DeleteMnemonic)
.Mnemonic("hold", HoldMnemonic)
.Mnemonic("postpone", PostponeMnemonic)
.Mnemonic("reject", RejectMnemonic)
.Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet)
.Mnemonic("Yes", SetTrueMnemonic)
@@ -176,11 +181,13 @@ void ConfigurationManager::update() {
.Mnemonic("Bypass", BypassMnemonic)
.Mnemonic("Delete", DeleteMnemonic)
.Mnemonic("Hold", HoldMnemonic)
.Mnemonic("Postpone", PostponeMnemonic)
.Mnemonic("Reject", RejectMnemonic)
.Mnemonic("allow", AllowMnemonic)
.Mnemonic("bypass", BypassMnemonic)
.Mnemonic("delete", DeleteMnemonic)
.Mnemonic("hold", HoldMnemonic)
.Mnemonic("postpone", PostponeMnemonic)
.Mnemonic("reject", RejectMnemonic)
.Attribute("headers", SpamInputDefaults.InjectHeaders, InputGroup::NotSet)
.Mnemonic("Yes", SetTrueMnemonic)
@@ -208,11 +215,13 @@ void ConfigurationManager::update() {
.Mnemonic("Bypass", BypassMnemonic)
.Mnemonic("Delete", DeleteMnemonic)
.Mnemonic("Hold", HoldMnemonic)
.Mnemonic("Postpone", PostponeMnemonic)
.Mnemonic("Reject", RejectMnemonic)
.Mnemonic("allow", AllowMnemonic)
.Mnemonic("bypass", BypassMnemonic)
.Mnemonic("delete", DeleteMnemonic)
.Mnemonic("hold", HoldMnemonic)
.Mnemonic("postpone", PostponeMnemonic)
.Mnemonic("reject", RejectMnemonic)
.Attribute("headers", CurrentInputs.InjectHeaders, InputGroup::NotSet)
.Mnemonic("Yes", SetTrueMnemonic)

+ 5
- 3
SNF4CGP/ConfigurationEngine.hpp View File

@@ -72,11 +72,12 @@ class InputGroup {
class ResultConfiguration {
public:
enum ActionType {
Bypass,
Allow,
Reject,
Bypass,
Delete,
Hold
Hold,
Postpone,
Reject,
};
int ResultCode;
@@ -138,6 +139,7 @@ class ResultConfiguration {
case Bypass: return Bypass; break;
case Delete: return Delete; break;
case Hold: return Hold; break;
case Postpone: return Postpone; break;
case Reject: return Reject; break;
default: return Bypass; break;
}

+ 26
- 10
SNF4CGP/JobPool.cpp View File

@@ -193,19 +193,22 @@ LogicFault FaultIfSettingScanResultConfigBeforeScan("Job::setConfigurationFromSc
void Job::setConfigurationFromScanResult(ScopeScanner& myScanner) {
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.EmitXMLLog) XMLLogData = myScanner.Engine().getXMLLog();
@@ -266,6 +269,7 @@ void Job::doAction() {
case ResultConfiguration::Bypass : { doBypass(); break; }
case ResultConfiguration::Delete : { doDelete(); break; }
case ResultConfiguration::Hold : { doHold(); break; }
case ResultConfiguration::Postpone : { doPostpone(); break; }
case ResultConfiguration::Reject : { doReject(); break; }
default: { throw FaultUhandledScanResultAction; }
}
@@ -280,7 +284,19 @@ void Job::doAllow() {
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() {
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);
}

+ 1
- 0
SNF4CGP/JobPool.hpp View File

@@ -122,6 +122,7 @@ class Job {
void doAction();
void doBypass();
void doAllow();
void doPostpone();
void doReject();
void doDelete();
void doHold();

+ 1
- 1
SNF4CGP/main.cpp View File

@@ -13,7 +13,7 @@
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 MaxArgcNumber = 2;

Loading…
Cancel
Save