OWASP AppSensor:发送事件不触发响应

OWASP AppSensor: Sending events is not triggering responses

我正在 运行按照 https://github.com/jtmelton/appsensor/blob/master/sample-apps/DemoSetup.md 上的说明使用 AppSensor。

当我 运行 客户端数据生成器时,一切看起来都很漂亮。

我正在从我的桌面应用程序在 http://localhost:8085/api/v1.0/events 添加事件,它们显示在仪表盘和地图上都很好。但它们不会触发响应。

我从我的应用程序发送的请求与客户端数据生成器生成的请求相同。下面是几个例子:

{"user":{"username":"bob","ipAddress":{"address":"10.10.10.1","geoLocation":{"latitude":37.596758,"longitude":-121.647992}}},"detectionPoint":{"category":"Input Validation","label":"IE1","responses":[]},"timestamp":"2017-05-08T17:07:06.076Z","detectionSystem":{"detectionSystemId":"myclientapp"},"metadata":[]}

{"user":{"username":"bob","ipAddress":{"address":"10.10.10.1","geoLocation":{"latitude":37.596758,"longitude":-121.647992}}},"detectionPoint":{"category":"Input Validation","label":"IE2","responses":[]},"timestamp":"2017-05-08T17:07:06.076Z","detectionSystem":{"detectionSystemId":"myclientapp"},"metadata":[]}

{"user":{"username":"bob","ipAddress":{"address":"10.10.10.1","geoLocation":{"latitude":37.596758,"longitude":-121.647992}}},"detectionPoint":{"category":"Request","label":"RE3","responses":[]},"timestamp":"2017-05-08T15:56:47.473Z","detectionSystem":{"detectionSystemId":"myclientapp"},"metadata":[]}}

{"user":{"username":"bob","ipAddress":{"address":"10.10.10.1","geoLocation":{"latitude":37.596758,"longitude":-121.647992}}},"detectionPoint":{"category":"Authentication","label":"AE4","responses":[]},"timestamp":"2017-05-08T17:07:06.076Z","detectionSystem":{"detectionSystemId":"myclientapp"},"metadata":[]}

我不明白为什么我的请求不会触发来自服务器的响应,而来自数据生成器工具的相同请求会触发响应。

更新 1: 有人问我是否发送了足够的事件来触发响应,答案是肯定的。

更新 2: 我被要求共享服务器日志,here 是。

更新 3: 我被要求尝试使用 cURL,我做到了。相同的结果。即事件被记录但没有响应被触发。我发送了大约 50 次以下的 curl 请求(相同的时间戳)。

curl -v --header "Content-Type: application/json" --header "X-Appsensor-Client-Application-Name2: myclientapp" -X POST -d '{"user":{"username":"bob","ipAddress":{"address":"10.10.10.1","geoLocation":{"latitude":37.596758,"longitude":-121.647992}}},"detectionPoint":{"category":"Input Validation","label":"IE1","responses":[]},"timestamp":"2017-05-08T15:56:47.473Z","detectionSystem":{"detectionSystemId":"myclientapp"},"metadata":[]}' http://localhost:8085/api/v1.0/events

windows

格式相同的请求
curl -v --header "Content-Type: application/json" --header "X-Appsensor-Client-Application-Name2: myclientapp" -X POST -d "{\"user\":{\"username\":\"bob\",\"ipAddress\":{\"address\":\"10.10.10.1\",\"geoLocation\":{\"latitude\":37.596758,\"longitude\":-121.647992}}},\"detectionPoint\":{\"category\":\"Input Validation\",\"label\":\"IE1\",\"responses\":[]},\"timestamp\":\"2017-05-08T15:56:47.473Z\",\"detectionSystem\":{\"detectionSystemId\":\"myclientapp\"},\"metadata\":[]}" http://localhost:8085/api/v1.0/events

更新 4:感谢@jtmelton 的帮助。通过查看代码,我意识到我的 appsensor 服务器和我的客户端应用程序使用的是不同的时区。一旦我将时区添加到我的时间戳中,它就起作用了!!!

据我了解,appsensor 演示不会对您的请求提供任何有意义的 REST 响应。

演示中的 REST / WebSocket 服务器 依赖于 appsensor-ws-rest-server-2.2.0.jar,后者在 class RestRequestHandler 中提供端点。任何 POST 到 /api/v1.0/events/api/v1.0/attacks 都会通过方法 public void addEvent(Event event)HTTP 201 - created 回答。出于某种原因,在我的 CURL 测试中,我观察到 HTTP 204 - no content,但没关系。

可以从 /api/v1.0/responses 端点读取响应,例如使用 EventManager 的方法 public Collection<Response> getResponses(String earliest),其中 earliest 是日期时间值。由于 earliest 是唯一的查询参数,您将收到自给定日期时间以来服务器存储的所有用户的响应。使用演示中的 REST / WebSocket 服务器,我看不到任何可能收到 appsensor 通知的可能性,您必须明确查询应用程序的响应。

问题请参考更新4。始终在您的时间戳中包含时区。在我的例子中,请求时间戳早于服务器时间,所以它们被忽略了。

C#

DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffzzz")