|
10 | 10 | from zentral.conf import settings |
11 | 11 | from zentral.contrib.inventory.events import MachineTagEvent |
12 | 12 | from zentral.contrib.inventory.models import EnrollmentSecret, MachineSnapshot, MachineTag, MetaBusinessUnit, Tag |
| 13 | +from zentral.contrib.inventory.utils import commit_machine_snapshot_and_trigger_events |
13 | 14 | from zentral.contrib.osquery.compliance_checks import sync_query_compliance_check |
14 | 15 | from zentral.contrib.osquery.conf import INVENTORY_QUERY_NAME |
15 | 16 | from zentral.contrib.osquery.events import (OsqueryEnrollmentEvent, OsqueryRequestEvent, OsqueryResultEvent, |
@@ -273,24 +274,29 @@ def post_default_inventory_query_snapshot( |
273 | 274 | missing_windows_build_data=False, |
274 | 275 | unknown_windows_build=False, |
275 | 276 | ): |
276 | | - return self.post_as_json( |
277 | | - "log", |
278 | | - {"node_key": node_key, |
279 | | - "log_type": "result", |
280 | | - "data": [{ |
281 | | - 'action': 'snapshot', |
282 | | - "name": INVENTORY_QUERY_NAME, |
283 | | - "snapshot": self.get_default_inventory_query_snapshot( |
284 | | - platform, |
285 | | - with_app, |
286 | | - with_ec2, |
287 | | - no_windows_build_data, |
288 | | - missing_windows_build_data, |
289 | | - unknown_windows_build, |
290 | | - ), |
291 | | - 'unixTime': '1480605737', |
292 | | - }]} |
293 | | - ) |
| 277 | + with patch("zentral.contrib.osquery.public_views.post_machine_snapshot_raw_event") as pmsre: |
| 278 | + def store_mstree(ms_tree): |
| 279 | + # simulate what is done by the preprocessor |
| 280 | + commit_machine_snapshot_and_trigger_events(ms_tree) |
| 281 | + pmsre.side_effect = store_mstree |
| 282 | + return self.post_as_json( |
| 283 | + "log", |
| 284 | + {"node_key": node_key, |
| 285 | + "log_type": "result", |
| 286 | + "data": [{ |
| 287 | + 'action': 'snapshot', |
| 288 | + "name": INVENTORY_QUERY_NAME, |
| 289 | + "snapshot": self.get_default_inventory_query_snapshot( |
| 290 | + platform, |
| 291 | + with_app, |
| 292 | + with_ec2, |
| 293 | + no_windows_build_data, |
| 294 | + missing_windows_build_data, |
| 295 | + unknown_windows_build, |
| 296 | + ), |
| 297 | + 'unixTime': '1480605737', |
| 298 | + }]} |
| 299 | + ) |
294 | 300 |
|
295 | 301 | # enrollment |
296 | 302 |
|
|
0 commit comments