Beispiel #1
0
int NovaNode::HandleSuspectClearedOnV8Thread(eio_req* req)
{
	HandleScope scope;
	Suspect* suspect = static_cast<Suspect*>(req->data);
	if (m_suspects.keyExists(suspect->GetIdentifier())) {
		delete m_suspects[suspect->GetIdentifier()];
	}
	m_suspects.erase(suspect->GetIdentifier());

	v8::Persistent<Value> weak_handle = Persistent<Value>::New(SuspectJs::WrapSuspect(suspect));
	weak_handle.MakeWeak(suspect, &DoneWithSuspectCallback);
	Persistent<Value> argv[1] = { weak_handle };	
	m_SuspectClearedCallback->Call(m_SuspectClearedCallback, 1, argv);
	
	return 0;
}
Beispiel #2
0
int NovaNode::HandleNewSuspectOnV8Thread(eio_req* req)
{
	HandleScope scope;
	
	Suspect* suspect = static_cast<Suspect*>(req->data);
		
	if (suspect != NULL) {	
		if (m_suspects.keyExists(suspect->GetIdentifier())) {
			delete m_suspects[suspect->GetIdentifier()];
		}
		
		m_suspects[suspect->GetIdentifier()] = suspect;
		SendSuspect(suspect);
	} else {
		LOG(DEBUG, "HandleNewSuspectOnV8Thread got a NULL suspect pointer. Ignoring.", "");
	}
	return 0;

}
Beispiel #3
0
void PrintAllSuspects(enum SuspectListType listType, bool csv)
{
	Connect();

	vector<SuspectIdentifier> suspects = GetSuspectList(listType);

	// Print the CSV header
	if (csv)
	{
		cout << "IP,";
		cout << "INTERFACE,";
		for(int i = 0; i < DIM; i++)
		{
			cout << FeatureSet::m_featureNames[i] << ",";
		}
		cout << "CLASSIFICATION" << endl;
	}

	for(uint i = 0; i < suspects.size(); i++)
	{
		Suspect *suspect = GetSuspect(suspects.at(i));

		if(suspect != NULL)
		{
			if(!csv)
			{
				cout << suspect->ToString() << endl;
			}
			else
			{
				cout << suspect->GetIpString() << ",";
				cout << suspect->GetIdentifier().m_interface << ",";
				for(int i = 0; i < DIM; i++)
				{
					cout << suspect->GetFeatureSet().m_features[i] << ",";
				}
				cout << suspect->GetClassification() << endl;
			}

			delete suspect;
		}
		else
		{
			cout << "Error: No suspect received" << endl;
		}
	}

	CloseNovadConnection();

}