def send(api: PyMISP, request_type: str, url: str, data=None, check_errors: bool = True) -> dict: if data is None: data = {} response = api._prepare_request(request_type, url, data=data) response = api._check_json_response(response) if check_errors: check_response(response) return response
def request(pymisp: PyMISP, request_type: str, url: str, data: dict = {}) -> dict: response = pymisp._prepare_request(request_type, url, data) return pymisp._check_json_response(response)
"remote_org_id": 1, "name": "Localhost", "url": url, "authkey": key, }) check_response(remote_server) # Check connection server_test = pymisp.test_server(remote_server) check_response(server_test) assert server_test["status"] == 1 assert server_test["post"] == 1 # Get remote user url = f'servers/getRemoteUser/{remote_server["id"]}' remote_user = pymisp._check_json_response(pymisp._prepare_request('GET', url)) check_response(remote_user) assert remote_user["Sync flag"] == "Yes" assert remote_user["Role name"] == "admin" assert remote_user["User"] == "*****@*****.**" # Create testing event event = MISPEvent() event.load_file(os.path.dirname(os.path.realpath(__file__)) + "/event.json") pymisp.delete_event_blocklist(event) event = pymisp.add_event(event, metadata=True) check_response(event) # Publish that event check_response(pymisp.publish(event))