def ClientInfo(self, responses): """Obtain some information about the GRR client running.""" if not responses.success: self.Log("Could not get ClientInfo.") return response = responses.First() if fleetspeak_utils.IsFleetspeakEnabledClient(self.client_id): label = fleetspeak_utils.GetLabelFromFleetspeak(self.client_id) # A FS enabled GRR shouldn't provide a label, but if it does prefer # it to an unrecognized FS label. # # TODO(user): Remove condition once we are confident in FS labeling. if label != fleetspeak_connector.unknown_label or not response.labels: response.labels = [label] sanitized_labels = [] for label in response.labels: try: rdf_aff4.AFF4ObjectLabel(name=label) sanitized_labels.append(label) except type_info.TypeValueError: self.Log("Got invalid label: %s", label) response.labels = sanitized_labels self.state.client.startup_info.client_info = response
def ClientInfo(self, responses): """Obtain some information about the GRR client running.""" if not responses.success: self.Log("Could not get ClientInfo.") return response = responses.First() if fleetspeak_utils.IsFleetspeakEnabledClient( self.client_id, token=self.token): label = fleetspeak_utils.GetLabelFromFleetspeak(self.client_id) # A FS enabled GRR shouldn't provide a label, but if it does prefer # it to an unrecognized FS label. # # TODO(user): Remove condition once we are confident in FS labeling. if label != fleetspeak_connector.unknown_label or not response.labels: response.labels = [label] if data_store.AFF4Enabled(): # AFF4 client. with self._OpenClient(mode="rw") as client: client.Set(client.Schema.CLIENT_INFO(response)) client.AddLabels(response.labels, owner="GRR") # rdf_objects.ClientSnapshot. self.state.client.startup_info.client_info = response
def testGetLabelFromFleetspeakKnown(self): client_id = "C.0000000000000001" conn = MockConnReturningClient( admin_pb2.Client( client_id=fleetspeak_utils.GRRIDToFleetspeakID(client_id), labels=[common_pb2.Label(service_name="client", label="division1")])) with test_lib.ConfigOverrider({ "Server.fleetspeak_label_map": ["division1:fleetspeak-division1"], }): with fleetspeak_test_lib.ConnectionOverrider(conn): self.assertEqual("fleetspeak-division1", fleetspeak_utils.GetLabelFromFleetspeak(client_id))