MCPcopy Index your code
hub / github.com/OWASP/Python-Honeypot / count_events

Function count_events

api/server.py:260–327  ·  view source on GitHub ↗

Get total number of events based on event type --- parameters: - in: path name: event_type schema: type: string required: true enum: - all - honeypot - network - credential

(event_type)

Source from the content-addressed store, hash-verified

258
259@app.route("/api/events/count/<event_type>", methods=["GET"])
260def count_events(event_type):
261 """
262 Get total number of events based on event type
263 ---
264 parameters:
265 - in: path
266 name: event_type
267 schema:
268 type: string
269 required: true
270 enum:
271 - all
272 - honeypot
273 - network
274 - credential
275 - file
276 - data
277 - pcap
278 - in: query
279 name: date
280 schema:
281 type: date
282 required: false
283 description: Date to filter records for particular day
284 responses:
285 '200':
286 description: Ok
287 examples:
288 application/json: { "count": 293879, "date": null}
289 '404':
290 description: Not Found
291 examples:
292 application/json: { "msg": "file/path not found!","status": "error"}
293 """
294 abort(404) if event_type not in event_types else None
295
296 date = get_value_from_request("date")
297 try:
298 return jsonify(
299 {
300 "count": int(
301 elasticsearch_events.count(
302 index=event_types[event_type],
303 body=filter_by_date(date)
304 )['count']
305 if date else
306 elasticsearch_events.count(index=event_types[event_type])['count']
307 ),
308 "date": date
309 } if event_type != "all" else {
310 "count": sum(
311 [
312 int(
313 elasticsearch_events.count(
314 index=event_types[event],
315 body=filter_by_date(date)
316 )['count']
317 if date else

Callers

nothing calls this directly

Calls 2

filter_by_dateFunction · 0.90
get_value_from_requestFunction · 0.85

Tested by

no test coverage detected