当前位置: 首页>>代码示例>>C#>>正文


C# Attack.GetDetectionSystemId方法代码示例

本文整理汇总了C#中Attack.GetDetectionSystemId方法的典型用法代码示例。如果您正苦于以下问题:C# Attack.GetDetectionSystemId方法的具体用法?C# Attack.GetDetectionSystemId怎么用?C# Attack.GetDetectionSystemId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attack的用法示例。


在下文中一共展示了Attack.GetDetectionSystemId方法的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.GetDetectionSystemId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。