partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | HTTPManager.OpenURL | Get the requested URL.
Note that we do not have any concept of timing here - we try to connect
through all proxies as fast as possible until one works. Timing and poll
frequency is left to the calling code.
Args:
url: The URL to fetch
verify_cb: An optional callback which can be used to va... | grr/client/grr_response_client/comms.py | def OpenURL(self,
url,
verify_cb=lambda x: True,
data=None,
params=None,
headers=None,
method="GET",
timeout=None):
"""Get the requested URL.
Note that we do not have any concept of timing here - we try to connect... | def OpenURL(self,
url,
verify_cb=lambda x: True,
data=None,
params=None,
headers=None,
method="GET",
timeout=None):
"""Get the requested URL.
Note that we do not have any concept of timing here - we try to connect... | [
"Get",
"the",
"requested",
"URL",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L257-L364 | [
"def",
"OpenURL",
"(",
"self",
",",
"url",
",",
"verify_cb",
"=",
"lambda",
"x",
":",
"True",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"method",
"=",
"\"GET\"",
",",
"timeout",
"=",
"None",
")",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HTTPManager._RetryRequest | Retry the request a few times before we determine it failed.
Sometimes the frontend becomes loaded and issues a 500 error to throttle the
clients. We wait Client.error_poll_min seconds between each attempt to back
off the frontend. Note that this does not affect any timing algorithm in the
client itsel... | grr/client/grr_response_client/comms.py | def _RetryRequest(self, timeout=None, **request_args):
"""Retry the request a few times before we determine it failed.
Sometimes the frontend becomes loaded and issues a 500 error to throttle the
clients. We wait Client.error_poll_min seconds between each attempt to back
off the frontend. Note that thi... | def _RetryRequest(self, timeout=None, **request_args):
"""Retry the request a few times before we determine it failed.
Sometimes the frontend becomes loaded and issues a 500 error to throttle the
clients. We wait Client.error_poll_min seconds between each attempt to back
off the frontend. Note that thi... | [
"Retry",
"the",
"request",
"a",
"few",
"times",
"before",
"we",
"determine",
"it",
"failed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L366-L429 | [
"def",
"_RetryRequest",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"while",
"True",
":",
"try",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"timeout",
":",
"timeout",
"=",
"config",
".",
"CON... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HTTPManager.Wait | Wait for the specified timeout. | grr/client/grr_response_client/comms.py | def Wait(self, timeout):
"""Wait for the specified timeout."""
time.sleep(timeout - int(timeout))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(timeout)):
time.sleep(1)
if self.heart_beat_cb:
self.heart_beat_cb() | def Wait(self, timeout):
"""Wait for the specified timeout."""
time.sleep(timeout - int(timeout))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(timeout)):
time.sleep(1)
if self.heart_beat_cb:
self.heart_beat_cb() | [
"Wait",
"for",
"the",
"specified",
"timeout",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L431-L440 | [
"def",
"Wait",
"(",
"self",
",",
"timeout",
")",
":",
"time",
".",
"sleep",
"(",
"timeout",
"-",
"int",
"(",
"timeout",
")",
")",
"# Split a long sleep interval into 1 second intervals so we can heartbeat.",
"for",
"_",
"in",
"range",
"(",
"int",
"(",
"timeout",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Timer.Wait | Wait until the next action is needed. | grr/client/grr_response_client/comms.py | def Wait(self):
"""Wait until the next action is needed."""
time.sleep(self.sleep_time - int(self.sleep_time))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(self.sleep_time)):
time.sleep(1)
# Back off slowly at first and fast if no answer.
... | def Wait(self):
"""Wait until the next action is needed."""
time.sleep(self.sleep_time - int(self.sleep_time))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(self.sleep_time)):
time.sleep(1)
# Back off slowly at first and fast if no answer.
... | [
"Wait",
"until",
"the",
"next",
"action",
"is",
"needed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L468-L478 | [
"def",
"Wait",
"(",
"self",
")",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"sleep_time",
"-",
"int",
"(",
"self",
".",
"sleep_time",
")",
")",
"# Split a long sleep interval into 1 second intervals so we can heartbeat.",
"for",
"_",
"in",
"range",
"(",
"int",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.QueueResponse | Pushes the Serialized Message on the output queue. | grr/client/grr_response_client/comms.py | def QueueResponse(self, message, blocking=True):
"""Pushes the Serialized Message on the output queue."""
self._out_queue.Put(message, block=blocking) | def QueueResponse(self, message, blocking=True):
"""Pushes the Serialized Message on the output queue."""
self._out_queue.Put(message, block=blocking) | [
"Pushes",
"the",
"Serialized",
"Message",
"on",
"the",
"output",
"queue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L554-L556 | [
"def",
"QueueResponse",
"(",
"self",
",",
"message",
",",
"blocking",
"=",
"True",
")",
":",
"self",
".",
"_out_queue",
".",
"Put",
"(",
"message",
",",
"block",
"=",
"blocking",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.QueueMessages | Push messages to the input queue. | grr/client/grr_response_client/comms.py | def QueueMessages(self, messages):
"""Push messages to the input queue."""
# Push all the messages to our input queue
for message in messages:
self._in_queue.put(message, block=True) | def QueueMessages(self, messages):
"""Push messages to the input queue."""
# Push all the messages to our input queue
for message in messages:
self._in_queue.put(message, block=True) | [
"Push",
"messages",
"to",
"the",
"input",
"queue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L573-L577 | [
"def",
"QueueMessages",
"(",
"self",
",",
"messages",
")",
":",
"# Push all the messages to our input queue",
"for",
"message",
"in",
"messages",
":",
"self",
".",
"_in_queue",
".",
"put",
"(",
"message",
",",
"block",
"=",
"True",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.SendReply | Send the protobuf to the server.
Args:
rdf_value: The RDFvalue to return.
request_id: The id of the request this is a response to.
response_id: The id of this response.
session_id: The session id of the flow.
message_type: The contents of this message, MESSAGE, STATUS or
RDF_V... | grr/client/grr_response_client/comms.py | def SendReply(self,
rdf_value=None,
request_id=None,
response_id=None,
session_id="W:0",
message_type=None,
name=None,
require_fastpoll=None,
ttl=None,
blocking=True,
... | def SendReply(self,
rdf_value=None,
request_id=None,
response_id=None,
session_id="W:0",
message_type=None,
name=None,
require_fastpoll=None,
ttl=None,
blocking=True,
... | [
"Send",
"the",
"protobuf",
"to",
"the",
"server",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L604-L670 | [
"def",
"SendReply",
"(",
"self",
",",
"rdf_value",
"=",
"None",
",",
"request_id",
"=",
"None",
",",
"response_id",
"=",
"None",
",",
"session_id",
"=",
"\"W:0\"",
",",
"message_type",
"=",
"None",
",",
"name",
"=",
"None",
",",
"require_fastpoll",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.HandleMessage | Entry point for processing jobs.
Args:
message: The GrrMessage that was delivered from the server.
Raises:
RuntimeError: The client action requested was not found. | grr/client/grr_response_client/comms.py | def HandleMessage(self, message):
"""Entry point for processing jobs.
Args:
message: The GrrMessage that was delivered from the server.
Raises:
RuntimeError: The client action requested was not found.
"""
self._is_active = True
try:
action_cls = actions.ActionPlugin.class... | def HandleMessage(self, message):
"""Entry point for processing jobs.
Args:
message: The GrrMessage that was delivered from the server.
Raises:
RuntimeError: The client action requested was not found.
"""
self._is_active = True
try:
action_cls = actions.ActionPlugin.class... | [
"Entry",
"point",
"for",
"processing",
"jobs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L685-L714 | [
"def",
"HandleMessage",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_is_active",
"=",
"True",
"try",
":",
"action_cls",
"=",
"actions",
".",
"ActionPlugin",
".",
"classes",
".",
"get",
"(",
"message",
".",
"name",
")",
"if",
"action_cls",
"is",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.MemoryExceeded | Returns True if our memory footprint is too large. | grr/client/grr_response_client/comms.py | def MemoryExceeded(self):
"""Returns True if our memory footprint is too large."""
rss_size = self.proc.memory_info().rss
return rss_size // 1024 // 1024 > config.CONFIG["Client.rss_max"] | def MemoryExceeded(self):
"""Returns True if our memory footprint is too large."""
rss_size = self.proc.memory_info().rss
return rss_size // 1024 // 1024 > config.CONFIG["Client.rss_max"] | [
"Returns",
"True",
"if",
"our",
"memory",
"footprint",
"is",
"too",
"large",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L716-L719 | [
"def",
"MemoryExceeded",
"(",
"self",
")",
":",
"rss_size",
"=",
"self",
".",
"proc",
".",
"memory_info",
"(",
")",
".",
"rss",
"return",
"rss_size",
"//",
"1024",
"//",
"1024",
">",
"config",
".",
"CONFIG",
"[",
"\"Client.rss_max\"",
"]"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.Sleep | Sleeps the calling thread with heartbeat. | grr/client/grr_response_client/comms.py | def Sleep(self, timeout):
"""Sleeps the calling thread with heartbeat."""
if self.nanny_controller:
self.nanny_controller.Heartbeat()
# Split a long sleep interval into 1 second intervals so we can heartbeat.
while timeout > 0:
time.sleep(min(1., timeout))
timeout -= 1
# If the ... | def Sleep(self, timeout):
"""Sleeps the calling thread with heartbeat."""
if self.nanny_controller:
self.nanny_controller.Heartbeat()
# Split a long sleep interval into 1 second intervals so we can heartbeat.
while timeout > 0:
time.sleep(min(1., timeout))
timeout -= 1
# If the ... | [
"Sleeps",
"the",
"calling",
"thread",
"with",
"heartbeat",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L744-L759 | [
"def",
"Sleep",
"(",
"self",
",",
"timeout",
")",
":",
"if",
"self",
".",
"nanny_controller",
":",
"self",
".",
"nanny_controller",
".",
"Heartbeat",
"(",
")",
"# Split a long sleep interval into 1 second intervals so we can heartbeat.",
"while",
"timeout",
">",
"0",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.OnStartup | A handler that is called on client startup. | grr/client/grr_response_client/comms.py | def OnStartup(self):
"""A handler that is called on client startup."""
# We read the transaction log and fail any requests that are in it. If there
# is anything in the transaction log we assume its there because we crashed
# last time and let the server know.
last_request = self.transaction_log.Ge... | def OnStartup(self):
"""A handler that is called on client startup."""
# We read the transaction log and fail any requests that are in it. If there
# is anything in the transaction log we assume its there because we crashed
# last time and let the server know.
last_request = self.transaction_log.Ge... | [
"A",
"handler",
"that",
"is",
"called",
"on",
"client",
"startup",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L761-L788 | [
"def",
"OnStartup",
"(",
"self",
")",
":",
"# We read the transaction log and fail any requests that are in it. If there",
"# is anything in the transaction log we assume its there because we crashed",
"# last time and let the server know.",
"last_request",
"=",
"self",
".",
"transaction_l... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRClientWorker.run | Main thread for processing messages. | grr/client/grr_response_client/comms.py | def run(self):
"""Main thread for processing messages."""
self.OnStartup()
try:
while True:
message = self._in_queue.get()
# A message of None is our terminal message.
if message is None:
break
try:
self.HandleMessage(message)
# Catch a... | def run(self):
"""Main thread for processing messages."""
self.OnStartup()
try:
while True:
message = self._in_queue.get()
# A message of None is our terminal message.
if message is None:
break
try:
self.HandleMessage(message)
# Catch a... | [
"Main",
"thread",
"for",
"processing",
"messages",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L790-L829 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"OnStartup",
"(",
")",
"try",
":",
"while",
"True",
":",
"message",
"=",
"self",
".",
"_in_queue",
".",
"get",
"(",
")",
"# A message of None is our terminal message.",
"if",
"message",
"is",
"None",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SizeLimitedQueue.Put | Put a message on the queue, blocking if it is too full.
Blocks when the queue contains more than the threshold.
Args:
message: rdf_flows.GrrMessage The message to put.
block: bool If True, we block and wait for the queue to have more space.
Otherwise, if the queue is full, we raise.
... | grr/client/grr_response_client/comms.py | def Put(self, message, block=True, timeout=1000):
"""Put a message on the queue, blocking if it is too full.
Blocks when the queue contains more than the threshold.
Args:
message: rdf_flows.GrrMessage The message to put.
block: bool If True, we block and wait for the queue to have more space.
... | def Put(self, message, block=True, timeout=1000):
"""Put a message on the queue, blocking if it is too full.
Blocks when the queue contains more than the threshold.
Args:
message: rdf_flows.GrrMessage The message to put.
block: bool If True, we block and wait for the queue to have more space.
... | [
"Put",
"a",
"message",
"on",
"the",
"queue",
"blocking",
"if",
"it",
"is",
"too",
"full",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L847-L881 | [
"def",
"Put",
"(",
"self",
",",
"message",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"1000",
")",
":",
"# We only queue already serialized objects so we know how large they are.",
"message",
"=",
"message",
".",
"SerializeToString",
"(",
")",
"if",
"not",
"b... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SizeLimitedQueue.GetMessages | Retrieves and removes the messages from the queue.
Args:
soft_size_limit: int If there is more data in the queue than
soft_size_limit bytes, the returned list of messages will be
approximately this large. If None (default), returns all messages
currently on the queue.
Returns:
... | grr/client/grr_response_client/comms.py | def GetMessages(self, soft_size_limit=None):
"""Retrieves and removes the messages from the queue.
Args:
soft_size_limit: int If there is more data in the queue than
soft_size_limit bytes, the returned list of messages will be
approximately this large. If None (default), returns all messa... | def GetMessages(self, soft_size_limit=None):
"""Retrieves and removes the messages from the queue.
Args:
soft_size_limit: int If there is more data in the queue than
soft_size_limit bytes, the returned list of messages will be
approximately this large. If None (default), returns all messa... | [
"Retrieves",
"and",
"removes",
"the",
"messages",
"from",
"the",
"queue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L888-L911 | [
"def",
"GetMessages",
"(",
"self",
",",
"soft_size_limit",
"=",
"None",
")",
":",
"with",
"self",
".",
"_lock",
":",
"ret",
"=",
"rdf_flows",
".",
"MessageList",
"(",
")",
"ret_size",
"=",
"0",
"for",
"message",
"in",
"self",
".",
"_Generate",
"(",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.VerifyServerPEM | Check the server PEM for validity.
This is used to determine connectivity to the server. Sometimes captive
portals return a valid HTTP status, but the data is corrupted.
Args:
http_object: The response received from the server.
Returns:
True if the response contains a valid server certifi... | grr/client/grr_response_client/comms.py | def VerifyServerPEM(self, http_object):
"""Check the server PEM for validity.
This is used to determine connectivity to the server. Sometimes captive
portals return a valid HTTP status, but the data is corrupted.
Args:
http_object: The response received from the server.
Returns:
True ... | def VerifyServerPEM(self, http_object):
"""Check the server PEM for validity.
This is used to determine connectivity to the server. Sometimes captive
portals return a valid HTTP status, but the data is corrupted.
Args:
http_object: The response received from the server.
Returns:
True ... | [
"Check",
"the",
"server",
"PEM",
"for",
"validity",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1004-L1033 | [
"def",
"VerifyServerPEM",
"(",
"self",
",",
"http_object",
")",
":",
"try",
":",
"server_pem",
"=",
"http_object",
".",
"data",
"server_url",
"=",
"http_object",
".",
"url",
"if",
"b\"BEGIN CERTIFICATE\"",
"in",
"server_pem",
":",
"# Now we know that this proxy is w... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.VerifyServerControlResponse | Verify the server response to a 'control' endpoint POST message.
We consider the message correct if and only if we can decrypt it
properly. Note that in practice we can not use the HTTP status to figure out
if the request worked because captive proxies have a habit of lying and
returning a HTTP success... | grr/client/grr_response_client/comms.py | def VerifyServerControlResponse(self, http_object):
"""Verify the server response to a 'control' endpoint POST message.
We consider the message correct if and only if we can decrypt it
properly. Note that in practice we can not use the HTTP status to figure out
if the request worked because captive pro... | def VerifyServerControlResponse(self, http_object):
"""Verify the server response to a 'control' endpoint POST message.
We consider the message correct if and only if we can decrypt it
properly. Note that in practice we can not use the HTTP status to figure out
if the request worked because captive pro... | [
"Verify",
"the",
"server",
"response",
"to",
"a",
"control",
"endpoint",
"POST",
"message",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1035-L1065 | [
"def",
"VerifyServerControlResponse",
"(",
"self",
",",
"http_object",
")",
":",
"if",
"http_object",
".",
"code",
"!=",
"200",
":",
"return",
"False",
"# Try to decrypt the message into the http_object.",
"try",
":",
"http_object",
".",
"messages",
",",
"http_object"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.MakeRequest | Make a HTTP Post request to the server 'control' endpoint. | grr/client/grr_response_client/comms.py | def MakeRequest(self, data):
"""Make a HTTP Post request to the server 'control' endpoint."""
stats_collector_instance.Get().IncrementCounter("grr_client_sent_bytes",
len(data))
# Verify the response is as it should be from the control endpoint.
respo... | def MakeRequest(self, data):
"""Make a HTTP Post request to the server 'control' endpoint."""
stats_collector_instance.Get().IncrementCounter("grr_client_sent_bytes",
len(data))
# Verify the response is as it should be from the control endpoint.
respo... | [
"Make",
"a",
"HTTP",
"Post",
"request",
"to",
"the",
"server",
"control",
"endpoint",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1067-L1089 | [
"def",
"MakeRequest",
"(",
"self",
",",
"data",
")",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"grr_client_sent_bytes\"",
",",
"len",
"(",
"data",
")",
")",
"# Verify the response is as it should be from the control endpoint.... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.RunOnce | Makes a single request to the GRR server.
Returns:
A Status() object indicating how the last POST went. | grr/client/grr_response_client/comms.py | def RunOnce(self):
"""Makes a single request to the GRR server.
Returns:
A Status() object indicating how the last POST went.
"""
# Attempt to fetch and load server certificate.
if not self._FetchServerCertificate():
self.timer.Wait()
return HTTPObject(code=500)
# Here we onl... | def RunOnce(self):
"""Makes a single request to the GRR server.
Returns:
A Status() object indicating how the last POST went.
"""
# Attempt to fetch and load server certificate.
if not self._FetchServerCertificate():
self.timer.Wait()
return HTTPObject(code=500)
# Here we onl... | [
"Makes",
"a",
"single",
"request",
"to",
"the",
"GRR",
"server",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1091-L1191 | [
"def",
"RunOnce",
"(",
"self",
")",
":",
"# Attempt to fetch and load server certificate.",
"if",
"not",
"self",
".",
"_FetchServerCertificate",
"(",
")",
":",
"self",
".",
"timer",
".",
"Wait",
"(",
")",
"return",
"HTTPObject",
"(",
"code",
"=",
"500",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient._FetchServerCertificate | Attempts to fetch the server cert.
Returns:
True if we succeed. | grr/client/grr_response_client/comms.py | def _FetchServerCertificate(self):
"""Attempts to fetch the server cert.
Returns:
True if we succeed.
"""
# Certificate is loaded and still valid.
if self.server_certificate:
return True
response = self.http_manager.OpenServerEndpoint(
"server.pem", verify_cb=self.VerifySer... | def _FetchServerCertificate(self):
"""Attempts to fetch the server cert.
Returns:
True if we succeed.
"""
# Certificate is loaded and still valid.
if self.server_certificate:
return True
response = self.http_manager.OpenServerEndpoint(
"server.pem", verify_cb=self.VerifySer... | [
"Attempts",
"to",
"fetch",
"the",
"server",
"cert",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1199-L1218 | [
"def",
"_FetchServerCertificate",
"(",
"self",
")",
":",
"# Certificate is loaded and still valid.",
"if",
"self",
".",
"server_certificate",
":",
"return",
"True",
"response",
"=",
"self",
".",
"http_manager",
".",
"OpenServerEndpoint",
"(",
"\"server.pem\"",
",",
"v... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.Run | The main run method of the client.
This method does not normally return. Only if there have been more than
connection_error_limit failures, the method returns and allows the
client to exit. | grr/client/grr_response_client/comms.py | def Run(self):
"""The main run method of the client.
This method does not normally return. Only if there have been more than
connection_error_limit failures, the method returns and allows the
client to exit.
"""
while True:
if self.http_manager.ErrorLimitReached():
return
#... | def Run(self):
"""The main run method of the client.
This method does not normally return. Only if there have been more than
connection_error_limit failures, the method returns and allows the
client to exit.
"""
while True:
if self.http_manager.ErrorLimitReached():
return
#... | [
"The",
"main",
"run",
"method",
"of",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1220-L1277 | [
"def",
"Run",
"(",
"self",
")",
":",
"while",
"True",
":",
"if",
"self",
".",
"http_manager",
".",
"ErrorLimitReached",
"(",
")",
":",
"return",
"# Check if there is a message from the nanny to be sent.",
"self",
".",
"client_worker",
".",
"SendNannyMessage",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRHTTPClient.InitiateEnrolment | Initiate the enrollment process.
We do not sent more than one enrollment request every 10 minutes. Note that
we still communicate to the server in fast poll mode, but these requests are
not carrying any payload. | grr/client/grr_response_client/comms.py | def InitiateEnrolment(self):
"""Initiate the enrollment process.
We do not sent more than one enrollment request every 10 minutes. Note that
we still communicate to the server in fast poll mode, but these requests are
not carrying any payload.
"""
logging.debug("sending enrollment request")
... | def InitiateEnrolment(self):
"""Initiate the enrollment process.
We do not sent more than one enrollment request every 10 minutes. Note that
we still communicate to the server in fast poll mode, but these requests are
not carrying any payload.
"""
logging.debug("sending enrollment request")
... | [
"Initiate",
"the",
"enrollment",
"process",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1279-L1300 | [
"def",
"InitiateEnrolment",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"sending enrollment request\"",
")",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"now",
">",
"self",
".",
"last_enrollment_time",
"+",
"10",
"*",
"60",
":",
"if",
"no... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientCommunicator.InitPrivateKey | Makes sure this client has a private key set.
It first tries to load an RSA key from the certificate.
If no certificate is found, or it is invalid, we make a new random RSA key,
and store it as our certificate.
Returns:
An RSA key - either from the certificate or a new random key. | grr/client/grr_response_client/comms.py | def InitPrivateKey(self):
"""Makes sure this client has a private key set.
It first tries to load an RSA key from the certificate.
If no certificate is found, or it is invalid, we make a new random RSA key,
and store it as our certificate.
Returns:
An RSA key - either from the certificate o... | def InitPrivateKey(self):
"""Makes sure this client has a private key set.
It first tries to load an RSA key from the certificate.
If no certificate is found, or it is invalid, we make a new random RSA key,
and store it as our certificate.
Returns:
An RSA key - either from the certificate o... | [
"Makes",
"sure",
"this",
"client",
"has",
"a",
"private",
"key",
"set",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1315-L1347 | [
"def",
"InitPrivateKey",
"(",
"self",
")",
":",
"if",
"self",
".",
"private_key",
":",
"try",
":",
"self",
".",
"common_name",
"=",
"rdf_client",
".",
"ClientURN",
".",
"FromPrivateKey",
"(",
"self",
".",
"private_key",
")",
"logging",
".",
"info",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientCommunicator.GetCSR | Return our CSR. | grr/client/grr_response_client/comms.py | def GetCSR(self):
"""Return our CSR."""
return rdf_crypto.CertificateSigningRequest(
common_name=self.common_name, private_key=self.private_key) | def GetCSR(self):
"""Return our CSR."""
return rdf_crypto.CertificateSigningRequest(
common_name=self.common_name, private_key=self.private_key) | [
"Return",
"our",
"CSR",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1349-L1352 | [
"def",
"GetCSR",
"(",
"self",
")",
":",
"return",
"rdf_crypto",
".",
"CertificateSigningRequest",
"(",
"common_name",
"=",
"self",
".",
"common_name",
",",
"private_key",
"=",
"self",
".",
"private_key",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientCommunicator.SavePrivateKey | Store the new private key on disk. | grr/client/grr_response_client/comms.py | def SavePrivateKey(self, private_key):
"""Store the new private key on disk."""
self.private_key = private_key
config.CONFIG.Set("Client.private_key",
self.private_key.SerializeToString())
config.CONFIG.Write() | def SavePrivateKey(self, private_key):
"""Store the new private key on disk."""
self.private_key = private_key
config.CONFIG.Set("Client.private_key",
self.private_key.SerializeToString())
config.CONFIG.Write() | [
"Store",
"the",
"new",
"private",
"key",
"on",
"disk",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1358-L1363 | [
"def",
"SavePrivateKey",
"(",
"self",
",",
"private_key",
")",
":",
"self",
".",
"private_key",
"=",
"private_key",
"config",
".",
"CONFIG",
".",
"Set",
"(",
"\"Client.private_key\"",
",",
"self",
".",
"private_key",
".",
"SerializeToString",
"(",
")",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientCommunicator.LoadServerCertificate | Loads and verifies the server certificate. | grr/client/grr_response_client/comms.py | def LoadServerCertificate(self, server_certificate=None, ca_certificate=None):
"""Loads and verifies the server certificate."""
# Check that the server certificate verifies
try:
server_certificate.Verify(ca_certificate.GetPublicKey())
except rdf_crypto.VerificationError as e:
self.server_nam... | def LoadServerCertificate(self, server_certificate=None, ca_certificate=None):
"""Loads and verifies the server certificate."""
# Check that the server certificate verifies
try:
server_certificate.Verify(ca_certificate.GetPublicKey())
except rdf_crypto.VerificationError as e:
self.server_nam... | [
"Loads",
"and",
"verifies",
"the",
"server",
"certificate",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L1365-L1392 | [
"def",
"LoadServerCertificate",
"(",
"self",
",",
"server_certificate",
"=",
"None",
",",
"ca_certificate",
"=",
"None",
")",
":",
"# Check that the server certificate verifies",
"try",
":",
"server_certificate",
".",
"Verify",
"(",
"ca_certificate",
".",
"GetPublicKey"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntResultQueue.ClaimNotificationsForCollection | Return unclaimed hunt result notifications for collection.
Args:
token: The security token to perform database operations with.
start_time: If set, an RDFDateTime indicating at what point to start
claiming notifications. Only notifications with a timestamp after this
point will be claim... | grr/server/grr_response_server/hunts/results.py | def ClaimNotificationsForCollection(cls,
token=None,
start_time=None,
lease_time=200,
collection=None):
"""Return unclaimed hunt result notifications for collection... | def ClaimNotificationsForCollection(cls,
token=None,
start_time=None,
lease_time=200,
collection=None):
"""Return unclaimed hunt result notifications for collection... | [
"Return",
"unclaimed",
"hunt",
"result",
"notifications",
"for",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/results.py#L43-L92 | [
"def",
"ClaimNotificationsForCollection",
"(",
"cls",
",",
"token",
"=",
"None",
",",
"start_time",
"=",
"None",
",",
"lease_time",
"=",
"200",
",",
"collection",
"=",
"None",
")",
":",
"class",
"CollectionFilter",
"(",
"object",
")",
":",
"def",
"__init__",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ChunkTable | Chunks given table into multiple smaller ones.
Tables that osquery yields can be arbitrarily large. Because GRR's messages
cannot be arbitrarily large, it might happen that the table has to be split
into multiple smaller ones.
Note that that serialized response protos are going to be slightly bigger than
th... | grr/client/grr_response_client/client_actions/osquery.py | def ChunkTable(table,
max_chunk_size):
"""Chunks given table into multiple smaller ones.
Tables that osquery yields can be arbitrarily large. Because GRR's messages
cannot be arbitrarily large, it might happen that the table has to be split
into multiple smaller ones.
Note that that serialize... | def ChunkTable(table,
max_chunk_size):
"""Chunks given table into multiple smaller ones.
Tables that osquery yields can be arbitrarily large. Because GRR's messages
cannot be arbitrarily large, it might happen that the table has to be split
into multiple smaller ones.
Note that that serialize... | [
"Chunks",
"given",
"table",
"into",
"multiple",
"smaller",
"ones",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osquery.py#L97-L148 | [
"def",
"ChunkTable",
"(",
"table",
",",
"max_chunk_size",
")",
":",
"def",
"ByteLength",
"(",
"string",
")",
":",
"return",
"len",
"(",
"string",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
"def",
"Chunk",
"(",
")",
":",
"result",
"=",
"rdf_osquery",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ParseTable | Parses table of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryTable` instance. | grr/client/grr_response_client/client_actions/osquery.py | def ParseTable(table):
"""Parses table of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryTable` instance.
"""
precondition.AssertIterableType(table, dict)
result = rdf_osquery.OsqueryTable()
result.header = ParseHeader(table)
for ... | def ParseTable(table):
"""Parses table of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryTable` instance.
"""
precondition.AssertIterableType(table, dict)
result = rdf_osquery.OsqueryTable()
result.header = ParseHeader(table)
for ... | [
"Parses",
"table",
"of",
"osquery",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osquery.py#L151-L166 | [
"def",
"ParseTable",
"(",
"table",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"table",
",",
"dict",
")",
"result",
"=",
"rdf_osquery",
".",
"OsqueryTable",
"(",
")",
"result",
".",
"header",
"=",
"ParseHeader",
"(",
"table",
")",
"for",
"row... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ParseHeader | Parses header of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryHeader` instance. | grr/client/grr_response_client/client_actions/osquery.py | def ParseHeader(table):
"""Parses header of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryHeader` instance.
"""
precondition.AssertIterableType(table, dict)
prototype = None # type: List[Text]
for row in table:
columns = list... | def ParseHeader(table):
"""Parses header of osquery output.
Args:
table: A table in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryHeader` instance.
"""
precondition.AssertIterableType(table, dict)
prototype = None # type: List[Text]
for row in table:
columns = list... | [
"Parses",
"header",
"of",
"osquery",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osquery.py#L170-L195 | [
"def",
"ParseHeader",
"(",
"table",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"table",
",",
"dict",
")",
"prototype",
"=",
"None",
"# type: List[Text]",
"for",
"row",
"in",
"table",
":",
"columns",
"=",
"list",
"(",
"iterkeys",
"(",
"row",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ParseRow | Parses a single row of osquery output.
Args:
header: A parsed header describing the row format.
row: A row in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryRow` instance. | grr/client/grr_response_client/client_actions/osquery.py | def ParseRow(header,
row):
"""Parses a single row of osquery output.
Args:
header: A parsed header describing the row format.
row: A row in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryRow` instance.
"""
precondition.AssertDictType(row, Text, Text)
result... | def ParseRow(header,
row):
"""Parses a single row of osquery output.
Args:
header: A parsed header describing the row format.
row: A row in a "parsed JSON" representation.
Returns:
A parsed `rdf_osquery.OsqueryRow` instance.
"""
precondition.AssertDictType(row, Text, Text)
result... | [
"Parses",
"a",
"single",
"row",
"of",
"osquery",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osquery.py#L198-L214 | [
"def",
"ParseRow",
"(",
"header",
",",
"row",
")",
":",
"precondition",
".",
"AssertDictType",
"(",
"row",
",",
"Text",
",",
"Text",
")",
"result",
"=",
"rdf_osquery",
".",
"OsqueryRow",
"(",
")",
"for",
"column",
"in",
"header",
".",
"columns",
":",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Query | Calls osquery with given query and returns its output.
Args:
args: A query to call osquery with.
Returns:
A "parsed JSON" representation of the osquery output.
Raises:
QueryError: If the query is incorrect.
TimeoutError: If a call to the osquery executable times out.
Error: If anything else... | grr/client/grr_response_client/client_actions/osquery.py | def Query(args):
"""Calls osquery with given query and returns its output.
Args:
args: A query to call osquery with.
Returns:
A "parsed JSON" representation of the osquery output.
Raises:
QueryError: If the query is incorrect.
TimeoutError: If a call to the osquery executable times out.
E... | def Query(args):
"""Calls osquery with given query and returns its output.
Args:
args: A query to call osquery with.
Returns:
A "parsed JSON" representation of the osquery output.
Raises:
QueryError: If the query is incorrect.
TimeoutError: If a call to the osquery executable times out.
E... | [
"Calls",
"osquery",
"with",
"given",
"query",
"and",
"returns",
"its",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/osquery.py#L221-L264 | [
"def",
"Query",
"(",
"args",
")",
":",
"query",
"=",
"args",
".",
"query",
".",
"encode",
"(",
"\"utf-8\"",
")",
"timeout",
"=",
"args",
".",
"timeout_millis",
"/",
"1000",
"# `subprocess.run` uses seconds.",
"# TODO: pytype is not aware of the backport.",
"# pytype... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | RegularExpression.Search | Search the text for our value. | grr/core/grr_response_core/lib/rdfvalues/standard.py | def Search(self, text):
"""Search the text for our value."""
if isinstance(text, rdfvalue.RDFString):
text = str(text)
return self._regex.search(text) | def Search(self, text):
"""Search the text for our value."""
if isinstance(text, rdfvalue.RDFString):
text = str(text)
return self._regex.search(text) | [
"Search",
"the",
"text",
"for",
"our",
"value",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/standard.py#L33-L38 | [
"def",
"Search",
"(",
"self",
",",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"rdfvalue",
".",
"RDFString",
")",
":",
"text",
"=",
"str",
"(",
"text",
")",
"return",
"self",
".",
"_regex",
".",
"search",
"(",
"text",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | EmailAlerterBase.SplitEmailsAndAppendEmailDomain | Splits a string of comma-separated emails, appending default domain. | grr/server/grr_response_server/email_alerts.py | def SplitEmailsAndAppendEmailDomain(self, address_list):
"""Splits a string of comma-separated emails, appending default domain."""
result = []
# Process email addresses, and build up a list.
if isinstance(address_list, rdf_standard.DomainEmailAddress):
address_list = [str(address_list)]
elif ... | def SplitEmailsAndAppendEmailDomain(self, address_list):
"""Splits a string of comma-separated emails, appending default domain."""
result = []
# Process email addresses, and build up a list.
if isinstance(address_list, rdf_standard.DomainEmailAddress):
address_list = [str(address_list)]
elif ... | [
"Splits",
"a",
"string",
"of",
"comma",
"-",
"separated",
"emails",
"appending",
"default",
"domain",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/email_alerts.py#L42-L52 | [
"def",
"SplitEmailsAndAppendEmailDomain",
"(",
"self",
",",
"address_list",
")",
":",
"result",
"=",
"[",
"]",
"# Process email addresses, and build up a list.",
"if",
"isinstance",
"(",
"address_list",
",",
"rdf_standard",
".",
"DomainEmailAddress",
")",
":",
"address_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SMTPEmailAlerter.SendEmail | This method sends an email notification.
Args:
to_addresses: blah@mycompany.com string, list of addresses as csv string,
or rdf_standard.DomainEmailAddress
from_address: blah@mycompany.com string
subject: email subject string
message: message contents string, as HTML or ... | grr/server/grr_response_server/email_alerts.py | def SendEmail(self,
to_addresses,
from_address,
subject,
message,
attachments=None,
is_html=True,
cc_addresses=None,
message_id=None,
headers=None):
"""This method sends an... | def SendEmail(self,
to_addresses,
from_address,
subject,
message,
attachments=None,
is_html=True,
cc_addresses=None,
message_id=None,
headers=None):
"""This method sends an... | [
"This",
"method",
"sends",
"an",
"email",
"notification",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/email_alerts.py#L69-L153 | [
"def",
"SendEmail",
"(",
"self",
",",
"to_addresses",
",",
"from_address",
",",
"subject",
",",
"message",
",",
"attachments",
"=",
"None",
",",
"is_html",
"=",
"True",
",",
"cc_addresses",
"=",
"None",
",",
"message_id",
"=",
"None",
",",
"headers",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ScheduleSystemCronFlows | Schedule all the SystemCronFlows found. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def ScheduleSystemCronFlows(names=None, token=None):
"""Schedule all the SystemCronFlows found."""
if data_store.RelationalDBEnabled():
return cronjobs.ScheduleSystemCronJobs(names=names)
errors = []
for name in config.CONFIG["Cron.disabled_system_jobs"]:
try:
cls = registry.AFF4FlowRegistry.Flo... | def ScheduleSystemCronFlows(names=None, token=None):
"""Schedule all the SystemCronFlows found."""
if data_store.RelationalDBEnabled():
return cronjobs.ScheduleSystemCronJobs(names=names)
errors = []
for name in config.CONFIG["Cron.disabled_system_jobs"]:
try:
cls = registry.AFF4FlowRegistry.Flo... | [
"Schedule",
"all",
"the",
"SystemCronFlows",
"found",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L253-L310 | [
"def",
"ScheduleSystemCronFlows",
"(",
"names",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
":",
"return",
"cronjobs",
".",
"ScheduleSystemCronJobs",
"(",
"names",
"=",
"names",
")",
"errors",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DualDBSystemCronJob | Decorator that creates AFF4 and RELDB cronjobs from a given mixin. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def DualDBSystemCronJob(legacy_name=None, stateful=False):
"""Decorator that creates AFF4 and RELDB cronjobs from a given mixin."""
def Decorator(cls):
"""Decorator producing 2 classes: legacy style one and a new style one."""
if not legacy_name:
raise ValueError("legacy_name has to be provided")
... | def DualDBSystemCronJob(legacy_name=None, stateful=False):
"""Decorator that creates AFF4 and RELDB cronjobs from a given mixin."""
def Decorator(cls):
"""Decorator producing 2 classes: legacy style one and a new style one."""
if not legacy_name:
raise ValueError("legacy_name has to be provided")
... | [
"Decorator",
"that",
"creates",
"AFF4",
"and",
"RELDB",
"cronjobs",
"from",
"a",
"given",
"mixin",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L563-L599 | [
"def",
"DualDBSystemCronJob",
"(",
"legacy_name",
"=",
"None",
",",
"stateful",
"=",
"False",
")",
":",
"def",
"Decorator",
"(",
"cls",
")",
":",
"\"\"\"Decorator producing 2 classes: legacy style one and a new style one.\"\"\"",
"if",
"not",
"legacy_name",
":",
"raise"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.CreateJob | Creates a cron job that runs given flow with a given frequency.
Args:
cron_args: A protobuf of type rdf_cronjobs.CreateCronJobArgs.
job_id: Use this job_id instead of an autogenerated unique name (used for
system cron jobs - we want them to have well-defined persistent name).
token: Secur... | grr/server/grr_response_server/aff4_objects/cronjobs.py | def CreateJob(self, cron_args=None, job_id=None, token=None, enabled=True):
"""Creates a cron job that runs given flow with a given frequency.
Args:
cron_args: A protobuf of type rdf_cronjobs.CreateCronJobArgs.
job_id: Use this job_id instead of an autogenerated unique name (used for
system... | def CreateJob(self, cron_args=None, job_id=None, token=None, enabled=True):
"""Creates a cron job that runs given flow with a given frequency.
Args:
cron_args: A protobuf of type rdf_cronjobs.CreateCronJobArgs.
job_id: Use this job_id instead of an autogenerated unique name (used for
system... | [
"Creates",
"a",
"cron",
"job",
"that",
"runs",
"given",
"flow",
"with",
"a",
"given",
"frequency",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L42-L95 | [
"def",
"CreateJob",
"(",
"self",
",",
"cron_args",
"=",
"None",
",",
"job_id",
"=",
"None",
",",
"token",
"=",
"None",
",",
"enabled",
"=",
"True",
")",
":",
"if",
"not",
"job_id",
":",
"uid",
"=",
"random",
".",
"UInt16",
"(",
")",
"job_id",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.ListJobs | Returns a list of all currently running cron jobs. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def ListJobs(self, token=None):
"""Returns a list of all currently running cron jobs."""
job_root = aff4.FACTORY.Open(self.CRON_JOBS_PATH, token=token)
return [urn.Basename() for urn in job_root.ListChildren()] | def ListJobs(self, token=None):
"""Returns a list of all currently running cron jobs."""
job_root = aff4.FACTORY.Open(self.CRON_JOBS_PATH, token=token)
return [urn.Basename() for urn in job_root.ListChildren()] | [
"Returns",
"a",
"list",
"of",
"all",
"currently",
"running",
"cron",
"jobs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L97-L100 | [
"def",
"ListJobs",
"(",
"self",
",",
"token",
"=",
"None",
")",
":",
"job_root",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"self",
".",
"CRON_JOBS_PATH",
",",
"token",
"=",
"token",
")",
"return",
"[",
"urn",
".",
"Basename",
"(",
")",
"for",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.EnableJob | Enable cron job with the given URN. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def EnableJob(self, job_id, token=None):
"""Enable cron job with the given URN."""
job_urn = self.CRON_JOBS_PATH.Add(job_id)
cron_job = aff4.FACTORY.Open(
job_urn, mode="rw", aff4_type=CronJob, token=token)
cron_job.Set(cron_job.Schema.DISABLED(0))
cron_job.Close() | def EnableJob(self, job_id, token=None):
"""Enable cron job with the given URN."""
job_urn = self.CRON_JOBS_PATH.Add(job_id)
cron_job = aff4.FACTORY.Open(
job_urn, mode="rw", aff4_type=CronJob, token=token)
cron_job.Set(cron_job.Schema.DISABLED(0))
cron_job.Close() | [
"Enable",
"cron",
"job",
"with",
"the",
"given",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L117-L123 | [
"def",
"EnableJob",
"(",
"self",
",",
"job_id",
",",
"token",
"=",
"None",
")",
":",
"job_urn",
"=",
"self",
".",
"CRON_JOBS_PATH",
".",
"Add",
"(",
"job_id",
")",
"cron_job",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"job_urn",
",",
"mode",
"="... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.DeleteJob | Deletes cron job with the given URN. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def DeleteJob(self, job_id, token=None):
"""Deletes cron job with the given URN."""
job_urn = self.CRON_JOBS_PATH.Add(job_id)
aff4.FACTORY.Delete(job_urn, token=token) | def DeleteJob(self, job_id, token=None):
"""Deletes cron job with the given URN."""
job_urn = self.CRON_JOBS_PATH.Add(job_id)
aff4.FACTORY.Delete(job_urn, token=token) | [
"Deletes",
"cron",
"job",
"with",
"the",
"given",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L133-L136 | [
"def",
"DeleteJob",
"(",
"self",
",",
"job_id",
",",
"token",
"=",
"None",
")",
":",
"job_urn",
"=",
"self",
".",
"CRON_JOBS_PATH",
".",
"Add",
"(",
"job_id",
")",
"aff4",
".",
"FACTORY",
".",
"Delete",
"(",
"job_urn",
",",
"token",
"=",
"token",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.RunOnce | Tries to lock and run cron jobs.
Args:
token: security token
force: If True, force a run
names: List of job names to run. If unset, run them all | grr/server/grr_response_server/aff4_objects/cronjobs.py | def RunOnce(self, token=None, force=False, names=None):
"""Tries to lock and run cron jobs.
Args:
token: security token
force: If True, force a run
names: List of job names to run. If unset, run them all
"""
names = names or self.ListJobs(token=token)
urns = [self.CRON_JOBS_PATH.... | def RunOnce(self, token=None, force=False, names=None):
"""Tries to lock and run cron jobs.
Args:
token: security token
force: If True, force a run
names: List of job names to run. If unset, run them all
"""
names = names or self.ListJobs(token=token)
urns = [self.CRON_JOBS_PATH.... | [
"Tries",
"to",
"lock",
"and",
"run",
"cron",
"jobs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L138-L164 | [
"def",
"RunOnce",
"(",
"self",
",",
"token",
"=",
"None",
",",
"force",
"=",
"False",
",",
"names",
"=",
"None",
")",
":",
"names",
"=",
"names",
"or",
"self",
".",
"ListJobs",
"(",
"token",
"=",
"token",
")",
"urns",
"=",
"[",
"self",
".",
"CRON... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronManager.DeleteOldRuns | Deletes flows initiated by the job that are older than specified. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def DeleteOldRuns(self, job, cutoff_timestamp=None, token=None):
"""Deletes flows initiated by the job that are older than specified."""
if cutoff_timestamp is None:
raise ValueError("cutoff_timestamp can't be None")
child_flows = list(job.ListChildren(age=cutoff_timestamp))
with queue_manager.Qu... | def DeleteOldRuns(self, job, cutoff_timestamp=None, token=None):
"""Deletes flows initiated by the job that are older than specified."""
if cutoff_timestamp is None:
raise ValueError("cutoff_timestamp can't be None")
child_flows = list(job.ListChildren(age=cutoff_timestamp))
with queue_manager.Qu... | [
"Deletes",
"flows",
"initiated",
"by",
"the",
"job",
"that",
"are",
"older",
"than",
"specified",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L166-L176 | [
"def",
"DeleteOldRuns",
"(",
"self",
",",
"job",
",",
"cutoff_timestamp",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"cutoff_timestamp",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"cutoff_timestamp can't be None\"",
")",
"child_flows",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronWorker.RunAsync | Runs a working thread and returns immediately. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def RunAsync(self):
"""Runs a working thread and returns immediately."""
self.running_thread = threading.Thread(
name=self.thread_name, target=self._RunLoop)
self.running_thread.daemon = True
self.running_thread.start()
return self.running_thread | def RunAsync(self):
"""Runs a working thread and returns immediately."""
self.running_thread = threading.Thread(
name=self.thread_name, target=self._RunLoop)
self.running_thread.daemon = True
self.running_thread.start()
return self.running_thread | [
"Runs",
"a",
"working",
"thread",
"and",
"returns",
"immediately",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L339-L345 | [
"def",
"RunAsync",
"(",
"self",
")",
":",
"self",
".",
"running_thread",
"=",
"threading",
".",
"Thread",
"(",
"name",
"=",
"self",
".",
"thread_name",
",",
"target",
"=",
"self",
".",
"_RunLoop",
")",
"self",
".",
"running_thread",
".",
"daemon",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronJob.IsRunning | Returns True if there's a currently running iteration of this job. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def IsRunning(self):
"""Returns True if there's a currently running iteration of this job."""
current_urn = self.Get(self.Schema.CURRENT_FLOW_URN)
if not current_urn:
return False
try:
current_flow = aff4.FACTORY.Open(
urn=current_urn, aff4_type=flow.GRRFlow, token=self.token, mod... | def IsRunning(self):
"""Returns True if there's a currently running iteration of this job."""
current_urn = self.Get(self.Schema.CURRENT_FLOW_URN)
if not current_urn:
return False
try:
current_flow = aff4.FACTORY.Open(
urn=current_urn, aff4_type=flow.GRRFlow, token=self.token, mod... | [
"Returns",
"True",
"if",
"there",
"s",
"a",
"currently",
"running",
"iteration",
"of",
"this",
"job",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L392-L408 | [
"def",
"IsRunning",
"(",
"self",
")",
":",
"current_urn",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"CURRENT_FLOW_URN",
")",
"if",
"not",
"current_urn",
":",
"return",
"False",
"try",
":",
"current_flow",
"=",
"aff4",
".",
"FACTORY",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronJob.DueToRun | Called periodically by the cron daemon, if True Run() will be called.
Returns:
True if it is time to run based on the specified frequency. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def DueToRun(self):
"""Called periodically by the cron daemon, if True Run() will be called.
Returns:
True if it is time to run based on the specified frequency.
"""
if self.Get(self.Schema.DISABLED):
return False
cron_args = self.Get(self.Schema.CRON_ARGS)
last_run_time = self.G... | def DueToRun(self):
"""Called periodically by the cron daemon, if True Run() will be called.
Returns:
True if it is time to run based on the specified frequency.
"""
if self.Get(self.Schema.DISABLED):
return False
cron_args = self.Get(self.Schema.CRON_ARGS)
last_run_time = self.G... | [
"Called",
"periodically",
"by",
"the",
"cron",
"daemon",
"if",
"True",
"Run",
"()",
"will",
"be",
"called",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L410-L439 | [
"def",
"DueToRun",
"(",
"self",
")",
":",
"if",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"DISABLED",
")",
":",
"return",
"False",
"cron_args",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"CRON_ARGS",
")",
"last_run_time",
"=... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronJob.KillOldFlows | Disable cron flow if it has exceeded CRON_ARGS.lifetime.
Returns:
bool: True if the flow is was killed. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def KillOldFlows(self):
"""Disable cron flow if it has exceeded CRON_ARGS.lifetime.
Returns:
bool: True if the flow is was killed.
"""
if not self.IsRunning():
return False
start_time = self.Get(self.Schema.LAST_RUN_TIME)
lifetime = self.Get(self.Schema.CRON_ARGS).lifetime
ela... | def KillOldFlows(self):
"""Disable cron flow if it has exceeded CRON_ARGS.lifetime.
Returns:
bool: True if the flow is was killed.
"""
if not self.IsRunning():
return False
start_time = self.Get(self.Schema.LAST_RUN_TIME)
lifetime = self.Get(self.Schema.CRON_ARGS).lifetime
ela... | [
"Disable",
"cron",
"flow",
"if",
"it",
"has",
"exceeded",
"CRON_ARGS",
".",
"lifetime",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L453-L475 | [
"def",
"KillOldFlows",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"IsRunning",
"(",
")",
":",
"return",
"False",
"start_time",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"LAST_RUN_TIME",
")",
"lifetime",
"=",
"self",
".",
"Get",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronJob.Run | Do the actual work of the Cron.
Will first check if DueToRun is True.
CronJob object must be locked (i.e. opened via OpenWithLock) for Run() to be
called.
Args:
force: If True, the job will run no matter what (i.e. even if DueToRun()
returns False).
Raises:
LockError: if the ... | grr/server/grr_response_server/aff4_objects/cronjobs.py | def Run(self, force=False):
"""Do the actual work of the Cron.
Will first check if DueToRun is True.
CronJob object must be locked (i.e. opened via OpenWithLock) for Run() to be
called.
Args:
force: If True, the job will run no matter what (i.e. even if DueToRun()
returns False).
... | def Run(self, force=False):
"""Do the actual work of the Cron.
Will first check if DueToRun is True.
CronJob object must be locked (i.e. opened via OpenWithLock) for Run() to be
called.
Args:
force: If True, the job will run no matter what (i.e. even if DueToRun()
returns False).
... | [
"Do",
"the",
"actual",
"work",
"of",
"the",
"Cron",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L477-L539 | [
"def",
"Run",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"locked",
":",
"raise",
"aff4",
".",
"LockError",
"(",
"\"CronJob must be locked for Run() to be called.\"",
")",
"self",
".",
"KillOldFlows",
"(",
")",
"# If currently ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronHook.RunOnce | Main CronHook method. | grr/server/grr_response_server/aff4_objects/cronjobs.py | def RunOnce(self):
"""Main CronHook method."""
# Start the cron thread if configured to.
if config.CONFIG["Cron.active"]:
self.cron_worker = CronWorker()
self.cron_worker.RunAsync() | def RunOnce(self):
"""Main CronHook method."""
# Start the cron thread if configured to.
if config.CONFIG["Cron.active"]:
self.cron_worker = CronWorker()
self.cron_worker.RunAsync() | [
"Main",
"CronHook",
"method",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L547-L553 | [
"def",
"RunOnce",
"(",
"self",
")",
":",
"# Start the cron thread if configured to.",
"if",
"config",
".",
"CONFIG",
"[",
"\"Cron.active\"",
"]",
":",
"self",
".",
"cron_worker",
"=",
"CronWorker",
"(",
")",
"self",
".",
"cron_worker",
".",
"RunAsync",
"(",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FingerprintFileLogic.FingerprintFile | Launch a fingerprint client action. | grr/server/grr_response_server/flows/general/fingerprint.py | def FingerprintFile(self, pathspec, max_filesize=None, request_data=None):
"""Launch a fingerprint client action."""
request = rdf_client_action.FingerprintRequest(pathspec=pathspec)
if max_filesize is not None:
request.max_filesize = max_filesize
# Generic hash.
request.AddRequest(
f... | def FingerprintFile(self, pathspec, max_filesize=None, request_data=None):
"""Launch a fingerprint client action."""
request = rdf_client_action.FingerprintRequest(pathspec=pathspec)
if max_filesize is not None:
request.max_filesize = max_filesize
# Generic hash.
request.AddRequest(
f... | [
"Launch",
"a",
"fingerprint",
"client",
"action",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/fingerprint.py#L42-L70 | [
"def",
"FingerprintFile",
"(",
"self",
",",
"pathspec",
",",
"max_filesize",
"=",
"None",
",",
"request_data",
"=",
"None",
")",
":",
"request",
"=",
"rdf_client_action",
".",
"FingerprintRequest",
"(",
"pathspec",
"=",
"pathspec",
")",
"if",
"max_filesize",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FingerprintFileLogic.ProcessFingerprint | Store the fingerprint response. | grr/server/grr_response_server/flows/general/fingerprint.py | def ProcessFingerprint(self, responses):
"""Store the fingerprint response."""
if not responses.success:
# Its better to raise rather than merely logging since it will make it to
# the flow's protobuf and users can inspect the reason this flow failed.
raise flow.FlowError("Could not fingerprin... | def ProcessFingerprint(self, responses):
"""Store the fingerprint response."""
if not responses.success:
# Its better to raise rather than merely logging since it will make it to
# the flow's protobuf and users can inspect the reason this flow failed.
raise flow.FlowError("Could not fingerprin... | [
"Store",
"the",
"fingerprint",
"response",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/fingerprint.py#L72-L101 | [
"def",
"ProcessFingerprint",
"(",
"self",
",",
"responses",
")",
":",
"if",
"not",
"responses",
".",
"success",
":",
"# Its better to raise rather than merely logging since it will make it to",
"# the flow's protobuf and users can inspect the reason this flow failed.",
"raise",
"fl... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Clean | Clean out compiled protos. | grr/proto/makefile.py | def Clean():
"""Clean out compiled protos."""
# Find all the compiled proto files and unlink them.
for (root, _, files) in os.walk(ROOT):
for filename in files:
full_filename = os.path.join(root, filename)
if full_filename.endswith("_pb2.py") or full_filename.endswith(
"_pb2.pyc"):
... | def Clean():
"""Clean out compiled protos."""
# Find all the compiled proto files and unlink them.
for (root, _, files) in os.walk(ROOT):
for filename in files:
full_filename = os.path.join(root, filename)
if full_filename.endswith("_pb2.py") or full_filename.endswith(
"_pb2.pyc"):
... | [
"Clean",
"out",
"compiled",
"protos",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/proto/makefile.py#L28-L36 | [
"def",
"Clean",
"(",
")",
":",
"# Find all the compiled proto files and unlink them.",
"for",
"(",
"root",
",",
"_",
",",
"files",
")",
"in",
"os",
".",
"walk",
"(",
"ROOT",
")",
":",
"for",
"filename",
"in",
"files",
":",
"full_filename",
"=",
"os",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MakeProto | Make sure our protos have been compiled to python libraries. | grr/proto/makefile.py | def MakeProto():
"""Make sure our protos have been compiled to python libraries."""
# Start running from one directory above the grr directory which is found by
# this scripts's location as __file__.
cwd = os.path.dirname(os.path.abspath(__file__))
# Find all the .proto files.
protos_to_compile = []
for ... | def MakeProto():
"""Make sure our protos have been compiled to python libraries."""
# Start running from one directory above the grr directory which is found by
# this scripts's location as __file__.
cwd = os.path.dirname(os.path.abspath(__file__))
# Find all the .proto files.
protos_to_compile = []
for ... | [
"Make",
"sure",
"our",
"protos",
"have",
"been",
"compiled",
"to",
"python",
"libraries",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/proto/makefile.py#L39-L90 | [
"def",
"MakeProto",
"(",
")",
":",
"# Start running from one directory above the grr directory which is found by",
"# this scripts's location as __file__.",
"cwd",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Lexer.Reset | Reset the lexer to process a new data feed. | grr/core/grr_response_core/lib/lexer.py | def Reset(self):
"""Reset the lexer to process a new data feed."""
# The first state
self.state = "INITIAL"
self.state_stack = []
# The buffer we are parsing now
self.buffer = ""
self.error = 0
self.verbose = 0
# The index into the buffer where we are currently pointing
self.pr... | def Reset(self):
"""Reset the lexer to process a new data feed."""
# The first state
self.state = "INITIAL"
self.state_stack = []
# The buffer we are parsing now
self.buffer = ""
self.error = 0
self.verbose = 0
# The index into the buffer where we are currently pointing
self.pr... | [
"Reset",
"the",
"lexer",
"to",
"process",
"a",
"new",
"data",
"feed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L84-L97 | [
"def",
"Reset",
"(",
"self",
")",
":",
"# The first state",
"self",
".",
"state",
"=",
"\"INITIAL\"",
"self",
".",
"state_stack",
"=",
"[",
"]",
"# The buffer we are parsing now",
"self",
".",
"buffer",
"=",
"\"\"",
"self",
".",
"error",
"=",
"0",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Lexer.NextToken | Fetch the next token by trying to match any of the regexes in order. | grr/core/grr_response_core/lib/lexer.py | def NextToken(self):
"""Fetch the next token by trying to match any of the regexes in order."""
# Nothing in the input stream - no token can match.
if not self.buffer:
return
current_state = self.state
for token in self._tokens:
# Does the rule apply to us?
if token.state_regex an... | def NextToken(self):
"""Fetch the next token by trying to match any of the regexes in order."""
# Nothing in the input stream - no token can match.
if not self.buffer:
return
current_state = self.state
for token in self._tokens:
# Does the rule apply to us?
if token.state_regex an... | [
"Fetch",
"the",
"next",
"token",
"by",
"trying",
"to",
"match",
"any",
"of",
"the",
"regexes",
"in",
"order",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L99-L164 | [
"def",
"NextToken",
"(",
"self",
")",
":",
"# Nothing in the input stream - no token can match.",
"if",
"not",
"self",
".",
"buffer",
":",
"return",
"current_state",
"=",
"self",
".",
"state",
"for",
"token",
"in",
"self",
".",
"_tokens",
":",
"# Does the rule app... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Lexer.PushState | Push the current state on the state stack. | grr/core/grr_response_core/lib/lexer.py | def PushState(self, **_):
"""Push the current state on the state stack."""
if self.verbose:
logging.debug("Storing state %r", self.state)
self.state_stack.append(self.state) | def PushState(self, **_):
"""Push the current state on the state stack."""
if self.verbose:
logging.debug("Storing state %r", self.state)
self.state_stack.append(self.state) | [
"Push",
"the",
"current",
"state",
"on",
"the",
"state",
"stack",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L181-L185 | [
"def",
"PushState",
"(",
"self",
",",
"*",
"*",
"_",
")",
":",
"if",
"self",
".",
"verbose",
":",
"logging",
".",
"debug",
"(",
"\"Storing state %r\"",
",",
"self",
".",
"state",
")",
"self",
".",
"state_stack",
".",
"append",
"(",
"self",
".",
"stat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Lexer.PopState | Pop the previous state from the stack. | grr/core/grr_response_core/lib/lexer.py | def PopState(self, **_):
"""Pop the previous state from the stack."""
try:
self.state = self.state_stack.pop()
if self.verbose:
logging.debug("Returned state to %s", self.state)
return self.state
except IndexError:
self.Error("Tried to pop the state but failed - possible rec... | def PopState(self, **_):
"""Pop the previous state from the stack."""
try:
self.state = self.state_stack.pop()
if self.verbose:
logging.debug("Returned state to %s", self.state)
return self.state
except IndexError:
self.Error("Tried to pop the state but failed - possible rec... | [
"Pop",
"the",
"previous",
"state",
"from",
"the",
"stack",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L187-L196 | [
"def",
"PopState",
"(",
"self",
",",
"*",
"*",
"_",
")",
":",
"try",
":",
"self",
".",
"state",
"=",
"self",
".",
"state_stack",
".",
"pop",
"(",
")",
"if",
"self",
".",
"verbose",
":",
"logging",
".",
"debug",
"(",
"\"Returned state to %s\"",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Lexer.PushBack | Push the match back on the stream. | grr/core/grr_response_core/lib/lexer.py | def PushBack(self, string="", **_):
"""Push the match back on the stream."""
precondition.AssertType(string, Text)
self.buffer = string + self.buffer
self.processed_buffer = self.processed_buffer[:-len(string)] | def PushBack(self, string="", **_):
"""Push the match back on the stream."""
precondition.AssertType(string, Text)
self.buffer = string + self.buffer
self.processed_buffer = self.processed_buffer[:-len(string)] | [
"Push",
"the",
"match",
"back",
"on",
"the",
"stream",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L198-L202 | [
"def",
"PushBack",
"(",
"self",
",",
"string",
"=",
"\"\"",
",",
"*",
"*",
"_",
")",
":",
"precondition",
".",
"AssertType",
"(",
"string",
",",
"Text",
")",
"self",
".",
"buffer",
"=",
"string",
"+",
"self",
".",
"buffer",
"self",
".",
"processed_bu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Expression.AddArg | Adds a new arg to this expression.
Args:
arg: The argument to add (string).
Returns:
True if this arg is the last arg, False otherwise.
Raises:
ParseError: If there are too many args. | grr/core/grr_response_core/lib/lexer.py | def AddArg(self, arg):
"""Adds a new arg to this expression.
Args:
arg: The argument to add (string).
Returns:
True if this arg is the last arg, False otherwise.
Raises:
ParseError: If there are too many args.
"""
self.args.append(arg)
if len(self.args) > self.number_of... | def AddArg(self, arg):
"""Adds a new arg to this expression.
Args:
arg: The argument to add (string).
Returns:
True if this arg is the last arg, False otherwise.
Raises:
ParseError: If there are too many args.
"""
self.args.append(arg)
if len(self.args) > self.number_of... | [
"Adds",
"a",
"new",
"arg",
"to",
"this",
"expression",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L229-L248 | [
"def",
"AddArg",
"(",
"self",
",",
"arg",
")",
":",
"self",
".",
"args",
".",
"append",
"(",
"arg",
")",
"if",
"len",
"(",
"self",
".",
"args",
")",
">",
"self",
".",
"number_of_args",
":",
"raise",
"ParseError",
"(",
"\"Too many args for this expression... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SearchParser.StringEscape | Escape backslashes found inside a string quote.
Backslashes followed by anything other than ['"rnbt] will just be included
in the string.
Args:
string: The string that matched.
match: The match object (m.group(1) is the escaped code) | grr/core/grr_response_core/lib/lexer.py | def StringEscape(self, string, match, **_):
"""Escape backslashes found inside a string quote.
Backslashes followed by anything other than ['"rnbt] will just be included
in the string.
Args:
string: The string that matched.
match: The match object (m.group(1) is the escaped code)
"""... | def StringEscape(self, string, match, **_):
"""Escape backslashes found inside a string quote.
Backslashes followed by anything other than ['"rnbt] will just be included
in the string.
Args:
string: The string that matched.
match: The match object (m.group(1) is the escaped code)
"""... | [
"Escape",
"backslashes",
"found",
"inside",
"a",
"string",
"quote",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L380-L394 | [
"def",
"StringEscape",
"(",
"self",
",",
"string",
",",
"match",
",",
"*",
"*",
"_",
")",
":",
"precondition",
".",
"AssertType",
"(",
"string",
",",
"Text",
")",
"if",
"match",
".",
"group",
"(",
"1",
")",
"in",
"\"'\\\"rnbt\"",
":",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SearchParser.InsertArg | Insert an arg to the current expression. | grr/core/grr_response_core/lib/lexer.py | def InsertArg(self, string="", **_):
"""Insert an arg to the current expression."""
if self.verbose:
logging.debug("Storing Argument %s", utils.SmartUnicode(string))
# This expression is complete
if self.current_expression.AddArg(string):
self.stack.append(self.current_expression)
sel... | def InsertArg(self, string="", **_):
"""Insert an arg to the current expression."""
if self.verbose:
logging.debug("Storing Argument %s", utils.SmartUnicode(string))
# This expression is complete
if self.current_expression.AddArg(string):
self.stack.append(self.current_expression)
sel... | [
"Insert",
"an",
"arg",
"to",
"the",
"current",
"expression",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/lexer.py#L423-L432 | [
"def",
"InsertArg",
"(",
"self",
",",
"string",
"=",
"\"\"",
",",
"*",
"*",
"_",
")",
":",
"if",
"self",
".",
"verbose",
":",
"logging",
".",
"debug",
"(",
"\"Storing Argument %s\"",
",",
"utils",
".",
"SmartUnicode",
"(",
"string",
")",
")",
"# This e... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateHunt | Creates a new hunt.
Args:
flow_name: String with a name of a flow that will run on all the clients
in the hunt.
flow_args: Flow arguments to be used. A proto, that depends on a flow.
hunt_runner_args: flows_pb2.HuntRunnerArgs instance. Used to specify
description, client_rule_set, output_... | api_client/python/grr_api_client/hunt.py | def CreateHunt(flow_name=None,
flow_args=None,
hunt_runner_args=None,
context=None):
"""Creates a new hunt.
Args:
flow_name: String with a name of a flow that will run on all the clients
in the hunt.
flow_args: Flow arguments to be used. A proto, that de... | def CreateHunt(flow_name=None,
flow_args=None,
hunt_runner_args=None,
context=None):
"""Creates a new hunt.
Args:
flow_name: String with a name of a flow that will run on all the clients
in the hunt.
flow_args: Flow arguments to be used. A proto, that de... | [
"Creates",
"a",
"new",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L306-L339 | [
"def",
"CreateHunt",
"(",
"flow_name",
"=",
"None",
",",
"flow_args",
"=",
"None",
",",
"hunt_runner_args",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"not",
"flow_name",
":",
"raise",
"ValueError",
"(",
"\"flow_name can't be empty\"",
")",
"r... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ListHunts | List all GRR hunts. | api_client/python/grr_api_client/hunt.py | def ListHunts(context=None):
"""List all GRR hunts."""
items = context.SendIteratorRequest("ListHunts", hunt_pb2.ApiListHuntsArgs())
return utils.MapItemsIterator(lambda data: Hunt(data=data, context=context),
items) | def ListHunts(context=None):
"""List all GRR hunts."""
items = context.SendIteratorRequest("ListHunts", hunt_pb2.ApiListHuntsArgs())
return utils.MapItemsIterator(lambda data: Hunt(data=data, context=context),
items) | [
"List",
"all",
"GRR",
"hunts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L342-L347 | [
"def",
"ListHunts",
"(",
"context",
"=",
"None",
")",
":",
"items",
"=",
"context",
".",
"SendIteratorRequest",
"(",
"\"ListHunts\"",
",",
"hunt_pb2",
".",
"ApiListHuntsArgs",
"(",
")",
")",
"return",
"utils",
".",
"MapItemsIterator",
"(",
"lambda",
"data",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ListHuntApprovals | List all hunt approvals belonging to requesting user. | api_client/python/grr_api_client/hunt.py | def ListHuntApprovals(context=None):
"""List all hunt approvals belonging to requesting user."""
items = context.SendIteratorRequest("ListHuntApprovals",
hunt_pb2.ApiListHuntApprovalsArgs())
def MapHuntApproval(data):
return HuntApproval(data=data, username=context.usern... | def ListHuntApprovals(context=None):
"""List all hunt approvals belonging to requesting user."""
items = context.SendIteratorRequest("ListHuntApprovals",
hunt_pb2.ApiListHuntApprovalsArgs())
def MapHuntApproval(data):
return HuntApproval(data=data, username=context.usern... | [
"List",
"all",
"hunt",
"approvals",
"belonging",
"to",
"requesting",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L350-L358 | [
"def",
"ListHuntApprovals",
"(",
"context",
"=",
"None",
")",
":",
"items",
"=",
"context",
".",
"SendIteratorRequest",
"(",
"\"ListHuntApprovals\"",
",",
"hunt_pb2",
".",
"ApiListHuntApprovalsArgs",
"(",
")",
")",
"def",
"MapHuntApproval",
"(",
"data",
")",
":"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntApprovalBase.Get | Fetch and return a proper HuntApproval object. | api_client/python/grr_api_client/hunt.py | def Get(self):
"""Fetch and return a proper HuntApproval object."""
args = user_pb2.ApiGetHuntApprovalArgs(
hunt_id=self.hunt_id,
approval_id=self.approval_id,
username=self.username)
result = self._context.SendRequest("GetHuntApproval", args)
return HuntApproval(
data=r... | def Get(self):
"""Fetch and return a proper HuntApproval object."""
args = user_pb2.ApiGetHuntApprovalArgs(
hunt_id=self.hunt_id,
approval_id=self.approval_id,
username=self.username)
result = self._context.SendRequest("GetHuntApproval", args)
return HuntApproval(
data=r... | [
"Fetch",
"and",
"return",
"a",
"proper",
"HuntApproval",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L47-L56 | [
"def",
"Get",
"(",
"self",
")",
":",
"args",
"=",
"user_pb2",
".",
"ApiGetHuntApprovalArgs",
"(",
"hunt_id",
"=",
"self",
".",
"hunt_id",
",",
"approval_id",
"=",
"self",
".",
"approval_id",
",",
"username",
"=",
"self",
".",
"username",
")",
"result",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntApprovalBase.WaitUntilValid | Wait until the approval is valid (i.e. - approved).
Args:
timeout: timeout in seconds. None means default timeout (1 hour).
0 means no timeout (wait forever).
Returns:
Operation object with refreshed target_file.
Raises:
PollTimeoutError: if timeout is reached. | api_client/python/grr_api_client/hunt.py | def WaitUntilValid(self, timeout=None):
"""Wait until the approval is valid (i.e. - approved).
Args:
timeout: timeout in seconds. None means default timeout (1 hour).
0 means no timeout (wait forever).
Returns:
Operation object with refreshed target_file.
Raises:
PollTi... | def WaitUntilValid(self, timeout=None):
"""Wait until the approval is valid (i.e. - approved).
Args:
timeout: timeout in seconds. None means default timeout (1 hour).
0 means no timeout (wait forever).
Returns:
Operation object with refreshed target_file.
Raises:
PollTi... | [
"Wait",
"until",
"the",
"approval",
"is",
"valid",
"(",
"i",
".",
"e",
".",
"-",
"approved",
")",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L58-L73 | [
"def",
"WaitUntilValid",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"utils",
".",
"Poll",
"(",
"generator",
"=",
"self",
".",
"Get",
",",
"condition",
"=",
"lambda",
"f",
":",
"f",
".",
"data",
".",
"is_valid",
",",
"timeout",
"=",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntBase.Approval | Returns a reference to an approval. | api_client/python/grr_api_client/hunt.py | def Approval(self, username, approval_id):
"""Returns a reference to an approval."""
return HuntApprovalRef(
hunt_id=self.hunt_id,
username=username,
approval_id=approval_id,
context=self._context) | def Approval(self, username, approval_id):
"""Returns a reference to an approval."""
return HuntApprovalRef(
hunt_id=self.hunt_id,
username=username,
approval_id=approval_id,
context=self._context) | [
"Returns",
"a",
"reference",
"to",
"an",
"approval",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L163-L170 | [
"def",
"Approval",
"(",
"self",
",",
"username",
",",
"approval_id",
")",
":",
"return",
"HuntApprovalRef",
"(",
"hunt_id",
"=",
"self",
".",
"hunt_id",
",",
"username",
"=",
"username",
",",
"approval_id",
"=",
"approval_id",
",",
"context",
"=",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntBase.CreateApproval | Create a new approval for the current user to access this hunt. | api_client/python/grr_api_client/hunt.py | def CreateApproval(self,
reason=None,
notified_users=None,
email_cc_addresses=None):
"""Create a new approval for the current user to access this hunt."""
if not reason:
raise ValueError("reason can't be empty")
if not notified_users:
... | def CreateApproval(self,
reason=None,
notified_users=None,
email_cc_addresses=None):
"""Create a new approval for the current user to access this hunt."""
if not reason:
raise ValueError("reason can't be empty")
if not notified_users:
... | [
"Create",
"a",
"new",
"approval",
"for",
"the",
"current",
"user",
"to",
"access",
"this",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L172-L193 | [
"def",
"CreateApproval",
"(",
"self",
",",
"reason",
"=",
"None",
",",
"notified_users",
"=",
"None",
",",
"email_cc_addresses",
"=",
"None",
")",
":",
"if",
"not",
"reason",
":",
"raise",
"ValueError",
"(",
"\"reason can't be empty\"",
")",
"if",
"not",
"no... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntBase.Modify | Modifies a number of hunt arguments. | api_client/python/grr_api_client/hunt.py | def Modify(self, client_limit=None, client_rate=None, duration=None):
"""Modifies a number of hunt arguments."""
args = hunt_pb2.ApiModifyHuntArgs(hunt_id=self.hunt_id)
if client_limit is not None:
args.client_limit = client_limit
if client_rate is not None:
args.client_rate = client_rate
... | def Modify(self, client_limit=None, client_rate=None, duration=None):
"""Modifies a number of hunt arguments."""
args = hunt_pb2.ApiModifyHuntArgs(hunt_id=self.hunt_id)
if client_limit is not None:
args.client_limit = client_limit
if client_rate is not None:
args.client_rate = client_rate
... | [
"Modifies",
"a",
"number",
"of",
"hunt",
"arguments",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L195-L209 | [
"def",
"Modify",
"(",
"self",
",",
"client_limit",
"=",
"None",
",",
"client_rate",
"=",
"None",
",",
"duration",
"=",
"None",
")",
":",
"args",
"=",
"hunt_pb2",
".",
"ApiModifyHuntArgs",
"(",
"hunt_id",
"=",
"self",
".",
"hunt_id",
")",
"if",
"client_li... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HuntRef.Get | Fetch hunt's data and return proper Hunt object. | api_client/python/grr_api_client/hunt.py | def Get(self):
"""Fetch hunt's data and return proper Hunt object."""
args = hunt_pb2.ApiGetHuntArgs(hunt_id=self.hunt_id)
data = self._context.SendRequest("GetHunt", args)
return Hunt(data=data, context=self._context) | def Get(self):
"""Fetch hunt's data and return proper Hunt object."""
args = hunt_pb2.ApiGetHuntArgs(hunt_id=self.hunt_id)
data = self._context.SendRequest("GetHunt", args)
return Hunt(data=data, context=self._context) | [
"Fetch",
"hunt",
"s",
"data",
"and",
"return",
"proper",
"Hunt",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/hunt.py#L284-L289 | [
"def",
"Get",
"(",
"self",
")",
":",
"args",
"=",
"hunt_pb2",
".",
"ApiGetHuntArgs",
"(",
"hunt_id",
"=",
"self",
".",
"hunt_id",
")",
"data",
"=",
"self",
".",
"_context",
".",
"SendRequest",
"(",
"\"GetHunt\"",
",",
"args",
")",
"return",
"Hunt",
"("... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLConnection._MakeConnection | Repeat connection attempts to server until we get a valid connection. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _MakeConnection(self, database=""):
"""Repeat connection attempts to server until we get a valid connection."""
first_attempt_time = time.time()
wait_time = config.CONFIG["Mysql.max_connect_wait"]
while wait_time == 0 or time.time() - first_attempt_time < wait_time:
try:
connection_arg... | def _MakeConnection(self, database=""):
"""Repeat connection attempts to server until we get a valid connection."""
first_attempt_time = time.time()
wait_time = config.CONFIG["Mysql.max_connect_wait"]
while wait_time == 0 or time.time() - first_attempt_time < wait_time:
try:
connection_arg... | [
"Repeat",
"connection",
"attempts",
"to",
"server",
"until",
"we",
"get",
"a",
"valid",
"connection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L87-L129 | [
"def",
"_MakeConnection",
"(",
"self",
",",
"database",
"=",
"\"\"",
")",
":",
"first_attempt_time",
"=",
"time",
".",
"time",
"(",
")",
"wait_time",
"=",
"config",
".",
"CONFIG",
"[",
"\"Mysql.max_connect_wait\"",
"]",
"while",
"wait_time",
"==",
"0",
"or",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConnectionPool.DropConnection | Attempt to cleanly drop the connection. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def DropConnection(self, connection):
"""Attempt to cleanly drop the connection."""
try:
connection.cursor.close()
except MySQLdb.Error:
pass
try:
connection.dbh.close()
except MySQLdb.Error:
pass | def DropConnection(self, connection):
"""Attempt to cleanly drop the connection."""
try:
connection.cursor.close()
except MySQLdb.Error:
pass
try:
connection.dbh.close()
except MySQLdb.Error:
pass | [
"Attempt",
"to",
"cleanly",
"drop",
"the",
"connection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L161-L171 | [
"def",
"DropConnection",
"(",
"self",
",",
"connection",
")",
":",
"try",
":",
"connection",
".",
"cursor",
".",
"close",
"(",
")",
"except",
"MySQLdb",
".",
"Error",
":",
"pass",
"try",
":",
"connection",
".",
"dbh",
".",
"close",
"(",
")",
"except",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.DropTables | Drop all existing tables. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def DropTables(self):
"""Drop all existing tables."""
rows, _ = self.ExecuteQuery(
"SELECT table_name FROM information_schema.tables "
"WHERE table_schema='%s'" % self.database_name)
for row in rows:
self.ExecuteQuery("DROP TABLE `%s`" % row["table_name"]) | def DropTables(self):
"""Drop all existing tables."""
rows, _ = self.ExecuteQuery(
"SELECT table_name FROM information_schema.tables "
"WHERE table_schema='%s'" % self.database_name)
for row in rows:
self.ExecuteQuery("DROP TABLE `%s`" % row["table_name"]) | [
"Drop",
"all",
"existing",
"tables",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L235-L242 | [
"def",
"DropTables",
"(",
"self",
")",
":",
"rows",
",",
"_",
"=",
"self",
".",
"ExecuteQuery",
"(",
"\"SELECT table_name FROM information_schema.tables \"",
"\"WHERE table_schema='%s'\"",
"%",
"self",
".",
"database_name",
")",
"for",
"row",
"in",
"rows",
":",
"s... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.DeleteAttributes | Remove some attributes from a subject. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def DeleteAttributes(self,
subject,
attributes,
start=None,
end=None,
sync=True):
"""Remove some attributes from a subject."""
_ = sync # Unused
if not attributes:
return
if isinsta... | def DeleteAttributes(self,
subject,
attributes,
start=None,
end=None,
sync=True):
"""Remove some attributes from a subject."""
_ = sync # Unused
if not attributes:
return
if isinsta... | [
"Remove",
"some",
"attributes",
"from",
"a",
"subject",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L264-L283 | [
"def",
"DeleteAttributes",
"(",
"self",
",",
"subject",
",",
"attributes",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"sync",
"=",
"True",
")",
":",
"_",
"=",
"sync",
"# Unused",
"if",
"not",
"attributes",
":",
"return",
"if",
"isinstance... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.ResolveMulti | Resolves multiple attributes at once for one subject. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def ResolveMulti(self, subject, attributes, timestamp=None, limit=None):
"""Resolves multiple attributes at once for one subject."""
for attribute in attributes:
query, args = self._BuildQuery(subject, attribute, timestamp, limit)
result, _ = self.ExecuteQuery(query, args)
for row in result:
... | def ResolveMulti(self, subject, attributes, timestamp=None, limit=None):
"""Resolves multiple attributes at once for one subject."""
for attribute in attributes:
query, args = self._BuildQuery(subject, attribute, timestamp, limit)
result, _ = self.ExecuteQuery(query, args)
for row in result:
... | [
"Resolves",
"multiple",
"attributes",
"at",
"once",
"for",
"one",
"subject",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L290-L305 | [
"def",
"ResolveMulti",
"(",
"self",
",",
"subject",
",",
"attributes",
",",
"timestamp",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"for",
"attribute",
"in",
"attributes",
":",
"query",
",",
"args",
"=",
"self",
".",
"_BuildQuery",
"(",
"subject",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.MultiResolvePrefix | Result multiple subjects using one or more attribute regexps. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def MultiResolvePrefix(self,
subjects,
attribute_prefix,
timestamp=None,
limit=None):
"""Result multiple subjects using one or more attribute regexps."""
result = {}
for subject in subjects:
values = s... | def MultiResolvePrefix(self,
subjects,
attribute_prefix,
timestamp=None,
limit=None):
"""Result multiple subjects using one or more attribute regexps."""
result = {}
for subject in subjects:
values = s... | [
"Result",
"multiple",
"subjects",
"using",
"one",
"or",
"more",
"attribute",
"regexps",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L307-L327 | [
"def",
"MultiResolvePrefix",
"(",
"self",
",",
"subjects",
",",
"attribute_prefix",
",",
"timestamp",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"result",
"=",
"{",
"}",
"for",
"subject",
"in",
"subjects",
":",
"values",
"=",
"self",
".",
"Resolve... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.ResolvePrefix | ResolvePrefix. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def ResolvePrefix(self, subject, attribute_prefix, timestamp=None,
limit=None):
"""ResolvePrefix."""
if isinstance(attribute_prefix, string_types):
attribute_prefix = [attribute_prefix]
results = []
for prefix in attribute_prefix:
query, args = self._BuildQuery(
... | def ResolvePrefix(self, subject, attribute_prefix, timestamp=None,
limit=None):
"""ResolvePrefix."""
if isinstance(attribute_prefix, string_types):
attribute_prefix = [attribute_prefix]
results = []
for prefix in attribute_prefix:
query, args = self._BuildQuery(
... | [
"ResolvePrefix",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L329-L346 | [
"def",
"ResolvePrefix",
"(",
"self",
",",
"subject",
",",
"attribute_prefix",
",",
"timestamp",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"attribute_prefix",
",",
"string_types",
")",
":",
"attribute_prefix",
"=",
"[",
"attri... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.MultiSet | Set multiple attributes' values for this subject in one operation. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def MultiSet(self,
subject,
values,
timestamp=None,
replace=True,
sync=True,
to_delete=None):
"""Set multiple attributes' values for this subject in one operation."""
to_delete = set(to_delete or [])
# Prepare a bulk ... | def MultiSet(self,
subject,
values,
timestamp=None,
replace=True,
sync=True,
to_delete=None):
"""Set multiple attributes' values for this subject in one operation."""
to_delete = set(to_delete or [])
# Prepare a bulk ... | [
"Set",
"multiple",
"attributes",
"values",
"for",
"this",
"subject",
"in",
"one",
"operation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L419-L483 | [
"def",
"MultiSet",
"(",
"self",
",",
"subject",
",",
"values",
",",
"timestamp",
"=",
"None",
",",
"replace",
"=",
"True",
",",
"sync",
"=",
"True",
",",
"to_delete",
"=",
"None",
")",
":",
"to_delete",
"=",
"set",
"(",
"to_delete",
"or",
"[",
"]",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore.ExecuteQuery | Get connection from pool and execute query. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def ExecuteQuery(self, query, args=None):
"""Get connection from pool and execute query."""
def Action(connection):
connection.cursor.execute(query, args)
rowcount = connection.cursor.rowcount
results = connection.cursor.fetchall()
return results, rowcount
return self._RetryWrapper... | def ExecuteQuery(self, query, args=None):
"""Get connection from pool and execute query."""
def Action(connection):
connection.cursor.execute(query, args)
rowcount = connection.cursor.rowcount
results = connection.cursor.fetchall()
return results, rowcount
return self._RetryWrapper... | [
"Get",
"connection",
"from",
"pool",
"and",
"execute",
"query",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L637-L646 | [
"def",
"ExecuteQuery",
"(",
"self",
",",
"query",
",",
"args",
"=",
"None",
")",
":",
"def",
"Action",
"(",
"connection",
")",
":",
"connection",
".",
"cursor",
".",
"execute",
"(",
"query",
",",
"args",
")",
"rowcount",
"=",
"connection",
".",
"cursor... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._ExecuteTransaction | Get connection from pool and execute transaction. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _ExecuteTransaction(self, transaction):
"""Get connection from pool and execute transaction."""
def Action(connection):
connection.cursor.execute("START TRANSACTION")
for query in transaction:
connection.cursor.execute(query["query"], query["args"])
connection.cursor.execute("COMM... | def _ExecuteTransaction(self, transaction):
"""Get connection from pool and execute transaction."""
def Action(connection):
connection.cursor.execute("START TRANSACTION")
for query in transaction:
connection.cursor.execute(query["query"], query["args"])
connection.cursor.execute("COMM... | [
"Get",
"connection",
"from",
"pool",
"and",
"execute",
"transaction",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L653-L663 | [
"def",
"_ExecuteTransaction",
"(",
"self",
",",
"transaction",
")",
":",
"def",
"Action",
"(",
"connection",
")",
":",
"connection",
".",
"cursor",
".",
"execute",
"(",
"\"START TRANSACTION\"",
")",
"for",
"query",
"in",
"transaction",
":",
"connection",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._CalculateAttributeStorageTypes | Build a mapping between column names and types. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _CalculateAttributeStorageTypes(self):
"""Build a mapping between column names and types."""
self.attribute_types = {}
for attribute in itervalues(aff4.Attribute.PREDICATES):
self.attribute_types[attribute.predicate] = (
attribute.attribute_type.data_store_type) | def _CalculateAttributeStorageTypes(self):
"""Build a mapping between column names and types."""
self.attribute_types = {}
for attribute in itervalues(aff4.Attribute.PREDICATES):
self.attribute_types[attribute.predicate] = (
attribute.attribute_type.data_store_type) | [
"Build",
"a",
"mapping",
"between",
"column",
"names",
"and",
"types",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L665-L671 | [
"def",
"_CalculateAttributeStorageTypes",
"(",
"self",
")",
":",
"self",
".",
"attribute_types",
"=",
"{",
"}",
"for",
"attribute",
"in",
"itervalues",
"(",
"aff4",
".",
"Attribute",
".",
"PREDICATES",
")",
":",
"self",
".",
"attribute_types",
"[",
"attribute"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._Encode | Encode the value for the attribute. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _Encode(self, value):
"""Encode the value for the attribute."""
try:
return value.SerializeToString().encode("hex")
except AttributeError:
if isinstance(value, (int, long)):
return str(value).encode("hex")
else:
# Types "string" and "bytes" are stored as strings here.
... | def _Encode(self, value):
"""Encode the value for the attribute."""
try:
return value.SerializeToString().encode("hex")
except AttributeError:
if isinstance(value, (int, long)):
return str(value).encode("hex")
else:
# Types "string" and "bytes" are stored as strings here.
... | [
"Encode",
"the",
"value",
"for",
"the",
"attribute",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L673-L682 | [
"def",
"_Encode",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"return",
"value",
".",
"SerializeToString",
"(",
")",
".",
"encode",
"(",
"\"hex\"",
")",
"except",
"AttributeError",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"long... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._BuildQuery | Build the SELECT query to be executed. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _BuildQuery(self,
subject,
attribute=None,
timestamp=None,
limit=None,
is_prefix=False):
"""Build the SELECT query to be executed."""
args = []
subject = utils.SmartUnicode(subject)
criteria = "WHERE aff4.subje... | def _BuildQuery(self,
subject,
attribute=None,
timestamp=None,
limit=None,
is_prefix=False):
"""Build the SELECT query to be executed."""
args = []
subject = utils.SmartUnicode(subject)
criteria = "WHERE aff4.subje... | [
"Build",
"the",
"SELECT",
"query",
"to",
"be",
"executed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L695-L747 | [
"def",
"_BuildQuery",
"(",
"self",
",",
"subject",
",",
"attribute",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"is_prefix",
"=",
"False",
")",
":",
"args",
"=",
"[",
"]",
"subject",
"=",
"utils",
".",
"SmartUnicode",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._BuildDelete | Build the DELETE query to be executed. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _BuildDelete(self, subject, attribute=None, timestamp=None):
"""Build the DELETE query to be executed."""
subjects_q = {
"query": "DELETE subjects FROM subjects WHERE hash=unhex(md5(%s))",
"args": [subject]
}
aff4_q = {
"query": "DELETE aff4 FROM aff4 WHERE subject_hash=unhe... | def _BuildDelete(self, subject, attribute=None, timestamp=None):
"""Build the DELETE query to be executed."""
subjects_q = {
"query": "DELETE subjects FROM subjects WHERE hash=unhex(md5(%s))",
"args": [subject]
}
aff4_q = {
"query": "DELETE aff4 FROM aff4 WHERE subject_hash=unhe... | [
"Build",
"the",
"DELETE",
"query",
"to",
"be",
"executed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L749-L788 | [
"def",
"_BuildDelete",
"(",
"self",
",",
"subject",
",",
"attribute",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"subjects_q",
"=",
"{",
"\"query\"",
":",
"\"DELETE subjects FROM subjects WHERE hash=unhex(md5(%s))\"",
",",
"\"args\"",
":",
"[",
"subject... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLAdvancedDataStore._MakeTimestamp | Create a timestamp using a start and end time.
Args:
start: Start timestamp.
end: End timestamp.
Returns:
A tuple (start, end) of converted timestamps or None for all time. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def _MakeTimestamp(self, start=None, end=None):
"""Create a timestamp using a start and end time.
Args:
start: Start timestamp.
end: End timestamp.
Returns:
A tuple (start, end) of converted timestamps or None for all time.
"""
mysql_unsigned_bigint_max = 18446744073709551615
... | def _MakeTimestamp(self, start=None, end=None):
"""Create a timestamp using a start and end time.
Args:
start: Start timestamp.
end: End timestamp.
Returns:
A tuple (start, end) of converted timestamps or None for all time.
"""
mysql_unsigned_bigint_max = 18446744073709551615
... | [
"Create",
"a",
"timestamp",
"using",
"a",
"start",
"and",
"end",
"time",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L790-L809 | [
"def",
"_MakeTimestamp",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"mysql_unsigned_bigint_max",
"=",
"18446744073709551615",
"ts_start",
"=",
"int",
"(",
"start",
"or",
"0",
")",
"if",
"end",
"is",
"None",
":",
"ts_end",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLDBSubjectLock.Release | Remove the lock.
Note that this only resets the lock if we actually hold it since
lock_expiration == self.expires and lock_owner = self.lock_token. | grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py | def Release(self):
"""Remove the lock.
Note that this only resets the lock if we actually hold it since
lock_expiration == self.expires and lock_owner = self.lock_token.
"""
if self.locked:
query = ("UPDATE locks SET lock_expiration=0, lock_owner=0 "
"WHERE lock_expiration=%s "... | def Release(self):
"""Remove the lock.
Note that this only resets the lock if we actually hold it since
lock_expiration == self.expires and lock_owner = self.lock_token.
"""
if self.locked:
query = ("UPDATE locks SET lock_expiration=0, lock_owner=0 "
"WHERE lock_expiration=%s "... | [
"Remove",
"the",
"lock",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/mysql_advanced_data_store.py#L896-L909 | [
"def",
"Release",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
":",
"query",
"=",
"(",
"\"UPDATE locks SET lock_expiration=0, lock_owner=0 \"",
"\"WHERE lock_expiration=%s \"",
"\"AND lock_owner=%s \"",
"\"AND subject_hash=unhex(md5(%s))\"",
")",
"args",
"=",
"[",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4KeywordIndex.Lookup | Finds objects associated with keywords.
Find the names related to all keywords.
Args:
keywords: A collection of keywords that we are interested in.
start_time: Only considers keywords added at or after this point in time.
end_time: Only considers keywords at or before this point in time.
... | grr/server/grr_response_server/keyword_index.py | def Lookup(self,
keywords,
start_time=FIRST_TIMESTAMP,
end_time=LAST_TIMESTAMP,
last_seen_map=None):
"""Finds objects associated with keywords.
Find the names related to all keywords.
Args:
keywords: A collection of keywords that we are interested ... | def Lookup(self,
keywords,
start_time=FIRST_TIMESTAMP,
end_time=LAST_TIMESTAMP,
last_seen_map=None):
"""Finds objects associated with keywords.
Find the names related to all keywords.
Args:
keywords: A collection of keywords that we are interested ... | [
"Finds",
"objects",
"associated",
"with",
"keywords",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/keyword_index.py#L27-L61 | [
"def",
"Lookup",
"(",
"self",
",",
"keywords",
",",
"start_time",
"=",
"FIRST_TIMESTAMP",
",",
"end_time",
"=",
"LAST_TIMESTAMP",
",",
"last_seen_map",
"=",
"None",
")",
":",
"posting_lists",
"=",
"self",
".",
"ReadPostingLists",
"(",
"keywords",
",",
"start_t... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4KeywordIndex.ReadPostingLists | Finds all objects associated with any of the keywords.
Args:
keywords: A collection of keywords that we are interested in.
start_time: Only considers keywords added at or after this point in time.
end_time: Only considers keywords at or before this point in time.
last_seen_map: If present, ... | grr/server/grr_response_server/keyword_index.py | def ReadPostingLists(self,
keywords,
start_time=FIRST_TIMESTAMP,
end_time=LAST_TIMESTAMP,
last_seen_map=None):
"""Finds all objects associated with any of the keywords.
Args:
keywords: A collection of keywords tha... | def ReadPostingLists(self,
keywords,
start_time=FIRST_TIMESTAMP,
end_time=LAST_TIMESTAMP,
last_seen_map=None):
"""Finds all objects associated with any of the keywords.
Args:
keywords: A collection of keywords tha... | [
"Finds",
"all",
"objects",
"associated",
"with",
"any",
"of",
"the",
"keywords",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/keyword_index.py#L63-L81 | [
"def",
"ReadPostingLists",
"(",
"self",
",",
"keywords",
",",
"start_time",
"=",
"FIRST_TIMESTAMP",
",",
"end_time",
"=",
"LAST_TIMESTAMP",
",",
"last_seen_map",
"=",
"None",
")",
":",
"return",
"data_store",
".",
"DB",
".",
"IndexReadPostingLists",
"(",
"self",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4KeywordIndex.AddKeywordsForName | Associates keywords with name.
Records that keywords are associated with name.
Args:
name: A name which should be associated with some keywords.
keywords: A collection of keywords to associate with name. | grr/server/grr_response_server/keyword_index.py | def AddKeywordsForName(self, name, keywords):
"""Associates keywords with name.
Records that keywords are associated with name.
Args:
name: A name which should be associated with some keywords.
keywords: A collection of keywords to associate with name.
"""
data_store.DB.IndexAddKeyword... | def AddKeywordsForName(self, name, keywords):
"""Associates keywords with name.
Records that keywords are associated with name.
Args:
name: A name which should be associated with some keywords.
keywords: A collection of keywords to associate with name.
"""
data_store.DB.IndexAddKeyword... | [
"Associates",
"keywords",
"with",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/keyword_index.py#L83-L92 | [
"def",
"AddKeywordsForName",
"(",
"self",
",",
"name",
",",
"keywords",
")",
":",
"data_store",
".",
"DB",
".",
"IndexAddKeywordsForName",
"(",
"self",
".",
"urn",
",",
"name",
",",
"keywords",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4KeywordIndex.RemoveKeywordsForName | Removes keywords for a name.
Args:
name: A name which should not be associated with some keywords anymore.
keywords: A collection of keywords. | grr/server/grr_response_server/keyword_index.py | def RemoveKeywordsForName(self, name, keywords):
"""Removes keywords for a name.
Args:
name: A name which should not be associated with some keywords anymore.
keywords: A collection of keywords.
"""
data_store.DB.IndexRemoveKeywordsForName(self.urn, name, keywords) | def RemoveKeywordsForName(self, name, keywords):
"""Removes keywords for a name.
Args:
name: A name which should not be associated with some keywords anymore.
keywords: A collection of keywords.
"""
data_store.DB.IndexRemoveKeywordsForName(self.urn, name, keywords) | [
"Removes",
"keywords",
"for",
"a",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/keyword_index.py#L94-L101 | [
"def",
"RemoveKeywordsForName",
"(",
"self",
",",
"name",
",",
"keywords",
")",
":",
"data_store",
".",
"DB",
".",
"IndexRemoveKeywordsForName",
"(",
"self",
".",
"urn",
",",
"name",
",",
"keywords",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ImportConfig | Reads an old config file and imports keys and user accounts. | grr/server/grr_response_server/bin/config_updater_util.py | def ImportConfig(filename, config):
"""Reads an old config file and imports keys and user accounts."""
sections_to_import = ["PrivateKeys"]
entries_to_import = [
"Client.executable_signing_public_key", "CA.certificate",
"Frontend.certificate"
]
options_imported = 0
old_config = grr_config.CONFIG... | def ImportConfig(filename, config):
"""Reads an old config file and imports keys and user accounts."""
sections_to_import = ["PrivateKeys"]
entries_to_import = [
"Client.executable_signing_public_key", "CA.certificate",
"Frontend.certificate"
]
options_imported = 0
old_config = grr_config.CONFIG... | [
"Reads",
"an",
"old",
"config",
"file",
"and",
"imports",
"keys",
"and",
"user",
"accounts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L87-L108 | [
"def",
"ImportConfig",
"(",
"filename",
",",
"config",
")",
":",
"sections_to_import",
"=",
"[",
"\"PrivateKeys\"",
"]",
"entries_to_import",
"=",
"[",
"\"Client.executable_signing_public_key\"",
",",
"\"CA.certificate\"",
",",
"\"Frontend.certificate\"",
"]",
"options_im... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | RetryQuestion | Continually ask a question until the output_re is matched. | grr/server/grr_response_server/bin/config_updater_util.py | def RetryQuestion(question_text, output_re="", default_val=None):
"""Continually ask a question until the output_re is matched."""
while True:
if default_val is not None:
new_text = "%s [%s]: " % (question_text, default_val)
else:
new_text = "%s: " % question_text
# pytype: disable=wrong-arg... | def RetryQuestion(question_text, output_re="", default_val=None):
"""Continually ask a question until the output_re is matched."""
while True:
if default_val is not None:
new_text = "%s [%s]: " % (question_text, default_val)
else:
new_text = "%s: " % question_text
# pytype: disable=wrong-arg... | [
"Continually",
"ask",
"a",
"question",
"until",
"the",
"output_re",
"is",
"matched",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L111-L126 | [
"def",
"RetryQuestion",
"(",
"question_text",
",",
"output_re",
"=",
"\"\"",
",",
"default_val",
"=",
"None",
")",
":",
"while",
"True",
":",
"if",
"default_val",
"is",
"not",
"None",
":",
"new_text",
"=",
"\"%s [%s]: \"",
"%",
"(",
"question_text",
",",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConfigureHostnames | This configures the hostnames stored in the config. | grr/server/grr_response_server/bin/config_updater_util.py | def ConfigureHostnames(config, external_hostname = None):
"""This configures the hostnames stored in the config."""
if not external_hostname:
try:
external_hostname = socket.gethostname()
except (OSError, IOError):
print("Sorry, we couldn't guess your hostname.\n")
external_hostname = Retry... | def ConfigureHostnames(config, external_hostname = None):
"""This configures the hostnames stored in the config."""
if not external_hostname:
try:
external_hostname = socket.gethostname()
except (OSError, IOError):
print("Sorry, we couldn't guess your hostname.\n")
external_hostname = Retry... | [
"This",
"configures",
"the",
"hostnames",
"stored",
"in",
"the",
"config",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L139-L172 | [
"def",
"ConfigureHostnames",
"(",
"config",
",",
"external_hostname",
"=",
"None",
")",
":",
"if",
"not",
"external_hostname",
":",
"try",
":",
"external_hostname",
"=",
"socket",
".",
"gethostname",
"(",
")",
"except",
"(",
"OSError",
",",
"IOError",
")",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckMySQLConnection | Checks whether a connection can be established to MySQL.
Args:
db_options: A dict mapping GRR MySQL config options to their values.
Returns:
A boolean indicating whether a connection could be made to a MySQL server
instance with the given options. | grr/server/grr_response_server/bin/config_updater_util.py | def CheckMySQLConnection(db_options):
"""Checks whether a connection can be established to MySQL.
Args:
db_options: A dict mapping GRR MySQL config options to their values.
Returns:
A boolean indicating whether a connection could be made to a MySQL server
instance with the given options.
"""
for... | def CheckMySQLConnection(db_options):
"""Checks whether a connection can be established to MySQL.
Args:
db_options: A dict mapping GRR MySQL config options to their values.
Returns:
A boolean indicating whether a connection could be made to a MySQL server
instance with the given options.
"""
for... | [
"Checks",
"whether",
"a",
"connection",
"can",
"be",
"established",
"to",
"MySQL",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L175-L249 | [
"def",
"CheckMySQLConnection",
"(",
"db_options",
")",
":",
"for",
"tries_left",
"in",
"range",
"(",
"_MYSQL_MAX_RETRIES",
",",
"-",
"1",
",",
"-",
"1",
")",
":",
"try",
":",
"connection_options",
"=",
"dict",
"(",
"host",
"=",
"db_options",
"[",
"\"Mysql.... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConfigureMySQLDatastore | Prompts the user for configuration details for a MySQL datastore. | grr/server/grr_response_server/bin/config_updater_util.py | def ConfigureMySQLDatastore(config):
"""Prompts the user for configuration details for a MySQL datastore."""
print("GRR will use MySQL as its database backend. Enter connection details:")
datastore_init_complete = False
db_options = {}
while not datastore_init_complete:
db_options["Datastore.implementatio... | def ConfigureMySQLDatastore(config):
"""Prompts the user for configuration details for a MySQL datastore."""
print("GRR will use MySQL as its database backend. Enter connection details:")
datastore_init_complete = False
db_options = {}
while not datastore_init_complete:
db_options["Datastore.implementatio... | [
"Prompts",
"the",
"user",
"for",
"configuration",
"details",
"for",
"a",
"MySQL",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L252-L301 | [
"def",
"ConfigureMySQLDatastore",
"(",
"config",
")",
":",
"print",
"(",
"\"GRR will use MySQL as its database backend. Enter connection details:\"",
")",
"datastore_init_complete",
"=",
"False",
"db_options",
"=",
"{",
"}",
"while",
"not",
"datastore_init_complete",
":",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConfigureDatastore | Guides the user through configuration of the datastore. | grr/server/grr_response_server/bin/config_updater_util.py | def ConfigureDatastore(config):
"""Guides the user through configuration of the datastore."""
print("\n\n-=GRR Datastore=-\n"
"For GRR to work each GRR server has to be able to communicate with\n"
"the datastore. To do this we need to configure a datastore.\n")
existing_datastore = grr_config.CON... | def ConfigureDatastore(config):
"""Guides the user through configuration of the datastore."""
print("\n\n-=GRR Datastore=-\n"
"For GRR to work each GRR server has to be able to communicate with\n"
"the datastore. To do this we need to configure a datastore.\n")
existing_datastore = grr_config.CON... | [
"Guides",
"the",
"user",
"through",
"configuration",
"of",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L304-L344 | [
"def",
"ConfigureDatastore",
"(",
"config",
")",
":",
"print",
"(",
"\"\\n\\n-=GRR Datastore=-\\n\"",
"\"For GRR to work each GRR server has to be able to communicate with\\n\"",
"\"the datastore. To do this we need to configure a datastore.\\n\"",
")",
"existing_datastore",
"=",
"grr_co... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConfigureUrls | Guides the user through configuration of various URLs used by GRR. | grr/server/grr_response_server/bin/config_updater_util.py | def ConfigureUrls(config, external_hostname = None):
"""Guides the user through configuration of various URLs used by GRR."""
print("\n\n-=GRR URLs=-\n"
"For GRR to work each client has to be able to communicate with the\n"
"server. To do this we normally need a public dns name or IP address\n"
... | def ConfigureUrls(config, external_hostname = None):
"""Guides the user through configuration of various URLs used by GRR."""
print("\n\n-=GRR URLs=-\n"
"For GRR to work each client has to be able to communicate with the\n"
"server. To do this we normally need a public dns name or IP address\n"
... | [
"Guides",
"the",
"user",
"through",
"configuration",
"of",
"various",
"URLs",
"used",
"by",
"GRR",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L347-L380 | [
"def",
"ConfigureUrls",
"(",
"config",
",",
"external_hostname",
"=",
"None",
")",
":",
"print",
"(",
"\"\\n\\n-=GRR URLs=-\\n\"",
"\"For GRR to work each client has to be able to communicate with the\\n\"",
"\"server. To do this we normally need a public dns name or IP address\\n\"",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConfigureEmails | Guides the user through email setup. | grr/server/grr_response_server/bin/config_updater_util.py | def ConfigureEmails(config):
"""Guides the user through email setup."""
print("\n\n-=GRR Emails=-\n"
"GRR needs to be able to send emails for various logging and\n"
"alerting functions. The email domain will be appended to GRR\n"
"usernames when sending emails to users.\n")
existing_log_d... | def ConfigureEmails(config):
"""Guides the user through email setup."""
print("\n\n-=GRR Emails=-\n"
"GRR needs to be able to send emails for various logging and\n"
"alerting functions. The email domain will be appended to GRR\n"
"usernames when sending emails to users.\n")
existing_log_d... | [
"Guides",
"the",
"user",
"through",
"email",
"setup",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L383-L421 | [
"def",
"ConfigureEmails",
"(",
"config",
")",
":",
"print",
"(",
"\"\\n\\n-=GRR Emails=-\\n\"",
"\"GRR needs to be able to send emails for various logging and\\n\"",
"\"alerting functions. The email domain will be appended to GRR\\n\"",
"\"usernames when sending emails to users.\\n\"",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InstallTemplatePackage | Call pip to install the templates. | grr/server/grr_response_server/bin/config_updater_util.py | def InstallTemplatePackage():
"""Call pip to install the templates."""
virtualenv_bin = os.path.dirname(sys.executable)
extension = os.path.splitext(sys.executable)[1]
pip = "%s/pip%s" % (virtualenv_bin, extension)
# Install the GRR server component to satisfy the dependency below.
major_minor_version = ".... | def InstallTemplatePackage():
"""Call pip to install the templates."""
virtualenv_bin = os.path.dirname(sys.executable)
extension = os.path.splitext(sys.executable)[1]
pip = "%s/pip%s" % (virtualenv_bin, extension)
# Install the GRR server component to satisfy the dependency below.
major_minor_version = ".... | [
"Call",
"pip",
"to",
"install",
"the",
"templates",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L424-L439 | [
"def",
"InstallTemplatePackage",
"(",
")",
":",
"virtualenv_bin",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"sys",
".",
"executable",
")",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"sys",
".",
"executable",
")",
"[",
"1",
"]",
"pip"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FinalizeConfigInit | Performs the final steps of config initialization. | grr/server/grr_response_server/bin/config_updater_util.py | def FinalizeConfigInit(config,
token,
admin_password = None,
redownload_templates = False,
repack_templates = True,
prompt = True):
"""Performs the final steps of config initialization."""
config.Set("... | def FinalizeConfigInit(config,
token,
admin_password = None,
redownload_templates = False,
repack_templates = True,
prompt = True):
"""Performs the final steps of config initialization."""
config.Set("... | [
"Performs",
"the",
"final",
"steps",
"of",
"config",
"initialization",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L442-L482 | [
"def",
"FinalizeConfigInit",
"(",
"config",
",",
"token",
",",
"admin_password",
"=",
"None",
",",
"redownload_templates",
"=",
"False",
",",
"repack_templates",
"=",
"True",
",",
"prompt",
"=",
"True",
")",
":",
"config",
".",
"Set",
"(",
"\"Server.initialize... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Initialize | Initialize or update a GRR configuration. | grr/server/grr_response_server/bin/config_updater_util.py | def Initialize(config=None,
external_hostname = None,
admin_password = None,
redownload_templates = False,
repack_templates = True,
token = None):
"""Initialize or update a GRR configuration."""
print("Checking write access on config %s" % ... | def Initialize(config=None,
external_hostname = None,
admin_password = None,
redownload_templates = False,
repack_templates = True,
token = None):
"""Initialize or update a GRR configuration."""
print("Checking write access on config %s" % ... | [
"Initialize",
"or",
"update",
"a",
"GRR",
"configuration",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L485-L535 | [
"def",
"Initialize",
"(",
"config",
"=",
"None",
",",
"external_hostname",
"=",
"None",
",",
"admin_password",
"=",
"None",
",",
"redownload_templates",
"=",
"False",
",",
"repack_templates",
"=",
"True",
",",
"token",
"=",
"None",
")",
":",
"print",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.