|
10 | 10 | import re |
11 | 11 | import secrets |
12 | 12 | from base64 import b64encode, b64decode |
| 13 | +import datetime |
13 | 14 |
|
14 | 15 | DISARM_MATRIX_PATH = path.join(path.dirname(__file__), 'data', 'DISARM.json') |
15 | 16 | DEFAULT_PAGE = 1 |
@@ -204,14 +205,22 @@ def threat_actor(threat_actor_id): |
204 | 205 | def stix2_objects_endpoint(): |
205 | 206 | # Fetch all the STIX2 objects stored in the database |
206 | 207 | newer_than = request.args.get('newer_than', default=None, type=str) |
| 208 | + newer_than = datetime.datetime.fromisoformat(newer_than.rstrip("Z") + "+00:00") if newer_than else None |
| 209 | + app.logger.info(f"Fetching STIX2 objects newer than {newer_than}") |
207 | 210 | # Fetch the incidents from the database |
208 | 211 | if newer_than: |
209 | 212 | total_objects = stix2_objects.count_documents({"modified": {"$gt": newer_than}}) |
210 | 213 | objects_cursor = stix2_objects.find({"modified": {"$gt": newer_than}}) |
211 | 214 | else: |
212 | 215 | total_objects = stix2_objects.count_documents({}) |
213 | 216 | objects_cursor = stix2_objects.find({}) |
214 | | - return build_paginated_json(request, objects_cursor, total_objects), 200 |
| 217 | + |
| 218 | + objects = list(objects_cursor) |
| 219 | + # Remove the _id field from the documents |
| 220 | + for object in objects: |
| 221 | + object.pop('_id', None) |
| 222 | + bundle = Bundle(objects=objects, allow_custom=True) |
| 223 | + return bundle.serialize(), 200, {'Content-Type': 'application/json'} |
215 | 224 |
|
216 | 225 | @app.route('/threat-actors/top', methods=['GET']) |
217 | 226 | def top_threat_actors(): |
|
0 commit comments