當前位置: 首頁>>代碼示例>>C#>>正文


C# Attack.GetDetectionPoint方法代碼示例

本文整理匯總了C#中Attack.GetDetectionPoint方法的典型用法代碼示例。如果您正苦於以下問題:C# Attack.GetDetectionPoint方法的具體用法?C# Attack.GetDetectionPoint怎麽用?C# Attack.GetDetectionPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Attack的用法示例。


在下文中一共展示了Attack.GetDetectionPoint方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: findAppropriateResponse

	/**
	 * Find/generate {@link Response} appropriate for specified {@link Attack}.
	 * 
	 * @param attack {@link Attack} that is being analyzed
	 * @return {@link Response} to be executed for given {@link Attack}
	 */
	protected Response findAppropriateResponse(Attack attack) {
		DetectionPoint triggeringDetectionPoint = attack.GetDetectionPoint();
		
		SearchCriteria criteria = new SearchCriteria().
				setUser(attack.GetUser()).
				setDetectionPoint(triggeringDetectionPoint).
                setDetectionSystemIds(appSensorServer.getConfiguration().getRelatedDetectionSystems(attack.GetDetectionSystemId()));
		
		//grab any existing responses
		Collection<Response> existingResponses = appSensorServer.getResponseStore().findResponses(criteria);
		
		string responseAction = null;
		Interval interval = null;

        Collection<Response> possibleResponses = findPossibleResponses(triggeringDetectionPoint);

		//if (existingResponses == null || existingResponses.Size() == 0) {
        if(existingResponses == null || existingResponses.Count == 0) {
			//no responses yet, just grab first configured response from detection point
            // Response response = possibleResponses.iterator().next();
            IEnumerator <Response> enumerator = possibleResponses.GetEnumerator();
            enumerator.MoveNext();
            Response response = enumerator.Current;
			
			responseAction = response.getAction();
			interval = response.getInterval();
		} else {
			foreach (Response configuredResponse in possibleResponses) {
				responseAction = configuredResponse.getAction();
				interval = configuredResponse.getInterval();

				if (! isPreviousResponse(configuredResponse, existingResponses)) {
					//if we find that this response doesn't already exist, use it
					break;
				}
				
				//if we reach here, we will just use the last configured response (repeat last response)
			}
		}
		
		if(responseAction == null) {
            //throw new IllegalArgumentException("No appropriate response was configured for this detection point: " + triggeringDetectionPoint.getId());
            throw new ArgumentException("No appropriate response was configured for this detection point: " + triggeringDetectionPoint.getId());
		}
		
		Response responses = new Response();
		responses.setUser(attack.GetUser());
		responses.setTimestamp(attack.GetTimestamp());
		responses.setAction(responseAction);
		responses.setInterval(interval);
		responses.setDetectionSystemId(attack.GetDetectionSystemId());
		
		return responses;
	}
開發者ID:Borealix,項目名稱:AppSensor2.NET,代碼行數:60,代碼來源:ReferenceAttackAnalysisEngine.cs


注:本文中的Attack.GetDetectionPoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。