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 | Triggers.Match | Test if host data should trigger a check.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that match. | grr/server/grr_response_server/check_lib/triggers.py | def Match(self, artifact=None, os_name=None, cpe=None, label=None):
"""Test if host data should trigger a check.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that match.
"""
return [
... | def Match(self, artifact=None, os_name=None, cpe=None, label=None):
"""Test if host data should trigger a check.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that match.
"""
return [
... | [
"Test",
"if",
"host",
"data",
"should",
"trigger",
"a",
"check",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L174-L188 | [
"def",
"Match",
"(",
"self",
",",
"artifact",
"=",
"None",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"return",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"conditions",
"if",
"c",
".",
"Match",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Triggers.Search | Find the host attributes that trigger data collection.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that contain the specified attributes. | grr/server/grr_response_server/check_lib/triggers.py | def Search(self, artifact=None, os_name=None, cpe=None, label=None):
"""Find the host attributes that trigger data collection.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that contain the spe... | def Search(self, artifact=None, os_name=None, cpe=None, label=None):
"""Find the host attributes that trigger data collection.
Args:
artifact: An artifact name.
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of conditions that contain the spe... | [
"Find",
"the",
"host",
"attributes",
"that",
"trigger",
"data",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L190-L204 | [
"def",
"Search",
"(",
"self",
",",
"artifact",
"=",
"None",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"return",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"conditions",
"if",
"c",
".",
"Search",
"(",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Triggers.Artifacts | Find the artifacts that correspond with other trigger conditions.
Args:
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of artifacts to be processed. | grr/server/grr_response_server/check_lib/triggers.py | def Artifacts(self, os_name=None, cpe=None, label=None):
"""Find the artifacts that correspond with other trigger conditions.
Args:
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of artifacts to be processed.
"""
return [
c.artifact... | def Artifacts(self, os_name=None, cpe=None, label=None):
"""Find the artifacts that correspond with other trigger conditions.
Args:
os_name: An OS string.
cpe: A CPE string.
label: A label string.
Returns:
A list of artifacts to be processed.
"""
return [
c.artifact... | [
"Find",
"the",
"artifacts",
"that",
"correspond",
"with",
"other",
"trigger",
"conditions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L206-L219 | [
"def",
"Artifacts",
"(",
"self",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"return",
"[",
"c",
".",
"artifact",
"for",
"c",
"in",
"self",
".",
"conditions",
"if",
"c",
".",
"Artifacts",
"(",
"os_name... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Triggers.Calls | Find the methods that evaluate data that meets this condition.
Args:
conditions: A tuple of (artifact, os_name, cpe, label)
Returns:
A list of methods that evaluate the data. | grr/server/grr_response_server/check_lib/triggers.py | def Calls(self, conditions=None):
"""Find the methods that evaluate data that meets this condition.
Args:
conditions: A tuple of (artifact, os_name, cpe, label)
Returns:
A list of methods that evaluate the data.
"""
results = set()
if conditions is None:
conditions = [None]
... | def Calls(self, conditions=None):
"""Find the methods that evaluate data that meets this condition.
Args:
conditions: A tuple of (artifact, os_name, cpe, label)
Returns:
A list of methods that evaluate the data.
"""
results = set()
if conditions is None:
conditions = [None]
... | [
"Find",
"the",
"methods",
"that",
"evaluate",
"data",
"that",
"meets",
"this",
"condition",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/triggers.py#L221-L236 | [
"def",
"Calls",
"(",
"self",
",",
"conditions",
"=",
"None",
")",
":",
"results",
"=",
"set",
"(",
")",
"if",
"conditions",
"is",
"None",
":",
"conditions",
"=",
"[",
"None",
"]",
"for",
"condition",
"in",
"conditions",
":",
"for",
"c",
"in",
"self",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ReportPluginBase.GetReportDescriptor | Returns plugins' metadata in ApiReportDescriptor. | grr/server/grr_response_server/gui/api_plugins/report_plugins/report_plugin_base.py | def GetReportDescriptor(cls):
"""Returns plugins' metadata in ApiReportDescriptor."""
if cls.TYPE is None:
raise ValueError("%s.TYPE is unintialized." % cls)
if cls.TITLE is None:
raise ValueError("%s.TITLE is unintialized." % cls)
if cls.SUMMARY is None:
raise ValueError("%s.SUMMARY... | def GetReportDescriptor(cls):
"""Returns plugins' metadata in ApiReportDescriptor."""
if cls.TYPE is None:
raise ValueError("%s.TYPE is unintialized." % cls)
if cls.TITLE is None:
raise ValueError("%s.TITLE is unintialized." % cls)
if cls.SUMMARY is None:
raise ValueError("%s.SUMMARY... | [
"Returns",
"plugins",
"metadata",
"in",
"ApiReportDescriptor",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/report_plugin_base.py#L31-L47 | [
"def",
"GetReportDescriptor",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"TYPE",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"%s.TYPE is unintialized.\"",
"%",
"cls",
")",
"if",
"cls",
".",
"TITLE",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"%s.TI... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MakeCASignedCert | Make a cert and sign it with the CA's private key. | grr/server/grr_response_server/key_utils.py | def MakeCASignedCert(common_name,
private_key,
ca_cert,
ca_private_key,
serial_number=2):
"""Make a cert and sign it with the CA's private key."""
public_key = private_key.GetPublicKey()
builder = x509.CertificateBuilder()
bui... | def MakeCASignedCert(common_name,
private_key,
ca_cert,
ca_private_key,
serial_number=2):
"""Make a cert and sign it with the CA's private key."""
public_key = private_key.GetPublicKey()
builder = x509.CertificateBuilder()
bui... | [
"Make",
"a",
"cert",
"and",
"sign",
"it",
"with",
"the",
"CA",
"s",
"private",
"key",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/key_utils.py#L16-L46 | [
"def",
"MakeCASignedCert",
"(",
"common_name",
",",
"private_key",
",",
"ca_cert",
",",
"ca_private_key",
",",
"serial_number",
"=",
"2",
")",
":",
"public_key",
"=",
"private_key",
".",
"GetPublicKey",
"(",
")",
"builder",
"=",
"x509",
".",
"CertificateBuilder"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MakeCACert | Generate a CA certificate.
Args:
private_key: The private key to use.
common_name: Name for cert.
issuer_cn: Name for issuer.
issuer_c: Country for issuer.
Returns:
The certificate. | grr/server/grr_response_server/key_utils.py | def MakeCACert(private_key,
common_name=u"grr",
issuer_cn=u"grr_test",
issuer_c=u"US"):
"""Generate a CA certificate.
Args:
private_key: The private key to use.
common_name: Name for cert.
issuer_cn: Name for issuer.
issuer_c: Country for issuer.
Retu... | def MakeCACert(private_key,
common_name=u"grr",
issuer_cn=u"grr_test",
issuer_c=u"US"):
"""Generate a CA certificate.
Args:
private_key: The private key to use.
common_name: Name for cert.
issuer_cn: Name for issuer.
issuer_c: Country for issuer.
Retu... | [
"Generate",
"a",
"CA",
"certificate",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/key_utils.py#L49-L94 | [
"def",
"MakeCACert",
"(",
"private_key",
",",
"common_name",
"=",
"u\"grr\"",
",",
"issuer_cn",
"=",
"u\"grr_test\"",
",",
"issuer_c",
"=",
"u\"US\"",
")",
":",
"public_key",
"=",
"private_key",
".",
"GetPublicKey",
"(",
")",
"builder",
"=",
"x509",
".",
"Ce... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _LoadAuditEvents | Returns AuditEvents for given handlers, actions, and timerange. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def _LoadAuditEvents(handlers,
get_report_args,
actions=None,
token=None,
transformers=None):
"""Returns AuditEvents for given handlers, actions, and timerange."""
if transformers is None:
transformers = {}
if data_store.Rela... | def _LoadAuditEvents(handlers,
get_report_args,
actions=None,
token=None,
transformers=None):
"""Returns AuditEvents for given handlers, actions, and timerange."""
if transformers is None:
transformers = {}
if data_store.Rela... | [
"Returns",
"AuditEvents",
"for",
"given",
"handlers",
"actions",
"and",
"timerange",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L27-L51 | [
"def",
"_LoadAuditEvents",
"(",
"handlers",
",",
"get_report_args",
",",
"actions",
"=",
"None",
",",
"token",
"=",
"None",
",",
"transformers",
"=",
"None",
")",
":",
"if",
"transformers",
"is",
"None",
":",
"transformers",
"=",
"{",
"}",
"if",
"data_stor... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _EntryToEvent | Converts an APIAuditEntry to a legacy AuditEvent. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def _EntryToEvent(entry, handlers, transformers):
"""Converts an APIAuditEntry to a legacy AuditEvent."""
event = rdf_events.AuditEvent(
timestamp=entry.timestamp,
user=entry.username,
action=handlers[entry.router_method_name])
for fn in transformers:
fn(entry, event)
return event | def _EntryToEvent(entry, handlers, transformers):
"""Converts an APIAuditEntry to a legacy AuditEvent."""
event = rdf_events.AuditEvent(
timestamp=entry.timestamp,
user=entry.username,
action=handlers[entry.router_method_name])
for fn in transformers:
fn(entry, event)
return event | [
"Converts",
"an",
"APIAuditEntry",
"to",
"a",
"legacy",
"AuditEvent",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L54-L64 | [
"def",
"_EntryToEvent",
"(",
"entry",
",",
"handlers",
",",
"transformers",
")",
":",
"event",
"=",
"rdf_events",
".",
"AuditEvent",
"(",
"timestamp",
"=",
"entry",
".",
"timestamp",
",",
"user",
"=",
"entry",
".",
"username",
",",
"action",
"=",
"handlers... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ExtractClientIdFromPath | Extracts a Client ID from an APIAuditEntry's HTTP request path. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def _ExtractClientIdFromPath(entry, event):
"""Extracts a Client ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*(C\.[0-9a-fA-F]{16}).*", entry.http_request_path)
if match:
event.client = match.group(1) | def _ExtractClientIdFromPath(entry, event):
"""Extracts a Client ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*(C\.[0-9a-fA-F]{16}).*", entry.http_request_path)
if match:
event.client = match.group(1) | [
"Extracts",
"a",
"Client",
"ID",
"from",
"an",
"APIAuditEntry",
"s",
"HTTP",
"request",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L67-L71 | [
"def",
"_ExtractClientIdFromPath",
"(",
"entry",
",",
"event",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r\".*(C\\.[0-9a-fA-F]{16}).*\"",
",",
"entry",
".",
"http_request_path",
")",
"if",
"match",
":",
"event",
".",
"client",
"=",
"match",
".",
"gro... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ExtractCronJobIdFromPath | Extracts a CronJob ID from an APIAuditEntry's HTTP request path. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def _ExtractCronJobIdFromPath(entry, event):
"""Extracts a CronJob ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*cron-job/([^/]+).*", entry.http_request_path)
if match:
event.urn = "aff4:/cron/{}".format(match.group(1)) | def _ExtractCronJobIdFromPath(entry, event):
"""Extracts a CronJob ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*cron-job/([^/]+).*", entry.http_request_path)
if match:
event.urn = "aff4:/cron/{}".format(match.group(1)) | [
"Extracts",
"a",
"CronJob",
"ID",
"from",
"an",
"APIAuditEntry",
"s",
"HTTP",
"request",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L75-L79 | [
"def",
"_ExtractCronJobIdFromPath",
"(",
"entry",
",",
"event",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r\".*cron-job/([^/]+).*\"",
",",
"entry",
".",
"http_request_path",
")",
"if",
"match",
":",
"event",
".",
"urn",
"=",
"\"aff4:/cron/{}\"",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ExtractHuntIdFromPath | Extracts a Hunt ID from an APIAuditEntry's HTTP request path. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def _ExtractHuntIdFromPath(entry, event):
"""Extracts a Hunt ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*hunt/([^/]+).*", entry.http_request_path)
if match:
event.urn = "aff4:/hunts/{}".format(match.group(1)) | def _ExtractHuntIdFromPath(entry, event):
"""Extracts a Hunt ID from an APIAuditEntry's HTTP request path."""
match = re.match(r".*hunt/([^/]+).*", entry.http_request_path)
if match:
event.urn = "aff4:/hunts/{}".format(match.group(1)) | [
"Extracts",
"a",
"Hunt",
"ID",
"from",
"an",
"APIAuditEntry",
"s",
"HTTP",
"request",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L82-L86 | [
"def",
"_ExtractHuntIdFromPath",
"(",
"entry",
",",
"event",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r\".*hunt/([^/]+).*\"",
",",
"entry",
".",
"http_request_path",
")",
"if",
"match",
":",
"event",
".",
"urn",
"=",
"\"aff4:/hunts/{}\"",
".",
"form... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientApprovalsReportPlugin.GetReportData | Filter the cron job approvals in the given timerange. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def GetReportData(self, get_report_args, token=None):
"""Filter the cron job approvals in the given timerange."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.AUDIT_CHART,
audit_chart=rdf_report_plugins.ApiAuditChartReportData(
used_fields=self.USED_... | def GetReportData(self, get_report_args, token=None):
"""Filter the cron job approvals in the given timerange."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.AUDIT_CHART,
audit_chart=rdf_report_plugins.ApiAuditChartReportData(
used_fields=self.USED_... | [
"Filter",
"the",
"cron",
"job",
"approvals",
"in",
"the",
"given",
"timerange",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L107-L119 | [
"def",
"GetReportData",
"(",
"self",
",",
"get_report_args",
",",
"token",
"=",
"None",
")",
":",
"ret",
"=",
"rdf_report_plugins",
".",
"ApiReportData",
"(",
"representation_type",
"=",
"RepresentationType",
".",
"AUDIT_CHART",
",",
"audit_chart",
"=",
"rdf_repor... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MostActiveUsersReportPlugin.GetReportData | Filter the last week of user actions. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def GetReportData(self, get_report_args, token):
"""Filter the last week of user actions."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.PIE_CHART)
counts = self._GetUserCounts(get_report_args, token)
for username in aff4_users.GRRUser.SYSTEM_USERS:
del ... | def GetReportData(self, get_report_args, token):
"""Filter the last week of user actions."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.PIE_CHART)
counts = self._GetUserCounts(get_report_args, token)
for username in aff4_users.GRRUser.SYSTEM_USERS:
del ... | [
"Filter",
"the",
"last",
"week",
"of",
"user",
"actions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L240-L254 | [
"def",
"GetReportData",
"(",
"self",
",",
"get_report_args",
",",
"token",
")",
":",
"ret",
"=",
"rdf_report_plugins",
".",
"ApiReportData",
"(",
"representation_type",
"=",
"RepresentationType",
".",
"PIE_CHART",
")",
"counts",
"=",
"self",
".",
"_GetUserCounts",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UserActivityReportPlugin.GetReportData | Filter the last week of user actions. | grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py | def GetReportData(self, get_report_args, token):
"""Filter the last week of user actions."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.STACK_CHART)
week_duration = rdfvalue.Duration("7d")
num_weeks = math.ceil(get_report_args.duration.seconds /
... | def GetReportData(self, get_report_args, token):
"""Filter the last week of user actions."""
ret = rdf_report_plugins.ApiReportData(
representation_type=RepresentationType.STACK_CHART)
week_duration = rdfvalue.Duration("7d")
num_weeks = math.ceil(get_report_args.duration.seconds /
... | [
"Filter",
"the",
"last",
"week",
"of",
"user",
"actions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/server_report_plugins.py#L360-L394 | [
"def",
"GetReportData",
"(",
"self",
",",
"get_report_args",
",",
"token",
")",
":",
"ret",
"=",
"rdf_report_plugins",
".",
"ApiReportData",
"(",
"representation_type",
"=",
"RepresentationType",
".",
"STACK_CHART",
")",
"week_duration",
"=",
"rdfvalue",
".",
"Dur... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GetAFF4AttributeForReportType | Returns the corresponding AFF4 attribute for the given report type. | grr/server/grr_response_server/client_report_utils.py | def _GetAFF4AttributeForReportType(report_type
):
"""Returns the corresponding AFF4 attribute for the given report type."""
if report_type == rdf_stats.ClientGraphSeries.ReportType.GRR_VERSION:
return aff4_stats.ClientFleetStats.SchemaCls.GRRVERSION_HISTOGRAM
elif report_type... | def _GetAFF4AttributeForReportType(report_type
):
"""Returns the corresponding AFF4 attribute for the given report type."""
if report_type == rdf_stats.ClientGraphSeries.ReportType.GRR_VERSION:
return aff4_stats.ClientFleetStats.SchemaCls.GRRVERSION_HISTOGRAM
elif report_type... | [
"Returns",
"the",
"corresponding",
"AFF4",
"attribute",
"for",
"the",
"given",
"report",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L33-L45 | [
"def",
"_GetAFF4AttributeForReportType",
"(",
"report_type",
")",
":",
"if",
"report_type",
"==",
"rdf_stats",
".",
"ClientGraphSeries",
".",
"ReportType",
".",
"GRR_VERSION",
":",
"return",
"aff4_stats",
".",
"ClientFleetStats",
".",
"SchemaCls",
".",
"GRRVERSION_HIS... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WriteGraphSeries | Writes graph series for a particular client label to the DB.
Args:
graph_series: A series of rdf_stats.Graphs containing aggregated data for a
particular report-type.
label: Client label by which data in the graph_series was aggregated.
token: ACL token to use for writing to the legacy (non-relatio... | grr/server/grr_response_server/client_report_utils.py | def WriteGraphSeries(graph_series,
label,
token = None):
"""Writes graph series for a particular client label to the DB.
Args:
graph_series: A series of rdf_stats.Graphs containing aggregated data for a
particular report-type.
label: Client label by which dat... | def WriteGraphSeries(graph_series,
label,
token = None):
"""Writes graph series for a particular client label to the DB.
Args:
graph_series: A series of rdf_stats.Graphs containing aggregated data for a
particular report-type.
label: Client label by which dat... | [
"Writes",
"graph",
"series",
"for",
"a",
"particular",
"client",
"label",
"to",
"the",
"DB",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L48-L87 | [
"def",
"WriteGraphSeries",
"(",
"graph_series",
",",
"label",
",",
"token",
"=",
"None",
")",
":",
"if",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
":",
"data_store",
".",
"REL_DB",
".",
"WriteClientGraphSeries",
"(",
"graph_series",
",",
"label",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FetchAllGraphSeries | Fetches graph series for the given label and report-type from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
period: rdfvalue.Duration specifying how far back in time to fetch data. If
not provided, all data for the given ... | grr/server/grr_response_server/client_report_utils.py | def FetchAllGraphSeries(
label,
report_type,
period = None,
token = None
):
"""Fetches graph series for the given label and report-type from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
period: rdfvalue.Durat... | def FetchAllGraphSeries(
label,
report_type,
period = None,
token = None
):
"""Fetches graph series for the given label and report-type from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
period: rdfvalue.Durat... | [
"Fetches",
"graph",
"series",
"for",
"the",
"given",
"label",
"and",
"report",
"-",
"type",
"from",
"the",
"DB",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L90-L125 | [
"def",
"FetchAllGraphSeries",
"(",
"label",
",",
"report_type",
",",
"period",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"return",
"_FetchAllGraphSeriesFromTheLegacyDB",
"(",
"label",
",",
"report_type",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _FetchAllGraphSeriesFromTheLegacyDB | Fetches graph-series from the legacy DB [see FetchAllGraphSeries()]. | grr/server/grr_response_server/client_report_utils.py | def _FetchAllGraphSeriesFromTheLegacyDB(
label,
report_type,
period = None,
token = None
):
"""Fetches graph-series from the legacy DB [see FetchAllGraphSeries()]."""
if period is None:
time_range = aff4.ALL_TIMES
else:
range_end = rdfvalue.RDFDatetime.Now()
time_range = (range_end - p... | def _FetchAllGraphSeriesFromTheLegacyDB(
label,
report_type,
period = None,
token = None
):
"""Fetches graph-series from the legacy DB [see FetchAllGraphSeries()]."""
if period is None:
time_range = aff4.ALL_TIMES
else:
range_end = rdfvalue.RDFDatetime.Now()
time_range = (range_end - p... | [
"Fetches",
"graph",
"-",
"series",
"from",
"the",
"legacy",
"DB",
"[",
"see",
"FetchAllGraphSeries",
"()",
"]",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L128-L165 | [
"def",
"_FetchAllGraphSeriesFromTheLegacyDB",
"(",
"label",
",",
"report_type",
",",
"period",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"period",
"is",
"None",
":",
"time_range",
"=",
"aff4",
".",
"ALL_TIMES",
"else",
":",
"range_end",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FetchMostRecentGraphSeries | Fetches the latest graph series for a client label from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
token: ACL token to use for reading from the legacy (non-relational)
datastore.
Raises:
AFF4AttributeTypeError: ... | grr/server/grr_response_server/client_report_utils.py | def FetchMostRecentGraphSeries(label,
report_type,
token = None
):
"""Fetches the latest graph series for a client label from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSe... | def FetchMostRecentGraphSeries(label,
report_type,
token = None
):
"""Fetches the latest graph series for a client label from the DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSe... | [
"Fetches",
"the",
"latest",
"graph",
"series",
"for",
"a",
"client",
"label",
"from",
"the",
"DB",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L168-L193 | [
"def",
"FetchMostRecentGraphSeries",
"(",
"label",
",",
"report_type",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"return",
"_FetchMostRecentGraphSeriesFromTheLegacyDB",
"(",
"label",
",",
"report_type",
",",
"token",
"=",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _FetchMostRecentGraphSeriesFromTheLegacyDB | Fetches the latest graph-series for a client label from the legacy DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
token: ACL token to use for reading from the DB.
Raises:
AFF4AttributeTypeError: If an unexpected report-data t... | grr/server/grr_response_server/client_report_utils.py | def _FetchMostRecentGraphSeriesFromTheLegacyDB(
label,
report_type,
token = None
):
"""Fetches the latest graph-series for a client label from the legacy DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
token: ACL token ... | def _FetchMostRecentGraphSeriesFromTheLegacyDB(
label,
report_type,
token = None
):
"""Fetches the latest graph-series for a client label from the legacy DB.
Args:
label: Client label to fetch data for.
report_type: rdf_stats.ClientGraphSeries.ReportType to fetch data for.
token: ACL token ... | [
"Fetches",
"the",
"latest",
"graph",
"-",
"series",
"for",
"a",
"client",
"label",
"from",
"the",
"legacy",
"DB",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_report_utils.py#L196-L240 | [
"def",
"_FetchMostRecentGraphSeriesFromTheLegacyDB",
"(",
"label",
",",
"report_type",
",",
"token",
"=",
"None",
")",
":",
"try",
":",
"stats_for_label",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"GetAFF4ClientReportsURN",
"(",
")",
".",
"Add",
"(",
"lab... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrMessage.GenerateTaskID | Generates a new, unique task_id. | grr/core/grr_response_core/lib/rdfvalues/flows.py | def GenerateTaskID(self):
"""Generates a new, unique task_id."""
# Random number can not be zero since next_id_base must increment.
random_number = random.PositiveUInt16()
# 16 bit random numbers
with GrrMessage.lock:
next_id_base = GrrMessage.next_id_base
id_base = (next_id_base + ran... | def GenerateTaskID(self):
"""Generates a new, unique task_id."""
# Random number can not be zero since next_id_base must increment.
random_number = random.PositiveUInt16()
# 16 bit random numbers
with GrrMessage.lock:
next_id_base = GrrMessage.next_id_base
id_base = (next_id_base + ran... | [
"Generates",
"a",
"new",
"unique",
"task_id",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/flows.py#L50-L71 | [
"def",
"GenerateTaskID",
"(",
"self",
")",
":",
"# Random number can not be zero since next_id_base must increment.",
"random_number",
"=",
"random",
".",
"PositiveUInt16",
"(",
")",
"# 16 bit random numbers",
"with",
"GrrMessage",
".",
"lock",
":",
"next_id_base",
"=",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrMessage.payload | The payload property automatically decodes the encapsulated data. | grr/core/grr_response_core/lib/rdfvalues/flows.py | def payload(self):
"""The payload property automatically decodes the encapsulated data."""
if self.args_rdf_name:
# Now try to create the correct RDFValue.
result_cls = self.classes.get(self.args_rdf_name, rdfvalue.RDFString)
result = result_cls.FromSerializedString(
self.Get("args"... | def payload(self):
"""The payload property automatically decodes the encapsulated data."""
if self.args_rdf_name:
# Now try to create the correct RDFValue.
result_cls = self.classes.get(self.args_rdf_name, rdfvalue.RDFString)
result = result_cls.FromSerializedString(
self.Get("args"... | [
"The",
"payload",
"property",
"automatically",
"decodes",
"the",
"encapsulated",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/flows.py#L98-L106 | [
"def",
"payload",
"(",
"self",
")",
":",
"if",
"self",
".",
"args_rdf_name",
":",
"# Now try to create the correct RDFValue.",
"result_cls",
"=",
"self",
".",
"classes",
".",
"get",
"(",
"self",
".",
"args_rdf_name",
",",
"rdfvalue",
".",
"RDFString",
")",
"re... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrMessage.payload | Automatically encode RDFValues into the message. | grr/core/grr_response_core/lib/rdfvalues/flows.py | def payload(self, value):
"""Automatically encode RDFValues into the message."""
if not isinstance(value, rdfvalue.RDFValue):
raise RuntimeError("Payload must be an RDFValue.")
self.Set("args", value.SerializeToString())
# pylint: disable=protected-access
if value._age is not None:
sel... | def payload(self, value):
"""Automatically encode RDFValues into the message."""
if not isinstance(value, rdfvalue.RDFValue):
raise RuntimeError("Payload must be an RDFValue.")
self.Set("args", value.SerializeToString())
# pylint: disable=protected-access
if value._age is not None:
sel... | [
"Automatically",
"encode",
"RDFValues",
"into",
"the",
"message",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/flows.py#L109-L121 | [
"def",
"payload",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"rdfvalue",
".",
"RDFValue",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Payload must be an RDFValue.\"",
")",
"self",
".",
"Set",
"(",
"\"args\"",
",",
"va... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AddFilesWithUnknownHashes | Adds new files consisting of given blob references.
Args:
client_path_blob_refs: A dictionary mapping `db.ClientPath` instances to
lists of blob references.
use_external_stores: A flag indicating if the files should also be added to
external file stores.
Returns:
A dictionary mapping `db.C... | grr/server/grr_response_server/file_store.py | def AddFilesWithUnknownHashes(
client_path_blob_refs,
use_external_stores = True
):
"""Adds new files consisting of given blob references.
Args:
client_path_blob_refs: A dictionary mapping `db.ClientPath` instances to
lists of blob references.
use_external_stores: A flag indicating if the fil... | def AddFilesWithUnknownHashes(
client_path_blob_refs,
use_external_stores = True
):
"""Adds new files consisting of given blob references.
Args:
client_path_blob_refs: A dictionary mapping `db.ClientPath` instances to
lists of blob references.
use_external_stores: A flag indicating if the fil... | [
"Adds",
"new",
"files",
"consisting",
"of",
"given",
"blob",
"references",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L211-L304 | [
"def",
"AddFilesWithUnknownHashes",
"(",
"client_path_blob_refs",
",",
"use_external_stores",
"=",
"True",
")",
":",
"hash_id_blob_refs",
"=",
"dict",
"(",
")",
"client_path_hash_id",
"=",
"dict",
"(",
")",
"metadatas",
"=",
"dict",
"(",
")",
"all_client_path_blob_r... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AddFileWithUnknownHash | Add a new file consisting of given blob IDs. | grr/server/grr_response_server/file_store.py | def AddFileWithUnknownHash(client_path, blob_refs, use_external_stores=True):
"""Add a new file consisting of given blob IDs."""
precondition.AssertType(client_path, db.ClientPath)
precondition.AssertIterableType(blob_refs, rdf_objects.BlobReference)
return AddFilesWithUnknownHashes(
{client_path: blob_re... | def AddFileWithUnknownHash(client_path, blob_refs, use_external_stores=True):
"""Add a new file consisting of given blob IDs."""
precondition.AssertType(client_path, db.ClientPath)
precondition.AssertIterableType(blob_refs, rdf_objects.BlobReference)
return AddFilesWithUnknownHashes(
{client_path: blob_re... | [
"Add",
"a",
"new",
"file",
"consisting",
"of",
"given",
"blob",
"IDs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L307-L313 | [
"def",
"AddFileWithUnknownHash",
"(",
"client_path",
",",
"blob_refs",
",",
"use_external_stores",
"=",
"True",
")",
":",
"precondition",
".",
"AssertType",
"(",
"client_path",
",",
"db",
".",
"ClientPath",
")",
"precondition",
".",
"AssertIterableType",
"(",
"blo... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckHashes | Checks if files with given hashes are present in the file store.
Args:
hash_ids: A list of SHA256HashID objects.
Returns:
A dict where SHA256HashID objects are keys. Corresponding values
may be False (if hash id is not present) or True if it is not present. | grr/server/grr_response_server/file_store.py | def CheckHashes(hash_ids):
"""Checks if files with given hashes are present in the file store.
Args:
hash_ids: A list of SHA256HashID objects.
Returns:
A dict where SHA256HashID objects are keys. Corresponding values
may be False (if hash id is not present) or True if it is not present.
"""
retu... | def CheckHashes(hash_ids):
"""Checks if files with given hashes are present in the file store.
Args:
hash_ids: A list of SHA256HashID objects.
Returns:
A dict where SHA256HashID objects are keys. Corresponding values
may be False (if hash id is not present) or True if it is not present.
"""
retu... | [
"Checks",
"if",
"files",
"with",
"given",
"hashes",
"are",
"present",
"in",
"the",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L316-L329 | [
"def",
"CheckHashes",
"(",
"hash_ids",
")",
":",
"return",
"{",
"k",
":",
"bool",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"data_store",
".",
"REL_DB",
".",
"ReadHashBlobReferences",
"(",
"hash_ids",
")",
".",
"items",
"(",
")",
"}"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | OpenFile | Opens latest content of a given file for reading.
Args:
client_path: A db.ClientPath object describing path to a file.
max_timestamp: If specified, will open the last collected version with a
timestamp equal or lower than max_timestamp. If not specified, will simply
open the latest version.
Re... | grr/server/grr_response_server/file_store.py | def OpenFile(client_path, max_timestamp=None):
"""Opens latest content of a given file for reading.
Args:
client_path: A db.ClientPath object describing path to a file.
max_timestamp: If specified, will open the last collected version with a
timestamp equal or lower than max_timestamp. If not specifi... | def OpenFile(client_path, max_timestamp=None):
"""Opens latest content of a given file for reading.
Args:
client_path: A db.ClientPath object describing path to a file.
max_timestamp: If specified, will open the last collected version with a
timestamp equal or lower than max_timestamp. If not specifi... | [
"Opens",
"latest",
"content",
"of",
"a",
"given",
"file",
"for",
"reading",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L369-L401 | [
"def",
"OpenFile",
"(",
"client_path",
",",
"max_timestamp",
"=",
"None",
")",
":",
"path_info",
"=",
"data_store",
".",
"REL_DB",
".",
"ReadLatestPathInfosWithHashBlobReferences",
"(",
"[",
"client_path",
"]",
",",
"max_timestamp",
"=",
"max_timestamp",
")",
"[",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StreamFilesChunks | Streams contents of given files.
Args:
client_paths: db.ClientPath objects describing paths to files.
max_timestamp: If specified, then for every requested file will open the
last collected version of the file with a timestamp equal or lower than
max_timestamp. If not specified, will simply open ... | grr/server/grr_response_server/file_store.py | def StreamFilesChunks(client_paths, max_timestamp=None, max_size=None):
"""Streams contents of given files.
Args:
client_paths: db.ClientPath objects describing paths to files.
max_timestamp: If specified, then for every requested file will open the
last collected version of the file with a timestamp... | def StreamFilesChunks(client_paths, max_timestamp=None, max_size=None):
"""Streams contents of given files.
Args:
client_paths: db.ClientPath objects describing paths to files.
max_timestamp: If specified, then for every requested file will open the
last collected version of the file with a timestamp... | [
"Streams",
"contents",
"of",
"given",
"files",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L431-L492 | [
"def",
"StreamFilesChunks",
"(",
"client_paths",
",",
"max_timestamp",
"=",
"None",
",",
"max_size",
"=",
"None",
")",
":",
"path_infos_by_cp",
"=",
"(",
"data_store",
".",
"REL_DB",
".",
"ReadLatestPathInfosWithHashBlobReferences",
"(",
"client_paths",
",",
"max_ti... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ExternalFileStore.AddFiles | Adds multiple files to the file store.
Args:
hash_id_metadatas: A dictionary mapping hash ids to file metadata (a tuple
of hash client path and blob references). | grr/server/grr_response_server/file_store.py | def AddFiles(self, hash_id_metadatas):
"""Adds multiple files to the file store.
Args:
hash_id_metadatas: A dictionary mapping hash ids to file metadata (a tuple
of hash client path and blob references).
"""
for hash_id, metadata in iteritems(hash_id_metadatas):
self.AddFile(hash_id... | def AddFiles(self, hash_id_metadatas):
"""Adds multiple files to the file store.
Args:
hash_id_metadatas: A dictionary mapping hash ids to file metadata (a tuple
of hash client path and blob references).
"""
for hash_id, metadata in iteritems(hash_id_metadatas):
self.AddFile(hash_id... | [
"Adds",
"multiple",
"files",
"to",
"the",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L69-L77 | [
"def",
"AddFiles",
"(",
"self",
",",
"hash_id_metadatas",
")",
":",
"for",
"hash_id",
",",
"metadata",
"in",
"iteritems",
"(",
"hash_id_metadatas",
")",
":",
"self",
".",
"AddFile",
"(",
"hash_id",
",",
"metadata",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BlobStream._GetChunk | Fetches a chunk corresponding to the current offset. | grr/server/grr_response_server/file_store.py | def _GetChunk(self):
"""Fetches a chunk corresponding to the current offset."""
found_ref = None
for ref in self._blob_refs:
if self._offset >= ref.offset and self._offset < (ref.offset + ref.size):
found_ref = ref
break
if not found_ref:
return None, None
# If self._c... | def _GetChunk(self):
"""Fetches a chunk corresponding to the current offset."""
found_ref = None
for ref in self._blob_refs:
if self._offset >= ref.offset and self._offset < (ref.offset + ref.size):
found_ref = ref
break
if not found_ref:
return None, None
# If self._c... | [
"Fetches",
"a",
"chunk",
"corresponding",
"to",
"the",
"current",
"offset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L125-L145 | [
"def",
"_GetChunk",
"(",
"self",
")",
":",
"found_ref",
"=",
"None",
"for",
"ref",
"in",
"self",
".",
"_blob_refs",
":",
"if",
"self",
".",
"_offset",
">=",
"ref",
".",
"offset",
"and",
"self",
".",
"_offset",
"<",
"(",
"ref",
".",
"offset",
"+",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BlobStream.Read | Reads data. | grr/server/grr_response_server/file_store.py | def Read(self, length=None):
"""Reads data."""
if length is None:
length = self._length - self._offset
if length > self._max_unbound_read:
raise OversizedReadError("Attempted to read %d bytes when "
"Server.max_unbound_read_size is %d" %
... | def Read(self, length=None):
"""Reads data."""
if length is None:
length = self._length - self._offset
if length > self._max_unbound_read:
raise OversizedReadError("Attempted to read %d bytes when "
"Server.max_unbound_read_size is %d" %
... | [
"Reads",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L147-L171 | [
"def",
"Read",
"(",
"self",
",",
"length",
"=",
"None",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"self",
".",
"_length",
"-",
"self",
".",
"_offset",
"if",
"length",
">",
"self",
".",
"_max_unbound_read",
":",
"raise",
"OversizedRead... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BlobStream.Seek | Moves the reading cursor. | grr/server/grr_response_server/file_store.py | def Seek(self, offset, whence=os.SEEK_SET):
"""Moves the reading cursor."""
if whence == os.SEEK_SET:
self._offset = offset
elif whence == os.SEEK_CUR:
self._offset += offset
elif whence == os.SEEK_END:
self._offset = self._length + offset
else:
raise ValueError("Invalid whe... | def Seek(self, offset, whence=os.SEEK_SET):
"""Moves the reading cursor."""
if whence == os.SEEK_SET:
self._offset = offset
elif whence == os.SEEK_CUR:
self._offset += offset
elif whence == os.SEEK_END:
self._offset = self._length + offset
else:
raise ValueError("Invalid whe... | [
"Moves",
"the",
"reading",
"cursor",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/file_store.py#L178-L188 | [
"def",
"Seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"whence",
"==",
"os",
".",
"SEEK_SET",
":",
"self",
".",
"_offset",
"=",
"offset",
"elif",
"whence",
"==",
"os",
".",
"SEEK_CUR",
":",
"self",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TransferStoreUploader.UploadFilePath | Uploads chunks of a file on a given path to the transfer store flow.
Args:
filepath: A path to the file to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to stream. If it is `None` then
the whole file is uploaded.
... | grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py | def UploadFilePath(self, filepath, offset=0, amount=None):
"""Uploads chunks of a file on a given path to the transfer store flow.
Args:
filepath: A path to the file to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to str... | def UploadFilePath(self, filepath, offset=0, amount=None):
"""Uploads chunks of a file on a given path to the transfer store flow.
Args:
filepath: A path to the file to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to str... | [
"Uploads",
"chunks",
"of",
"a",
"file",
"on",
"a",
"given",
"path",
"to",
"the",
"transfer",
"store",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py#L40-L53 | [
"def",
"UploadFilePath",
"(",
"self",
",",
"filepath",
",",
"offset",
"=",
"0",
",",
"amount",
"=",
"None",
")",
":",
"return",
"self",
".",
"_UploadChunkStream",
"(",
"self",
".",
"_streamer",
".",
"StreamFilePath",
"(",
"filepath",
",",
"offset",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TransferStoreUploader.UploadFile | Uploads chunks of a given file descriptor to the transfer store flow.
Args:
fd: A file descriptor to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to stream. If it is `None` then
the whole file is uploaded.
Retur... | grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py | def UploadFile(self, fd, offset=0, amount=None):
"""Uploads chunks of a given file descriptor to the transfer store flow.
Args:
fd: A file descriptor to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to stream. If it is `N... | def UploadFile(self, fd, offset=0, amount=None):
"""Uploads chunks of a given file descriptor to the transfer store flow.
Args:
fd: A file descriptor to upload.
offset: An integer offset at which the file upload should start on.
amount: An upper bound on number of bytes to stream. If it is `N... | [
"Uploads",
"chunks",
"of",
"a",
"given",
"file",
"descriptor",
"to",
"the",
"transfer",
"store",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py#L55-L68 | [
"def",
"UploadFile",
"(",
"self",
",",
"fd",
",",
"offset",
"=",
"0",
",",
"amount",
"=",
"None",
")",
":",
"return",
"self",
".",
"_UploadChunkStream",
"(",
"self",
".",
"_streamer",
".",
"StreamFile",
"(",
"fd",
",",
"offset",
"=",
"offset",
",",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TransferStoreUploader._UploadChunk | Uploads a single chunk to the transfer store flow.
Args:
chunk: A chunk to upload.
Returns:
A `BlobImageChunkDescriptor` object. | grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py | def _UploadChunk(self, chunk):
"""Uploads a single chunk to the transfer store flow.
Args:
chunk: A chunk to upload.
Returns:
A `BlobImageChunkDescriptor` object.
"""
blob = _CompressedDataBlob(chunk)
self._action.ChargeBytesToSession(len(chunk.data))
self._action.SendReply(bl... | def _UploadChunk(self, chunk):
"""Uploads a single chunk to the transfer store flow.
Args:
chunk: A chunk to upload.
Returns:
A `BlobImageChunkDescriptor` object.
"""
blob = _CompressedDataBlob(chunk)
self._action.ChargeBytesToSession(len(chunk.data))
self._action.SendReply(bl... | [
"Uploads",
"a",
"single",
"chunk",
"to",
"the",
"transfer",
"store",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/uploading.py#L78-L95 | [
"def",
"_UploadChunk",
"(",
"self",
",",
"chunk",
")",
":",
"blob",
"=",
"_CompressedDataBlob",
"(",
"chunk",
")",
"self",
".",
"_action",
".",
"ChargeBytesToSession",
"(",
"len",
"(",
"chunk",
".",
"data",
")",
")",
"self",
".",
"_action",
".",
"SendRep... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _DistributionFromHistogram | Instantiate a rdf_stats.Distribution from a Prometheus Histogram.
Prometheus Histogram uses cumulative "buckets" lower or equal to an upper
bound. At instantiation, +Inf is implicitly appended to the upper bounds.
The delimiters [0.0, 0.1, 0.2 (, +Inf)] produce the following buckets:
Bucket "0.0" : -Inf <= val... | grr/server/grr_response_server/prometheus_stats_collector.py | def _DistributionFromHistogram(metric, values_by_suffix):
"""Instantiate a rdf_stats.Distribution from a Prometheus Histogram.
Prometheus Histogram uses cumulative "buckets" lower or equal to an upper
bound. At instantiation, +Inf is implicitly appended to the upper bounds.
The delimiters [0.0, 0.1, 0.2 (, +In... | def _DistributionFromHistogram(metric, values_by_suffix):
"""Instantiate a rdf_stats.Distribution from a Prometheus Histogram.
Prometheus Histogram uses cumulative "buckets" lower or equal to an upper
bound. At instantiation, +Inf is implicitly appended to the upper bounds.
The delimiters [0.0, 0.1, 0.2 (, +In... | [
"Instantiate",
"a",
"rdf_stats",
".",
"Distribution",
"from",
"a",
"Prometheus",
"Histogram",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/prometheus_stats_collector.py#L97-L147 | [
"def",
"_DistributionFromHistogram",
"(",
"metric",
",",
"values_by_suffix",
")",
":",
"dist",
"=",
"rdf_stats",
".",
"Distribution",
"(",
"bins",
"=",
"list",
"(",
"metric",
".",
"metadata",
".",
"bins",
")",
")",
"if",
"metric",
".",
"metadata",
".",
"bi... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CronTabParser.Parse | Parse the crontab file. | grr/core/grr_response_core/lib/parsers/cron_file_parser.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the crontab file."""
_ = knowledge_base
entries = []
crondata = file_object.read().decode("utf-8")
jobs = crontab.CronTab(tab=crondata)
for job in jobs:
entries.append(
rdf_cronjobs.CronTabEntry(
minute=... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the crontab file."""
_ = knowledge_base
entries = []
crondata = file_object.read().decode("utf-8")
jobs = crontab.CronTab(tab=crondata)
for job in jobs:
entries.append(
rdf_cronjobs.CronTabEntry(
minute=... | [
"Parse",
"the",
"crontab",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/cron_file_parser.py#L23-L47 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
"=",
"knowledge_base",
"entries",
"=",
"[",
"]",
"crondata",
"=",
"file_object",
".",
"read",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
"jobs",
"=... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MetadataCondition.Parse | Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`MetadataCondition` objects that correspond to the file-finder conditions. | grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py | def Parse(conditions):
"""Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`MetadataCondition` objects that correspond to the file-finder conditions.
"""
kind = rdf_file_finder.FileFinderConditi... | def Parse(conditions):
"""Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`MetadataCondition` objects that correspond to the file-finder conditions.
"""
kind = rdf_file_finder.FileFinderConditi... | [
"Parses",
"the",
"file",
"finder",
"condition",
"types",
"into",
"the",
"condition",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py#L40-L62 | [
"def",
"Parse",
"(",
"conditions",
")",
":",
"kind",
"=",
"rdf_file_finder",
".",
"FileFinderCondition",
".",
"Type",
"classes",
"=",
"{",
"kind",
".",
"MODIFICATION_TIME",
":",
"ModificationTimeCondition",
",",
"kind",
".",
"ACCESS_TIME",
":",
"AccessTimeConditio... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ContentCondition.Parse | Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`ContentCondition` objects that correspond to the file-finder conditions. | grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py | def Parse(conditions):
"""Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`ContentCondition` objects that correspond to the file-finder conditions.
"""
kind = rdf_file_finder.FileFinderConditio... | def Parse(conditions):
"""Parses the file finder condition types into the condition objects.
Args:
conditions: An iterator over `FileFinderCondition` objects.
Yields:
`ContentCondition` objects that correspond to the file-finder conditions.
"""
kind = rdf_file_finder.FileFinderConditio... | [
"Parses",
"the",
"file",
"finder",
"condition",
"types",
"into",
"the",
"condition",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py#L160-L179 | [
"def",
"Parse",
"(",
"conditions",
")",
":",
"kind",
"=",
"rdf_file_finder",
".",
"FileFinderCondition",
".",
"Type",
"classes",
"=",
"{",
"kind",
".",
"CONTENTS_LITERAL_MATCH",
":",
"LiteralMatchCondition",
",",
"kind",
".",
"CONTENTS_REGEX_MATCH",
":",
"RegexMat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ContentCondition.Scan | Scans given file searching for occurrences of given pattern.
Args:
fd: A file descriptor of the file that needs to be searched.
matcher: A matcher object specifying a pattern to search for.
Yields:
`BufferReference` objects pointing to file parts with matching content. | grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py | def Scan(self, fd,
matcher):
"""Scans given file searching for occurrences of given pattern.
Args:
fd: A file descriptor of the file that needs to be searched.
matcher: A matcher object specifying a pattern to search for.
Yields:
`BufferReference` objects pointing to file part... | def Scan(self, fd,
matcher):
"""Scans given file searching for occurrences of given pattern.
Args:
fd: A file descriptor of the file that needs to be searched.
matcher: A matcher object specifying a pattern to search for.
Yields:
`BufferReference` objects pointing to file part... | [
"Scans",
"given",
"file",
"searching",
"for",
"occurrences",
"of",
"given",
"pattern",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_finder_utils/conditions.py#L184-L212 | [
"def",
"Scan",
"(",
"self",
",",
"fd",
",",
"matcher",
")",
":",
"streamer",
"=",
"streaming",
".",
"Streamer",
"(",
"chunk_size",
"=",
"self",
".",
"CHUNK_SIZE",
",",
"overlap_size",
"=",
"self",
".",
"OVERLAP_SIZE",
")",
"offset",
"=",
"self",
".",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ServerLoggingStartupInit | Initialize the server logging configuration. | grr/server/grr_response_server/server_logging.py | def ServerLoggingStartupInit():
"""Initialize the server logging configuration."""
global LOGGER
if local_log:
logging.debug("Using local LogInit from %s", local_log)
local_log.LogInit()
logging.debug("Using local AppLogInit from %s", local_log)
LOGGER = local_log.AppLogInit()
else:
LogInit(... | def ServerLoggingStartupInit():
"""Initialize the server logging configuration."""
global LOGGER
if local_log:
logging.debug("Using local LogInit from %s", local_log)
local_log.LogInit()
logging.debug("Using local AppLogInit from %s", local_log)
LOGGER = local_log.AppLogInit()
else:
LogInit(... | [
"Initialize",
"the",
"server",
"logging",
"configuration",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_logging.py#L236-L246 | [
"def",
"ServerLoggingStartupInit",
"(",
")",
":",
"global",
"LOGGER",
"if",
"local_log",
":",
"logging",
".",
"debug",
"(",
"\"Using local LogInit from %s\"",
",",
"local_log",
")",
"local_log",
".",
"LogInit",
"(",
")",
"logging",
".",
"debug",
"(",
"\"Using lo... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrApplicationLogger.GetNewEventId | Return a unique Event ID string. | grr/server/grr_response_server/server_logging.py | def GetNewEventId(self, event_time=None):
"""Return a unique Event ID string."""
if event_time is None:
event_time = int(time.time() * 1e6)
return "%s:%s:%s" % (event_time, socket.gethostname(), os.getpid()) | def GetNewEventId(self, event_time=None):
"""Return a unique Event ID string."""
if event_time is None:
event_time = int(time.time() * 1e6)
return "%s:%s:%s" % (event_time, socket.gethostname(), os.getpid()) | [
"Return",
"a",
"unique",
"Event",
"ID",
"string",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_logging.py#L43-L48 | [
"def",
"GetNewEventId",
"(",
"self",
",",
"event_time",
"=",
"None",
")",
":",
"if",
"event_time",
"is",
"None",
":",
"event_time",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"*",
"1e6",
")",
"return",
"\"%s:%s:%s\"",
"%",
"(",
"event_time",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrApplicationLogger.LogHttpAdminUIAccess | Log an http based api call.
Args:
request: A WSGI request object.
response: A WSGI response object. | grr/server/grr_response_server/server_logging.py | def LogHttpAdminUIAccess(self, request, response):
"""Log an http based api call.
Args:
request: A WSGI request object.
response: A WSGI response object.
"""
# TODO(user): generate event_id elsewhere and use it for all the log
# messages that have to do with handling corresponding reque... | def LogHttpAdminUIAccess(self, request, response):
"""Log an http based api call.
Args:
request: A WSGI request object.
response: A WSGI response object.
"""
# TODO(user): generate event_id elsewhere and use it for all the log
# messages that have to do with handling corresponding reque... | [
"Log",
"an",
"http",
"based",
"api",
"call",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_logging.py#L50-L72 | [
"def",
"LogHttpAdminUIAccess",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# TODO(user): generate event_id elsewhere and use it for all the log",
"# messages that have to do with handling corresponding request.",
"event_id",
"=",
"self",
".",
"GetNewEventId",
"(",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrApplicationLogger.LogHttpFrontendAccess | Write a log entry for a Frontend or UI Request.
Args:
request: A HttpRequest protobuf.
source: Client id of the client initiating the request. Optional.
message_count: Number of messages received from the client. Optional. | grr/server/grr_response_server/server_logging.py | def LogHttpFrontendAccess(self, request, source=None, message_count=None):
"""Write a log entry for a Frontend or UI Request.
Args:
request: A HttpRequest protobuf.
source: Client id of the client initiating the request. Optional.
message_count: Number of messages received from the client. Op... | def LogHttpFrontendAccess(self, request, source=None, message_count=None):
"""Write a log entry for a Frontend or UI Request.
Args:
request: A HttpRequest protobuf.
source: Client id of the client initiating the request. Optional.
message_count: Number of messages received from the client. Op... | [
"Write",
"a",
"log",
"entry",
"for",
"a",
"Frontend",
"or",
"UI",
"Request",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_logging.py#L74-L89 | [
"def",
"LogHttpFrontendAccess",
"(",
"self",
",",
"request",
",",
"source",
"=",
"None",
",",
"message_count",
"=",
"None",
")",
":",
"# TODO(user): generate event_id elsewhere and use it for all the log",
"# messages that have to do with handling corresponding request.",
"event_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GetPkgResources | A wrapper for the `pkg_resource.resource_filename` function. | grr/core/grr_response_core/lib/package.py | def _GetPkgResources(package_name, filepath):
"""A wrapper for the `pkg_resource.resource_filename` function."""
requirement = pkg_resources.Requirement.parse(package_name)
try:
return pkg_resources.resource_filename(requirement, filepath)
except pkg_resources.DistributionNotFound:
# It may be that the ... | def _GetPkgResources(package_name, filepath):
"""A wrapper for the `pkg_resource.resource_filename` function."""
requirement = pkg_resources.Requirement.parse(package_name)
try:
return pkg_resources.resource_filename(requirement, filepath)
except pkg_resources.DistributionNotFound:
# It may be that the ... | [
"A",
"wrapper",
"for",
"the",
"pkg_resource",
".",
"resource_filename",
"function",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/package.py#L20-L33 | [
"def",
"_GetPkgResources",
"(",
"package_name",
",",
"filepath",
")",
":",
"requirement",
"=",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"package_name",
")",
"try",
":",
"return",
"pkg_resources",
".",
"resource_filename",
"(",
"requirement",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ResourcePath | Computes a path to the specified package resource.
Args:
package_name: A name of the package where the resource is located.
filepath: A path to the resource relative to the package location.
Returns:
A path to the resource or `None` if the resource cannot be found. | grr/core/grr_response_core/lib/package.py | def ResourcePath(package_name, filepath):
"""Computes a path to the specified package resource.
Args:
package_name: A name of the package where the resource is located.
filepath: A path to the resource relative to the package location.
Returns:
A path to the resource or `None` if the resource cannot... | def ResourcePath(package_name, filepath):
"""Computes a path to the specified package resource.
Args:
package_name: A name of the package where the resource is located.
filepath: A path to the resource relative to the package location.
Returns:
A path to the resource or `None` if the resource cannot... | [
"Computes",
"a",
"path",
"to",
"the",
"specified",
"package",
"resource",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/package.py#L36-L62 | [
"def",
"ResourcePath",
"(",
"package_name",
",",
"filepath",
")",
":",
"# If we are running a pyinstaller-built binary we rely on the sys.prefix",
"# code below and avoid running this which will generate confusing error",
"# messages.",
"if",
"not",
"getattr",
"(",
"sys",
",",
"\"f... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ModulePath | Computes a path to the specified module.
Args:
module_name: A name of the module to get the path for.
Returns:
A path to the specified module.
Raises:
ImportError: If specified module cannot be imported. | grr/core/grr_response_core/lib/package.py | def ModulePath(module_name):
"""Computes a path to the specified module.
Args:
module_name: A name of the module to get the path for.
Returns:
A path to the specified module.
Raises:
ImportError: If specified module cannot be imported.
"""
module = importlib.import_module(module_name)
path ... | def ModulePath(module_name):
"""Computes a path to the specified module.
Args:
module_name: A name of the module to get the path for.
Returns:
A path to the specified module.
Raises:
ImportError: If specified module cannot be imported.
"""
module = importlib.import_module(module_name)
path ... | [
"Computes",
"a",
"path",
"to",
"the",
"specified",
"module",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/package.py#L67-L95 | [
"def",
"ModulePath",
"(",
"module_name",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"path",
"=",
"inspect",
".",
"getfile",
"(",
"module",
")",
"# TODO: In Python 2 `inspect.getfile` returns a byte string, so",
"# we have to dec... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WithLimitedCallFrequency | Function call rate-limiting decorator.
This decorator ensures that the wrapped function will be called at most
once in min_time_between_calls time for the same set of arguments. For all
excessive calls a previous cached return value will be returned.
Suppose we use the decorator like this:
@cache.WithLimite... | grr/core/grr_response_core/lib/util/cache.py | def WithLimitedCallFrequency(min_time_between_calls):
"""Function call rate-limiting decorator.
This decorator ensures that the wrapped function will be called at most
once in min_time_between_calls time for the same set of arguments. For all
excessive calls a previous cached return value will be returned.
... | def WithLimitedCallFrequency(min_time_between_calls):
"""Function call rate-limiting decorator.
This decorator ensures that the wrapped function will be called at most
once in min_time_between_calls time for the same set of arguments. For all
excessive calls a previous cached return value will be returned.
... | [
"Function",
"call",
"rate",
"-",
"limiting",
"decorator",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/cache.py#L17-L117 | [
"def",
"WithLimitedCallFrequency",
"(",
"min_time_between_calls",
")",
":",
"def",
"Decorated",
"(",
"f",
")",
":",
"\"\"\"Actual decorator implementation.\"\"\"",
"lock",
"=",
"threading",
".",
"RLock",
"(",
")",
"prev_times",
"=",
"{",
"}",
"prev_results",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FieldDefinitionProtosFromTuples | Converts (field-name, type) tuples to MetricFieldDefinition protos. | grr/core/grr_response_core/stats/stats_utils.py | def FieldDefinitionProtosFromTuples(field_def_tuples):
"""Converts (field-name, type) tuples to MetricFieldDefinition protos."""
# TODO: This needs fixing for Python 3.
field_def_protos = []
for field_name, field_type in field_def_tuples:
if field_type in (int, long):
field_type = rdf_stats.MetricFiel... | def FieldDefinitionProtosFromTuples(field_def_tuples):
"""Converts (field-name, type) tuples to MetricFieldDefinition protos."""
# TODO: This needs fixing for Python 3.
field_def_protos = []
for field_name, field_type in field_def_tuples:
if field_type in (int, long):
field_type = rdf_stats.MetricFiel... | [
"Converts",
"(",
"field",
"-",
"name",
"type",
")",
"tuples",
"to",
"MetricFieldDefinition",
"protos",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L78-L92 | [
"def",
"FieldDefinitionProtosFromTuples",
"(",
"field_def_tuples",
")",
":",
"# TODO: This needs fixing for Python 3.",
"field_def_protos",
"=",
"[",
"]",
"for",
"field_name",
",",
"field_type",
"in",
"field_def_tuples",
":",
"if",
"field_type",
"in",
"(",
"int",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FieldDefinitionTuplesFromProtos | Converts MetricFieldDefinition protos to (field-name, type) tuples. | grr/core/grr_response_core/stats/stats_utils.py | def FieldDefinitionTuplesFromProtos(field_def_protos):
"""Converts MetricFieldDefinition protos to (field-name, type) tuples."""
# TODO: This needs fixing for Python 3.
field_def_tuples = []
for proto in field_def_protos:
if proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.INT:
field_type... | def FieldDefinitionTuplesFromProtos(field_def_protos):
"""Converts MetricFieldDefinition protos to (field-name, type) tuples."""
# TODO: This needs fixing for Python 3.
field_def_tuples = []
for proto in field_def_protos:
if proto.field_type == rdf_stats.MetricFieldDefinition.FieldType.INT:
field_type... | [
"Converts",
"MetricFieldDefinition",
"protos",
"to",
"(",
"field",
"-",
"name",
"type",
")",
"tuples",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L95-L108 | [
"def",
"FieldDefinitionTuplesFromProtos",
"(",
"field_def_protos",
")",
":",
"# TODO: This needs fixing for Python 3.",
"field_def_tuples",
"=",
"[",
"]",
"for",
"proto",
"in",
"field_def_protos",
":",
"if",
"proto",
".",
"field_type",
"==",
"rdf_stats",
".",
"MetricFie... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MetricValueTypeFromPythonType | Converts Python types to MetricMetadata.ValueType enum values. | grr/core/grr_response_core/stats/stats_utils.py | def MetricValueTypeFromPythonType(python_type):
"""Converts Python types to MetricMetadata.ValueType enum values."""
if python_type in (int, long):
return rdf_stats.MetricMetadata.ValueType.INT
elif python_type == float:
return rdf_stats.MetricMetadata.ValueType.FLOAT
else:
raise ValueError("Invalid... | def MetricValueTypeFromPythonType(python_type):
"""Converts Python types to MetricMetadata.ValueType enum values."""
if python_type in (int, long):
return rdf_stats.MetricMetadata.ValueType.INT
elif python_type == float:
return rdf_stats.MetricMetadata.ValueType.FLOAT
else:
raise ValueError("Invalid... | [
"Converts",
"Python",
"types",
"to",
"MetricMetadata",
".",
"ValueType",
"enum",
"values",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L111-L118 | [
"def",
"MetricValueTypeFromPythonType",
"(",
"python_type",
")",
":",
"if",
"python_type",
"in",
"(",
"int",
",",
"long",
")",
":",
"return",
"rdf_stats",
".",
"MetricMetadata",
".",
"ValueType",
".",
"INT",
"elif",
"python_type",
"==",
"float",
":",
"return",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PythonTypeFromMetricValueType | Converts MetricMetadata.ValueType enums to corresponding Python types. | grr/core/grr_response_core/stats/stats_utils.py | def PythonTypeFromMetricValueType(value_type):
"""Converts MetricMetadata.ValueType enums to corresponding Python types."""
if value_type == rdf_stats.MetricMetadata.ValueType.INT:
return int
elif value_type == rdf_stats.MetricMetadata.ValueType.FLOAT:
return float
else:
raise ValueError("Unknown va... | def PythonTypeFromMetricValueType(value_type):
"""Converts MetricMetadata.ValueType enums to corresponding Python types."""
if value_type == rdf_stats.MetricMetadata.ValueType.INT:
return int
elif value_type == rdf_stats.MetricMetadata.ValueType.FLOAT:
return float
else:
raise ValueError("Unknown va... | [
"Converts",
"MetricMetadata",
".",
"ValueType",
"enums",
"to",
"corresponding",
"Python",
"types",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L121-L128 | [
"def",
"PythonTypeFromMetricValueType",
"(",
"value_type",
")",
":",
"if",
"value_type",
"==",
"rdf_stats",
".",
"MetricMetadata",
".",
"ValueType",
".",
"INT",
":",
"return",
"int",
"elif",
"value_type",
"==",
"rdf_stats",
".",
"MetricMetadata",
".",
"ValueType",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateCounterMetadata | Helper function for creating MetricMetadata for counter metrics. | grr/core/grr_response_core/stats/stats_utils.py | def CreateCounterMetadata(metric_name, fields=None, docstring=None, units=None):
"""Helper function for creating MetricMetadata for counter metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
metric_type=rdf_stats.MetricMetadata.MetricType.COUNTER,
value_type=rdf_stats.MetricMetadata... | def CreateCounterMetadata(metric_name, fields=None, docstring=None, units=None):
"""Helper function for creating MetricMetadata for counter metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
metric_type=rdf_stats.MetricMetadata.MetricType.COUNTER,
value_type=rdf_stats.MetricMetadata... | [
"Helper",
"function",
"for",
"creating",
"MetricMetadata",
"for",
"counter",
"metrics",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L131-L139 | [
"def",
"CreateCounterMetadata",
"(",
"metric_name",
",",
"fields",
"=",
"None",
",",
"docstring",
"=",
"None",
",",
"units",
"=",
"None",
")",
":",
"return",
"rdf_stats",
".",
"MetricMetadata",
"(",
"varname",
"=",
"metric_name",
",",
"metric_type",
"=",
"rd... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateEventMetadata | Helper function for creating MetricMetadata for event metrics. | grr/core/grr_response_core/stats/stats_utils.py | def CreateEventMetadata(metric_name,
bins=None,
fields=None,
docstring=None,
units=None):
"""Helper function for creating MetricMetadata for event metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
... | def CreateEventMetadata(metric_name,
bins=None,
fields=None,
docstring=None,
units=None):
"""Helper function for creating MetricMetadata for event metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
... | [
"Helper",
"function",
"for",
"creating",
"MetricMetadata",
"for",
"event",
"metrics",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L142-L155 | [
"def",
"CreateEventMetadata",
"(",
"metric_name",
",",
"bins",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"docstring",
"=",
"None",
",",
"units",
"=",
"None",
")",
":",
"return",
"rdf_stats",
".",
"MetricMetadata",
"(",
"varname",
"=",
"metric_name",
",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateGaugeMetadata | Helper function for creating MetricMetadata for gauge metrics. | grr/core/grr_response_core/stats/stats_utils.py | def CreateGaugeMetadata(metric_name,
value_type,
fields=None,
docstring=None,
units=None):
"""Helper function for creating MetricMetadata for gauge metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
... | def CreateGaugeMetadata(metric_name,
value_type,
fields=None,
docstring=None,
units=None):
"""Helper function for creating MetricMetadata for gauge metrics."""
return rdf_stats.MetricMetadata(
varname=metric_name,
... | [
"Helper",
"function",
"for",
"creating",
"MetricMetadata",
"for",
"gauge",
"metrics",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/stats/stats_utils.py#L158-L170 | [
"def",
"CreateGaugeMetadata",
"(",
"metric_name",
",",
"value_type",
",",
"fields",
"=",
"None",
",",
"docstring",
"=",
"None",
",",
"units",
"=",
"None",
")",
":",
"return",
"rdf_stats",
".",
"MetricMetadata",
"(",
"varname",
"=",
"metric_name",
",",
"metri... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ImportFile | Import hashes from 'filename' into 'store'. | grr/server/grr_response_server/bin/import_nsrl_hashes.py | def ImportFile(store, filename, start):
"""Import hashes from 'filename' into 'store'."""
with io.open(filename, "r") as fp:
reader = csv.Reader(fp.read())
i = 0
current_row = None
product_code_list = []
op_system_code_list = []
for row in reader:
# Skip first row.
i += 1
i... | def ImportFile(store, filename, start):
"""Import hashes from 'filename' into 'store'."""
with io.open(filename, "r") as fp:
reader = csv.Reader(fp.read())
i = 0
current_row = None
product_code_list = []
op_system_code_list = []
for row in reader:
# Skip first row.
i += 1
i... | [
"Import",
"hashes",
"from",
"filename",
"into",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/import_nsrl_hashes.py#L41-L84 | [
"def",
"ImportFile",
"(",
"store",
",",
"filename",
",",
"start",
")",
":",
"with",
"io",
".",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"fp",
":",
"reader",
"=",
"csv",
".",
"Reader",
"(",
"fp",
".",
"read",
"(",
")",
")",
"i",
"=",
"0... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | main | Main. | grr/server/grr_response_server/bin/import_nsrl_hashes.py | def main(argv):
"""Main."""
del argv # Unused.
server_startup.Init()
filename = flags.FLAGS.filename
if not os.path.exists(filename):
print("File %s does not exist" % filename)
return
with aff4.FACTORY.Create(
filestore.NSRLFileStore.PATH,
filestore.NSRLFileStore,
mode="rw",
... | def main(argv):
"""Main."""
del argv # Unused.
server_startup.Init()
filename = flags.FLAGS.filename
if not os.path.exists(filename):
print("File %s does not exist" % filename)
return
with aff4.FACTORY.Create(
filestore.NSRLFileStore.PATH,
filestore.NSRLFileStore,
mode="rw",
... | [
"Main",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/import_nsrl_hashes.py#L87-L104 | [
"def",
"main",
"(",
"argv",
")",
":",
"del",
"argv",
"# Unused.",
"server_startup",
".",
"Init",
"(",
")",
"filename",
"=",
"flags",
".",
"FLAGS",
".",
"filename",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"print",
"("... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CanonicalPathToLocalPath | r"""Converts the canonical paths as used by GRR to OS specific paths.
Due to the inconsistencies between handling paths in windows we need to
convert a path to an OS specific version prior to using it. This function
should be called just before any OS specific functions.
Canonical paths on windows have:
-... | grr/client/grr_response_client/client_utils_windows.py | def CanonicalPathToLocalPath(path):
r"""Converts the canonical paths as used by GRR to OS specific paths.
Due to the inconsistencies between handling paths in windows we need to
convert a path to an OS specific version prior to using it. This function
should be called just before any OS specific functions.
... | def CanonicalPathToLocalPath(path):
r"""Converts the canonical paths as used by GRR to OS specific paths.
Due to the inconsistencies between handling paths in windows we need to
convert a path to an OS specific version prior to using it. This function
should be called just before any OS specific functions.
... | [
"r",
"Converts",
"the",
"canonical",
"paths",
"as",
"used",
"by",
"GRR",
"to",
"OS",
"specific",
"paths",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L33-L57 | [
"def",
"CanonicalPathToLocalPath",
"(",
"path",
")",
":",
"# Account for raw devices",
"path",
"=",
"path",
".",
"replace",
"(",
"\"/\\\\\"",
",",
"\"\\\\\"",
")",
"path",
"=",
"path",
".",
"replace",
"(",
"\"/\"",
",",
"\"\\\\\"",
")",
"m",
"=",
"re",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LocalPathToCanonicalPath | Converts path from the local system's convention to the canonical. | grr/client/grr_response_client/client_utils_windows.py | def LocalPathToCanonicalPath(path):
"""Converts path from the local system's convention to the canonical."""
path_components = path.split("/")
result = []
for component in path_components:
# Devices must maintain their \\ so they do not get broken up.
m = re.match(r"\\\\.\\", component)
# The compo... | def LocalPathToCanonicalPath(path):
"""Converts path from the local system's convention to the canonical."""
path_components = path.split("/")
result = []
for component in path_components:
# Devices must maintain their \\ so they do not get broken up.
m = re.match(r"\\\\.\\", component)
# The compo... | [
"Converts",
"path",
"from",
"the",
"local",
"system",
"s",
"convention",
"to",
"the",
"canonical",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L60-L74 | [
"def",
"LocalPathToCanonicalPath",
"(",
"path",
")",
":",
"path_components",
"=",
"path",
".",
"split",
"(",
"\"/\"",
")",
"result",
"=",
"[",
"]",
"for",
"component",
"in",
"path_components",
":",
"# Devices must maintain their \\\\ so they do not get broken up.",
"m... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WinChmod | Provide chmod-like functionality for windows.
Doco links:
goo.gl/n7YR1
goo.gl/rDv81
goo.gl/hDobb
Args:
filename: target filename for acl
acl_list: list of ntsecuritycon acl strings to be applied with bitwise OR.
e.g. ["FILE_GENERIC_READ", "FILE_GENERIC_WRITE"]
user: usernam... | grr/client/grr_response_client/client_utils_windows.py | def WinChmod(filename, acl_list, user=None):
"""Provide chmod-like functionality for windows.
Doco links:
goo.gl/n7YR1
goo.gl/rDv81
goo.gl/hDobb
Args:
filename: target filename for acl
acl_list: list of ntsecuritycon acl strings to be applied with bitwise OR.
e.g. ["FILE_GENER... | def WinChmod(filename, acl_list, user=None):
"""Provide chmod-like functionality for windows.
Doco links:
goo.gl/n7YR1
goo.gl/rDv81
goo.gl/hDobb
Args:
filename: target filename for acl
acl_list: list of ntsecuritycon acl strings to be applied with bitwise OR.
e.g. ["FILE_GENER... | [
"Provide",
"chmod",
"-",
"like",
"functionality",
"for",
"windows",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L77-L119 | [
"def",
"WinChmod",
"(",
"filename",
",",
"acl_list",
",",
"user",
"=",
"None",
")",
":",
"if",
"user",
"is",
"None",
":",
"user",
"=",
"win32api",
".",
"GetUserName",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FindProxies | Tries to find proxies by interrogating all the user's settings.
This function is a modified urillib.getproxies_registry() from the
standard library. We just store the proxy value in the environment
for urllib to find it.
TODO(user): Iterate through all the possible values if one proxy
fails, in case more th... | grr/client/grr_response_client/client_utils_windows.py | def FindProxies():
"""Tries to find proxies by interrogating all the user's settings.
This function is a modified urillib.getproxies_registry() from the
standard library. We just store the proxy value in the environment
for urllib to find it.
TODO(user): Iterate through all the possible values if one proxy
... | def FindProxies():
"""Tries to find proxies by interrogating all the user's settings.
This function is a modified urillib.getproxies_registry() from the
standard library. We just store the proxy value in the environment
for urllib to find it.
TODO(user): Iterate through all the possible values if one proxy
... | [
"Tries",
"to",
"find",
"proxies",
"by",
"interrogating",
"all",
"the",
"user",
"s",
"settings",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L134-L193 | [
"def",
"FindProxies",
"(",
")",
":",
"proxies",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"100",
")",
":",
"try",
":",
"sid",
"=",
"winreg",
".",
"EnumKey",
"(",
"winreg",
".",
"HKEY_USERS",
",",
"i",
")",
"except",
"OSError",
":",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetRawDevice | Resolves the raw device that contains the path.
Args:
path: A path to examine.
Returns:
A pathspec to read the raw device as well as the modified path to read
within the raw device. This is usually the path without the mount point.
Raises:
IOError: if the path does not exist or some unexpected ... | grr/client/grr_response_client/client_utils_windows.py | def GetRawDevice(path):
"""Resolves the raw device that contains the path.
Args:
path: A path to examine.
Returns:
A pathspec to read the raw device as well as the modified path to read
within the raw device. This is usually the path without the mount point.
Raises:
IOError: if the path does ... | def GetRawDevice(path):
"""Resolves the raw device that contains the path.
Args:
path: A path to examine.
Returns:
A pathspec to read the raw device as well as the modified path to read
within the raw device. This is usually the path without the mount point.
Raises:
IOError: if the path does ... | [
"Resolves",
"the",
"raw",
"device",
"that",
"contains",
"the",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L196-L239 | [
"def",
"GetRawDevice",
"(",
"path",
")",
":",
"path",
"=",
"CanonicalPathToLocalPath",
"(",
"path",
")",
"# Try to expand the shortened paths",
"try",
":",
"path",
"=",
"win32file",
".",
"GetLongPathName",
"(",
"path",
")",
"except",
"pywintypes",
".",
"error",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GetServiceKey | Returns the service key. | grr/client/grr_response_client/client_utils_windows.py | def _GetServiceKey():
"""Returns the service key."""
global _service_key
if _service_key is None:
hive = getattr(winreg, config.CONFIG["Client.config_hive"])
path = config.CONFIG["Client.config_key"]
# Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000
_service_key = winreg.CreateK... | def _GetServiceKey():
"""Returns the service key."""
global _service_key
if _service_key is None:
hive = getattr(winreg, config.CONFIG["Client.config_hive"])
path = config.CONFIG["Client.config_key"]
# Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000
_service_key = winreg.CreateK... | [
"Returns",
"the",
"service",
"key",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L245-L256 | [
"def",
"_GetServiceKey",
"(",
")",
":",
"global",
"_service_key",
"if",
"_service_key",
"is",
"None",
":",
"hive",
"=",
"getattr",
"(",
"winreg",
",",
"config",
".",
"CONFIG",
"[",
"\"Client.config_hive\"",
"]",
")",
"path",
"=",
"config",
".",
"CONFIG",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | RtlGetVersion | Wraps the lowlevel RtlGetVersion routine.
Args:
os_version_info_struct: instance of either a RTL_OSVERSIONINFOW structure
or a RTL_OSVERSIONINFOEXW structure,
ctypes.Structure-wrapped, with the
dwOSVersionInfoSize field preset to... | grr/client/grr_response_client/client_utils_windows.py | def RtlGetVersion(os_version_info_struct):
"""Wraps the lowlevel RtlGetVersion routine.
Args:
os_version_info_struct: instance of either a RTL_OSVERSIONINFOW structure
or a RTL_OSVERSIONINFOEXW structure,
ctypes.Structure-wrapped, with the
... | def RtlGetVersion(os_version_info_struct):
"""Wraps the lowlevel RtlGetVersion routine.
Args:
os_version_info_struct: instance of either a RTL_OSVERSIONINFOW structure
or a RTL_OSVERSIONINFOEXW structure,
ctypes.Structure-wrapped, with the
... | [
"Wraps",
"the",
"lowlevel",
"RtlGetVersion",
"routine",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L379-L397 | [
"def",
"RtlGetVersion",
"(",
"os_version_info_struct",
")",
":",
"rc",
"=",
"ctypes",
".",
"windll",
".",
"Ntdll",
".",
"RtlGetVersion",
"(",
"ctypes",
".",
"byref",
"(",
"os_version_info_struct",
")",
")",
"if",
"rc",
"!=",
"0",
":",
"raise",
"OSError",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | KernelVersion | Gets the kernel version as string, eg. "5.1.2600".
Returns:
The kernel version, or "unknown" in the case of failure. | grr/client/grr_response_client/client_utils_windows.py | def KernelVersion():
"""Gets the kernel version as string, eg. "5.1.2600".
Returns:
The kernel version, or "unknown" in the case of failure.
"""
rtl_osversioninfoexw = RtlOSVersionInfoExw()
try:
RtlGetVersion(rtl_osversioninfoexw)
except OSError:
return "unknown"
return "%d.%d.%d" % (rtl_osv... | def KernelVersion():
"""Gets the kernel version as string, eg. "5.1.2600".
Returns:
The kernel version, or "unknown" in the case of failure.
"""
rtl_osversioninfoexw = RtlOSVersionInfoExw()
try:
RtlGetVersion(rtl_osversioninfoexw)
except OSError:
return "unknown"
return "%d.%d.%d" % (rtl_osv... | [
"Gets",
"the",
"kernel",
"version",
"as",
"string",
"eg",
".",
"5",
".",
"1",
".",
"2600",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L425-L439 | [
"def",
"KernelVersion",
"(",
")",
":",
"rtl_osversioninfoexw",
"=",
"RtlOSVersionInfoExw",
"(",
")",
"try",
":",
"RtlGetVersion",
"(",
"rtl_osversioninfoexw",
")",
"except",
"OSError",
":",
"return",
"\"unknown\"",
"return",
"\"%d.%d.%d\"",
"%",
"(",
"rtl_osversioni... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | NannyController.Heartbeat | Writes a heartbeat to the registry. | grr/client/grr_response_client/client_utils_windows.py | def Heartbeat(self):
"""Writes a heartbeat to the registry."""
service_key = _GetServiceKey()
try:
winreg.SetValueEx(service_key, "Nanny.heartbeat", 0, winreg.REG_DWORD,
int(time.time()))
except OSError as e:
logging.debug("Failed to heartbeat nanny at %s: %s", servic... | def Heartbeat(self):
"""Writes a heartbeat to the registry."""
service_key = _GetServiceKey()
try:
winreg.SetValueEx(service_key, "Nanny.heartbeat", 0, winreg.REG_DWORD,
int(time.time()))
except OSError as e:
logging.debug("Failed to heartbeat nanny at %s: %s", servic... | [
"Writes",
"a",
"heartbeat",
"to",
"the",
"registry",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L262-L269 | [
"def",
"Heartbeat",
"(",
"self",
")",
":",
"service_key",
"=",
"_GetServiceKey",
"(",
")",
"try",
":",
"winreg",
".",
"SetValueEx",
"(",
"service_key",
",",
"\"Nanny.heartbeat\"",
",",
"0",
",",
"winreg",
".",
"REG_DWORD",
",",
"int",
"(",
"time",
".",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TransactionLog.Write | Write the message into the transaction log.
Args:
grr_message: A GrrMessage instance. | grr/client/grr_response_client/client_utils_windows.py | def Write(self, grr_message):
"""Write the message into the transaction log.
Args:
grr_message: A GrrMessage instance.
"""
grr_message = grr_message.SerializeToString()
try:
winreg.SetValueEx(_GetServiceKey(), "Transaction", 0, winreg.REG_BINARY,
grr_message)
... | def Write(self, grr_message):
"""Write the message into the transaction log.
Args:
grr_message: A GrrMessage instance.
"""
grr_message = grr_message.SerializeToString()
try:
winreg.SetValueEx(_GetServiceKey(), "Transaction", 0, winreg.REG_BINARY,
grr_message)
... | [
"Write",
"the",
"message",
"into",
"the",
"transaction",
"log",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L328-L340 | [
"def",
"Write",
"(",
"self",
",",
"grr_message",
")",
":",
"grr_message",
"=",
"grr_message",
".",
"SerializeToString",
"(",
")",
"try",
":",
"winreg",
".",
"SetValueEx",
"(",
"_GetServiceKey",
"(",
")",
",",
"\"Transaction\"",
",",
"0",
",",
"winreg",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TransactionLog.Get | Return a GrrMessage instance from the transaction log or None. | grr/client/grr_response_client/client_utils_windows.py | def Get(self):
"""Return a GrrMessage instance from the transaction log or None."""
try:
value, reg_type = winreg.QueryValueEx(_GetServiceKey(), "Transaction")
except OSError:
return
if reg_type != winreg.REG_BINARY:
return
try:
return rdf_flows.GrrMessage.FromSerializedStr... | def Get(self):
"""Return a GrrMessage instance from the transaction log or None."""
try:
value, reg_type = winreg.QueryValueEx(_GetServiceKey(), "Transaction")
except OSError:
return
if reg_type != winreg.REG_BINARY:
return
try:
return rdf_flows.GrrMessage.FromSerializedStr... | [
"Return",
"a",
"GrrMessage",
"instance",
"from",
"the",
"transaction",
"log",
"or",
"None",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_windows.py#L355-L368 | [
"def",
"Get",
"(",
"self",
")",
":",
"try",
":",
"value",
",",
"reg_type",
"=",
"winreg",
".",
"QueryValueEx",
"(",
"_GetServiceKey",
"(",
")",
",",
"\"Transaction\"",
")",
"except",
"OSError",
":",
"return",
"if",
"reg_type",
"!=",
"winreg",
".",
"REG_B... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Stat.FromPath | Returns stat information about the given OS path, calling os.[l]stat.
Args:
path: A path to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting has no effect.
Returns:
Stat instance, with... | grr/core/grr_response_core/lib/util/filesystem.py | def FromPath(cls, path, follow_symlink = True):
"""Returns stat information about the given OS path, calling os.[l]stat.
Args:
path: A path to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting... | def FromPath(cls, path, follow_symlink = True):
"""Returns stat information about the given OS path, calling os.[l]stat.
Args:
path: A path to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting... | [
"Returns",
"stat",
"information",
"about",
"the",
"given",
"OS",
"path",
"calling",
"os",
".",
"[",
"l",
"]",
"stat",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/filesystem.py#L36-L60 | [
"def",
"FromPath",
"(",
"cls",
",",
"path",
",",
"follow_symlink",
"=",
"True",
")",
":",
"# Note that we do not add type assertion for `path` here. The reason is that",
"# many of the existing system calls (e.g. `os.listdir`) return results as",
"# bytestrings in Python 2. This is fine ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Stat._FetchLinuxFlags | Fetches Linux extended file flags. | grr/core/grr_response_core/lib/util/filesystem.py | def _FetchLinuxFlags(self):
"""Fetches Linux extended file flags."""
if platform.system() != "Linux":
return 0
# Since we open a file in the next step we do not want to open a symlink.
# `lsattr` returns an error when trying to check flags of a symlink, so we
# assume that symlinks cannot hav... | def _FetchLinuxFlags(self):
"""Fetches Linux extended file flags."""
if platform.system() != "Linux":
return 0
# Since we open a file in the next step we do not want to open a symlink.
# `lsattr` returns an error when trying to check flags of a symlink, so we
# assume that symlinks cannot hav... | [
"Fetches",
"Linux",
"extended",
"file",
"flags",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/filesystem.py#L120-L159 | [
"def",
"_FetchLinuxFlags",
"(",
"self",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"\"Linux\"",
":",
"return",
"0",
"# Since we open a file in the next step we do not want to open a symlink.",
"# `lsattr` returns an error when trying to check flags of a symlink, s... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StatCache.Get | Stats given file or returns a cached result if available.
Args:
path: A path to the file to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting has no effect.
Returns:
`Stat` object corre... | grr/core/grr_response_core/lib/util/filesystem.py | def Get(self, path, follow_symlink = True):
"""Stats given file or returns a cached result if available.
Args:
path: A path to the file to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting has... | def Get(self, path, follow_symlink = True):
"""Stats given file or returns a cached result if available.
Args:
path: A path to the file to perform `stat` on.
follow_symlink: True if `stat` of a symlink should be returned instead of
a file that it points to. For non-symlinks this setting has... | [
"Stats",
"given",
"file",
"or",
"returns",
"a",
"cached",
"result",
"if",
"available",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/filesystem.py#L187-L211 | [
"def",
"Get",
"(",
"self",
",",
"path",
",",
"follow_symlink",
"=",
"True",
")",
":",
"key",
"=",
"self",
".",
"_Key",
"(",
"path",
"=",
"path",
",",
"follow_symlink",
"=",
"follow_symlink",
")",
"try",
":",
"return",
"self",
".",
"_cache",
"[",
"key... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Parser.GetClassesByArtifact | Get the classes that support parsing a given artifact. | grr/core/grr_response_core/lib/parser.py | def GetClassesByArtifact(cls, artifact_name):
"""Get the classes that support parsing a given artifact."""
return [
cls.classes[c]
for c in cls.classes
if artifact_name in cls.classes[c].supported_artifacts
] | def GetClassesByArtifact(cls, artifact_name):
"""Get the classes that support parsing a given artifact."""
return [
cls.classes[c]
for c in cls.classes
if artifact_name in cls.classes[c].supported_artifacts
] | [
"Get",
"the",
"classes",
"that",
"support",
"parsing",
"a",
"given",
"artifact",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parser.py#L130-L136 | [
"def",
"GetClassesByArtifact",
"(",
"cls",
",",
"artifact_name",
")",
":",
"return",
"[",
"cls",
".",
"classes",
"[",
"c",
"]",
"for",
"c",
"in",
"cls",
".",
"classes",
"if",
"artifact_name",
"in",
"cls",
".",
"classes",
"[",
"c",
"]",
".",
"supported_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PAMFieldParser.EnumerateAllConfigs | Generate RDFs for the fully expanded configs.
Args:
stats: A list of RDF StatEntries corresponding to the file_objects.
file_objects: A list of file handles.
Returns:
A tuple of a list of RDFValue PamConfigEntries found & a list of strings
which are the external config references found... | grr/core/grr_response_core/lib/parsers/linux_pam_parser.py | def EnumerateAllConfigs(self, stats, file_objects):
"""Generate RDFs for the fully expanded configs.
Args:
stats: A list of RDF StatEntries corresponding to the file_objects.
file_objects: A list of file handles.
Returns:
A tuple of a list of RDFValue PamConfigEntries found & a list of s... | def EnumerateAllConfigs(self, stats, file_objects):
"""Generate RDFs for the fully expanded configs.
Args:
stats: A list of RDF StatEntries corresponding to the file_objects.
file_objects: A list of file handles.
Returns:
A tuple of a list of RDFValue PamConfigEntries found & a list of s... | [
"Generate",
"RDFs",
"for",
"the",
"fully",
"expanded",
"configs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_pam_parser.py#L47-L84 | [
"def",
"EnumerateAllConfigs",
"(",
"self",
",",
"stats",
",",
"file_objects",
")",
":",
"# Convert the stats & file_objects into a cache of a",
"# simple path keyed dict of file contents.",
"cache",
"=",
"{",
"}",
"for",
"stat_obj",
",",
"file_obj",
"in",
"zip",
"(",
"s... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PAMFieldParser.EnumerateConfig | Return PamConfigEntries it finds as it recursively follows PAM configs.
Args:
service: A string containing the service name we are processing.
path: A string containing the file path name we want.
cache: A dictionary keyed on path, with the file contents (list of str).
filter_type: A string... | grr/core/grr_response_core/lib/parsers/linux_pam_parser.py | def EnumerateConfig(self, service, path, cache, filter_type=None):
"""Return PamConfigEntries it finds as it recursively follows PAM configs.
Args:
service: A string containing the service name we are processing.
path: A string containing the file path name we want.
cache: A dictionary keyed ... | def EnumerateConfig(self, service, path, cache, filter_type=None):
"""Return PamConfigEntries it finds as it recursively follows PAM configs.
Args:
service: A string containing the service name we are processing.
path: A string containing the file path name we want.
cache: A dictionary keyed ... | [
"Return",
"PamConfigEntries",
"it",
"finds",
"as",
"it",
"recursively",
"follows",
"PAM",
"configs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_pam_parser.py#L86-L184 | [
"def",
"EnumerateConfig",
"(",
"self",
",",
"service",
",",
"path",
",",
"cache",
",",
"filter_type",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"external",
"=",
"[",
"]",
"path",
"=",
"self",
".",
"_FixPath",
"(",
"path",
")",
"# Make sure we onl... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FingerprintFile.Run | Fingerprint a file. | grr/client/grr_response_client/client_actions/file_fingerprint.py | def Run(self, args):
"""Fingerprint a file."""
with vfs.VFSOpen(
args.pathspec, progress_callback=self.Progress) as file_obj:
fingerprinter = Fingerprinter(self.Progress, file_obj)
response = rdf_client_action.FingerprintResponse()
response.pathspec = file_obj.pathspec
if args.tu... | def Run(self, args):
"""Fingerprint a file."""
with vfs.VFSOpen(
args.pathspec, progress_callback=self.Progress) as file_obj:
fingerprinter = Fingerprinter(self.Progress, file_obj)
response = rdf_client_action.FingerprintResponse()
response.pathspec = file_obj.pathspec
if args.tu... | [
"Fingerprint",
"a",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/file_fingerprint.py#L46-L97 | [
"def",
"Run",
"(",
"self",
",",
"args",
")",
":",
"with",
"vfs",
".",
"VFSOpen",
"(",
"args",
".",
"pathspec",
",",
"progress_callback",
"=",
"self",
".",
"Progress",
")",
"as",
"file_obj",
":",
"fingerprinter",
"=",
"Fingerprinter",
"(",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ValidateAFF4Type | Validates an AFF4 type. | grr/server/grr_response_server/aff4.py | def _ValidateAFF4Type(aff4_type):
"""Validates an AFF4 type."""
if aff4_type is None:
return
if not isinstance(aff4_type, type):
raise TypeError("aff4_type=%s must be a type" % aff4_type)
if not issubclass(aff4_type, AFF4Object):
raise TypeError("aff4_type=%s must be a subclass of AFF4Object." %
... | def _ValidateAFF4Type(aff4_type):
"""Validates an AFF4 type."""
if aff4_type is None:
return
if not isinstance(aff4_type, type):
raise TypeError("aff4_type=%s must be a type" % aff4_type)
if not issubclass(aff4_type, AFF4Object):
raise TypeError("aff4_type=%s must be a subclass of AFF4Object." %
... | [
"Validates",
"an",
"AFF4",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L272-L281 | [
"def",
"_ValidateAFF4Type",
"(",
"aff4_type",
")",
":",
"if",
"aff4_type",
"is",
"None",
":",
"return",
"if",
"not",
"isinstance",
"(",
"aff4_type",
",",
"type",
")",
":",
"raise",
"TypeError",
"(",
"\"aff4_type=%s must be a type\"",
"%",
"aff4_type",
")",
"if... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.Open | Opens the named object.
DeletionPool will only open the object if it's not in the pool already.
Otherwise it will just return the cached version. Objects are cached
based on their urn and mode. I.e. same object opened with mode="r" and
mode="rw" will be actually opened two times and cached separately.
... | grr/server/grr_response_server/aff4.py | def Open(self, urn, aff4_type=None, mode="r"):
"""Opens the named object.
DeletionPool will only open the object if it's not in the pool already.
Otherwise it will just return the cached version. Objects are cached
based on their urn and mode. I.e. same object opened with mode="r" and
mode="rw" wil... | def Open(self, urn, aff4_type=None, mode="r"):
"""Opens the named object.
DeletionPool will only open the object if it's not in the pool already.
Otherwise it will just return the cached version. Objects are cached
based on their urn and mode. I.e. same object opened with mode="r" and
mode="rw" wil... | [
"Opens",
"the",
"named",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L106-L142 | [
"def",
"Open",
"(",
"self",
",",
"urn",
",",
"aff4_type",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
")",
":",
"key",
"=",
"self",
".",
"_ObjectKey",
"(",
"urn",
",",
"mode",
")",
"try",
":",
"obj",
"=",
"self",
".",
"_objects_cache",
"[",
"key",
"]... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.MultiOpen | Opens many urns efficiently, returning cached objects when possible. | grr/server/grr_response_server/aff4.py | def MultiOpen(self, urns, aff4_type=None, mode="r"):
"""Opens many urns efficiently, returning cached objects when possible."""
not_opened_urns = []
_ValidateAFF4Type(aff4_type)
for urn in urns:
key = self._ObjectKey(urn, mode)
try:
result = self._objects_cache[key]
if aff4_... | def MultiOpen(self, urns, aff4_type=None, mode="r"):
"""Opens many urns efficiently, returning cached objects when possible."""
not_opened_urns = []
_ValidateAFF4Type(aff4_type)
for urn in urns:
key = self._ObjectKey(urn, mode)
try:
result = self._objects_cache[key]
if aff4_... | [
"Opens",
"many",
"urns",
"efficiently",
"returning",
"cached",
"objects",
"when",
"possible",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L144-L169 | [
"def",
"MultiOpen",
"(",
"self",
",",
"urns",
",",
"aff4_type",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
")",
":",
"not_opened_urns",
"=",
"[",
"]",
"_ValidateAFF4Type",
"(",
"aff4_type",
")",
"for",
"urn",
"in",
"urns",
":",
"key",
"=",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.ListChildren | Lists children of a given urn. Resulting list is cached. | grr/server/grr_response_server/aff4.py | def ListChildren(self, urn):
"""Lists children of a given urn. Resulting list is cached."""
result = self.MultiListChildren([urn])
try:
return result[urn]
except KeyError:
return [] | def ListChildren(self, urn):
"""Lists children of a given urn. Resulting list is cached."""
result = self.MultiListChildren([urn])
try:
return result[urn]
except KeyError:
return [] | [
"Lists",
"children",
"of",
"a",
"given",
"urn",
".",
"Resulting",
"list",
"is",
"cached",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L171-L177 | [
"def",
"ListChildren",
"(",
"self",
",",
"urn",
")",
":",
"result",
"=",
"self",
".",
"MultiListChildren",
"(",
"[",
"urn",
"]",
")",
"try",
":",
"return",
"result",
"[",
"urn",
"]",
"except",
"KeyError",
":",
"return",
"[",
"]"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.MultiListChildren | Lists children of a bunch of given urns. Results are cached. | grr/server/grr_response_server/aff4.py | def MultiListChildren(self, urns):
"""Lists children of a bunch of given urns. Results are cached."""
result = {}
not_listed_urns = []
for urn in urns:
try:
result[urn] = self._children_lists_cache[urn]
except KeyError:
not_listed_urns.append(urn)
if not_listed_urns:
... | def MultiListChildren(self, urns):
"""Lists children of a bunch of given urns. Results are cached."""
result = {}
not_listed_urns = []
for urn in urns:
try:
result[urn] = self._children_lists_cache[urn]
except KeyError:
not_listed_urns.append(urn)
if not_listed_urns:
... | [
"Lists",
"children",
"of",
"a",
"bunch",
"of",
"given",
"urns",
".",
"Results",
"are",
"cached",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L179-L198 | [
"def",
"MultiListChildren",
"(",
"self",
",",
"urns",
")",
":",
"result",
"=",
"{",
"}",
"not_listed_urns",
"=",
"[",
"]",
"for",
"urn",
"in",
"urns",
":",
"try",
":",
"result",
"[",
"urn",
"]",
"=",
"self",
".",
"_children_lists_cache",
"[",
"urn",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.RecursiveMultiListChildren | Recursively lists given urns. Results are cached. | grr/server/grr_response_server/aff4.py | def RecursiveMultiListChildren(self, urns):
"""Recursively lists given urns. Results are cached."""
result = {}
checked_urns = set()
not_cached_urns = []
urns_to_check = urns
while True:
found_children = []
for urn in urns_to_check:
try:
children = result[urn] = s... | def RecursiveMultiListChildren(self, urns):
"""Recursively lists given urns. Results are cached."""
result = {}
checked_urns = set()
not_cached_urns = []
urns_to_check = urns
while True:
found_children = []
for urn in urns_to_check:
try:
children = result[urn] = s... | [
"Recursively",
"lists",
"given",
"urns",
".",
"Results",
"are",
"cached",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L200-L226 | [
"def",
"RecursiveMultiListChildren",
"(",
"self",
",",
"urns",
")",
":",
"result",
"=",
"{",
"}",
"checked_urns",
"=",
"set",
"(",
")",
"not_cached_urns",
"=",
"[",
"]",
"urns_to_check",
"=",
"urns",
"while",
"True",
":",
"found_children",
"=",
"[",
"]",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.MultiMarkForDeletion | Marks multiple urns (and their children) for deletion. | grr/server/grr_response_server/aff4.py | def MultiMarkForDeletion(self, urns):
"""Marks multiple urns (and their children) for deletion."""
all_children_urns = self.RecursiveMultiListChildren(urns)
urns.extend(collection.Flatten(itervalues(all_children_urns)))
self._urns_for_deletion.update(urns)
for obj in self.MultiOpen(urns):
ob... | def MultiMarkForDeletion(self, urns):
"""Marks multiple urns (and their children) for deletion."""
all_children_urns = self.RecursiveMultiListChildren(urns)
urns.extend(collection.Flatten(itervalues(all_children_urns)))
self._urns_for_deletion.update(urns)
for obj in self.MultiOpen(urns):
ob... | [
"Marks",
"multiple",
"urns",
"(",
"and",
"their",
"children",
")",
"for",
"deletion",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L232-L240 | [
"def",
"MultiMarkForDeletion",
"(",
"self",
",",
"urns",
")",
":",
"all_children_urns",
"=",
"self",
".",
"RecursiveMultiListChildren",
"(",
"urns",
")",
"urns",
".",
"extend",
"(",
"collection",
".",
"Flatten",
"(",
"itervalues",
"(",
"all_children_urns",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeletionPool.root_urns_for_deletion | Roots of the graph of urns marked for deletion. | grr/server/grr_response_server/aff4.py | def root_urns_for_deletion(self):
"""Roots of the graph of urns marked for deletion."""
roots = set()
for urn in self._urns_for_deletion:
new_root = True
str_urn = utils.SmartUnicode(urn)
fake_roots = []
for root in roots:
str_root = utils.SmartUnicode(root)
if str_... | def root_urns_for_deletion(self):
"""Roots of the graph of urns marked for deletion."""
roots = set()
for urn in self._urns_for_deletion:
new_root = True
str_urn = utils.SmartUnicode(urn)
fake_roots = []
for root in roots:
str_root = utils.SmartUnicode(root)
if str_... | [
"Roots",
"of",
"the",
"graph",
"of",
"urns",
"marked",
"for",
"deletion",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L243-L264 | [
"def",
"root_urns_for_deletion",
"(",
"self",
")",
":",
"roots",
"=",
"set",
"(",
")",
"for",
"urn",
"in",
"self",
".",
"_urns_for_deletion",
":",
"new_root",
"=",
"True",
"str_urn",
"=",
"utils",
".",
"SmartUnicode",
"(",
"urn",
")",
"fake_roots",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.ParseAgeSpecification | Parses an aff4 age and returns a datastore age specification. | grr/server/grr_response_server/aff4.py | def ParseAgeSpecification(cls, age):
"""Parses an aff4 age and returns a datastore age specification."""
try:
return (0, int(age))
except (ValueError, TypeError):
pass
if age == NEWEST_TIME:
return data_store.DB.NEWEST_TIMESTAMP
elif age == ALL_TIMES:
return data_store.DB.AL... | def ParseAgeSpecification(cls, age):
"""Parses an aff4 age and returns a datastore age specification."""
try:
return (0, int(age))
except (ValueError, TypeError):
pass
if age == NEWEST_TIME:
return data_store.DB.NEWEST_TIMESTAMP
elif age == ALL_TIMES:
return data_store.DB.AL... | [
"Parses",
"an",
"aff4",
"age",
"and",
"returns",
"a",
"datastore",
"age",
"specification",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L303-L319 | [
"def",
"ParseAgeSpecification",
"(",
"cls",
",",
"age",
")",
":",
"try",
":",
"return",
"(",
"0",
",",
"int",
"(",
"age",
")",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"pass",
"if",
"age",
"==",
"NEWEST_TIME",
":",
"return",
"dat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.GetAttributes | Retrieves all the attributes for all the urns. | grr/server/grr_response_server/aff4.py | def GetAttributes(self, urns, age=NEWEST_TIME):
"""Retrieves all the attributes for all the urns."""
urns = set([utils.SmartUnicode(u) for u in urns])
to_read = {urn: self._MakeCacheInvariant(urn, age) for urn in urns}
# Urns not present in the cache we need to get from the database.
if to_read:
... | def GetAttributes(self, urns, age=NEWEST_TIME):
"""Retrieves all the attributes for all the urns."""
urns = set([utils.SmartUnicode(u) for u in urns])
to_read = {urn: self._MakeCacheInvariant(urn, age) for urn in urns}
# Urns not present in the cache we need to get from the database.
if to_read:
... | [
"Retrieves",
"all",
"the",
"attributes",
"for",
"all",
"the",
"urns",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L321-L337 | [
"def",
"GetAttributes",
"(",
"self",
",",
"urns",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"urns",
"=",
"set",
"(",
"[",
"utils",
".",
"SmartUnicode",
"(",
"u",
")",
"for",
"u",
"in",
"urns",
"]",
")",
"to_read",
"=",
"{",
"urn",
":",
"self",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.SetAttributes | Sets the attributes in the data store. | grr/server/grr_response_server/aff4.py | def SetAttributes(self,
urn,
attributes,
to_delete,
add_child_index=True,
mutation_pool=None):
"""Sets the attributes in the data store."""
attributes[AFF4Object.SchemaCls.LAST] = [
rdfvalue.RDFDatetime.... | def SetAttributes(self,
urn,
attributes,
to_delete,
add_child_index=True,
mutation_pool=None):
"""Sets the attributes in the data store."""
attributes[AFF4Object.SchemaCls.LAST] = [
rdfvalue.RDFDatetime.... | [
"Sets",
"the",
"attributes",
"in",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L339-L361 | [
"def",
"SetAttributes",
"(",
"self",
",",
"urn",
",",
"attributes",
",",
"to_delete",
",",
"add_child_index",
"=",
"True",
",",
"mutation_pool",
"=",
"None",
")",
":",
"attributes",
"[",
"AFF4Object",
".",
"SchemaCls",
".",
"LAST",
"]",
"=",
"[",
"rdfvalue... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory._UpdateChildIndex | Update the child indexes.
This function maintains the index for direct child relations. When we set
an AFF4 path, we always add an attribute like
index:dir/%(childname)s to its parent. This is written
asynchronously to its parent.
In order to query for all direct children of an AFF4 object, we the... | grr/server/grr_response_server/aff4.py | def _UpdateChildIndex(self, urn, mutation_pool):
"""Update the child indexes.
This function maintains the index for direct child relations. When we set
an AFF4 path, we always add an attribute like
index:dir/%(childname)s to its parent. This is written
asynchronously to its parent.
In order to... | def _UpdateChildIndex(self, urn, mutation_pool):
"""Update the child indexes.
This function maintains the index for direct child relations. When we set
an AFF4 path, we always add an attribute like
index:dir/%(childname)s to its parent. This is written
asynchronously to its parent.
In order to... | [
"Update",
"the",
"child",
"indexes",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L363-L409 | [
"def",
"_UpdateChildIndex",
"(",
"self",
",",
"urn",
",",
"mutation_pool",
")",
":",
"try",
":",
"# Create navigation aids by touching intermediate subject names.",
"while",
"urn",
".",
"Path",
"(",
")",
"!=",
"\"/\"",
":",
"basename",
"=",
"urn",
".",
"Basename",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory._MakeCacheInvariant | Returns an invariant key for an AFF4 object.
The object will be cached based on this key. This function is specifically
extracted to ensure that we encapsulate all security critical aspects of the
AFF4 object so that objects do not leak across security boundaries.
Args:
urn: The urn of the obje... | grr/server/grr_response_server/aff4.py | def _MakeCacheInvariant(self, urn, age):
"""Returns an invariant key for an AFF4 object.
The object will be cached based on this key. This function is specifically
extracted to ensure that we encapsulate all security critical aspects of the
AFF4 object so that objects do not leak across security bounda... | def _MakeCacheInvariant(self, urn, age):
"""Returns an invariant key for an AFF4 object.
The object will be cached based on this key. This function is specifically
extracted to ensure that we encapsulate all security critical aspects of the
AFF4 object so that objects do not leak across security bounda... | [
"Returns",
"an",
"invariant",
"key",
"for",
"an",
"AFF4",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L439-L455 | [
"def",
"_MakeCacheInvariant",
"(",
"self",
",",
"urn",
",",
"age",
")",
":",
"precondition",
".",
"AssertType",
"(",
"urn",
",",
"Text",
")",
"return",
"\"%s:%s\"",
"%",
"(",
"urn",
",",
"self",
".",
"ParseAgeSpecification",
"(",
"age",
")",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.CreateWithLock | Creates a new object and locks it.
Similar to OpenWithLock below, this creates a locked object. The difference
is that when you call CreateWithLock, the object does not yet have to exist
in the data store.
Args:
urn: The object to create.
aff4_type: The desired type for this object.
... | grr/server/grr_response_server/aff4.py | def CreateWithLock(self,
urn,
aff4_type,
token=None,
age=NEWEST_TIME,
force_new_version=True,
blocking=True,
blocking_lock_timeout=10,
blocking_sleep_in... | def CreateWithLock(self,
urn,
aff4_type,
token=None,
age=NEWEST_TIME,
force_new_version=True,
blocking=True,
blocking_lock_timeout=10,
blocking_sleep_in... | [
"Creates",
"a",
"new",
"object",
"and",
"locks",
"it",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L457-L513 | [
"def",
"CreateWithLock",
"(",
"self",
",",
"urn",
",",
"aff4_type",
",",
"token",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
",",
"force_new_version",
"=",
"True",
",",
"blocking",
"=",
"True",
",",
"blocking_lock_timeout",
"=",
"10",
",",
"blocking_sleep_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.OpenWithLock | Open given urn and locks it.
Opens an object and locks it for 'lease_time' seconds. OpenWithLock can
only be used in 'with ...' statement. The lock is released when code
execution leaves 'with ...' block.
The urn is always opened in "rw" mode. Symlinks are not followed in
OpenWithLock() due to pos... | grr/server/grr_response_server/aff4.py | def OpenWithLock(self,
urn,
aff4_type=None,
token=None,
age=NEWEST_TIME,
blocking=True,
blocking_lock_timeout=10,
blocking_sleep_interval=1,
lease_time=100):
"""Ope... | def OpenWithLock(self,
urn,
aff4_type=None,
token=None,
age=NEWEST_TIME,
blocking=True,
blocking_lock_timeout=10,
blocking_sleep_interval=1,
lease_time=100):
"""Ope... | [
"Open",
"given",
"urn",
"and",
"locks",
"it",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L515-L576 | [
"def",
"OpenWithLock",
"(",
"self",
",",
"urn",
",",
"aff4_type",
"=",
"None",
",",
"token",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
",",
"blocking",
"=",
"True",
",",
"blocking_lock_timeout",
"=",
"10",
",",
"blocking_sleep_interval",
"=",
"1",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory._AcquireLock | This actually acquires the lock for a given URN. | grr/server/grr_response_server/aff4.py | def _AcquireLock(self,
urn,
blocking=None,
blocking_lock_timeout=None,
lease_time=None,
blocking_sleep_interval=None):
"""This actually acquires the lock for a given URN."""
if urn is None:
raise ValueError("URN... | def _AcquireLock(self,
urn,
blocking=None,
blocking_lock_timeout=None,
lease_time=None,
blocking_sleep_interval=None):
"""This actually acquires the lock for a given URN."""
if urn is None:
raise ValueError("URN... | [
"This",
"actually",
"acquires",
"the",
"lock",
"for",
"a",
"given",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L578-L598 | [
"def",
"_AcquireLock",
"(",
"self",
",",
"urn",
",",
"blocking",
"=",
"None",
",",
"blocking_lock_timeout",
"=",
"None",
",",
"lease_time",
"=",
"None",
",",
"blocking_sleep_interval",
"=",
"None",
")",
":",
"if",
"urn",
"is",
"None",
":",
"raise",
"ValueE... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Copy | Make a copy of one AFF4 object to a different URN. | grr/server/grr_response_server/aff4.py | def Copy(self,
old_urn,
new_urn,
age=NEWEST_TIME,
limit=None,
update_timestamps=False):
"""Make a copy of one AFF4 object to a different URN."""
new_urn = rdfvalue.RDFURN(new_urn)
if update_timestamps and age != NEWEST_TIME:
raise ValueError(
... | def Copy(self,
old_urn,
new_urn,
age=NEWEST_TIME,
limit=None,
update_timestamps=False):
"""Make a copy of one AFF4 object to a different URN."""
new_urn = rdfvalue.RDFURN(new_urn)
if update_timestamps and age != NEWEST_TIME:
raise ValueError(
... | [
"Make",
"a",
"copy",
"of",
"one",
"AFF4",
"object",
"to",
"a",
"different",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L600-L627 | [
"def",
"Copy",
"(",
"self",
",",
"old_urn",
",",
"new_urn",
",",
"age",
"=",
"NEWEST_TIME",
",",
"limit",
"=",
"None",
",",
"update_timestamps",
"=",
"False",
")",
":",
"new_urn",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"new_urn",
")",
"if",
"update_timesta... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.ExistsWithType | Checks if an object with a given URN and type exists in the datastore.
Args:
urn: The urn to check.
aff4_type: Expected object type.
follow_symlinks: If object opened is a symlink, follow it.
age: The age policy used to check this object. Should be either
NEWEST_TIME or a time range... | grr/server/grr_response_server/aff4.py | def ExistsWithType(self,
urn,
aff4_type=None,
follow_symlinks=True,
age=NEWEST_TIME,
token=None):
"""Checks if an object with a given URN and type exists in the datastore.
Args:
urn: The urn to check.... | def ExistsWithType(self,
urn,
aff4_type=None,
follow_symlinks=True,
age=NEWEST_TIME,
token=None):
"""Checks if an object with a given URN and type exists in the datastore.
Args:
urn: The urn to check.... | [
"Checks",
"if",
"an",
"object",
"with",
"a",
"given",
"URN",
"and",
"type",
"exists",
"in",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L629-L665 | [
"def",
"ExistsWithType",
"(",
"self",
",",
"urn",
",",
"aff4_type",
"=",
"None",
",",
"follow_symlinks",
"=",
"True",
",",
"age",
"=",
"NEWEST_TIME",
",",
"token",
"=",
"None",
")",
":",
"if",
"not",
"aff4_type",
":",
"raise",
"ValueError",
"(",
"\"aff4_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Open | Opens the named object.
This instantiates the object from the AFF4 data store.
Note that the root aff4:/ object is a container for all other
objects. Opening it for reading will instantiate a AFF4Volume instance, even
if the row does not exist.
The mode parameter specifies, how the object should b... | grr/server/grr_response_server/aff4.py | def Open(self,
urn,
aff4_type=None,
mode="r",
token=None,
local_cache=None,
age=NEWEST_TIME,
follow_symlinks=True,
transaction=None):
"""Opens the named object.
This instantiates the object from the AFF4 data store.
Not... | def Open(self,
urn,
aff4_type=None,
mode="r",
token=None,
local_cache=None,
age=NEWEST_TIME,
follow_symlinks=True,
transaction=None):
"""Opens the named object.
This instantiates the object from the AFF4 data store.
Not... | [
"Opens",
"the",
"named",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L667-L771 | [
"def",
"Open",
"(",
"self",
",",
"urn",
",",
"aff4_type",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
",",
"token",
"=",
"None",
",",
"local_cache",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
",",
"follow_symlinks",
"=",
"True",
",",
"transaction",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.MultiOpen | Opens a bunch of urns efficiently. | grr/server/grr_response_server/aff4.py | def MultiOpen(self,
urns,
mode="rw",
token=None,
aff4_type=None,
age=NEWEST_TIME,
follow_symlinks=True):
"""Opens a bunch of urns efficiently."""
if not data_store.AFF4Enabled():
raise NotImplementedError("AFF... | def MultiOpen(self,
urns,
mode="rw",
token=None,
aff4_type=None,
age=NEWEST_TIME,
follow_symlinks=True):
"""Opens a bunch of urns efficiently."""
if not data_store.AFF4Enabled():
raise NotImplementedError("AFF... | [
"Opens",
"a",
"bunch",
"of",
"urns",
"efficiently",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L773-L832 | [
"def",
"MultiOpen",
"(",
"self",
",",
"urns",
",",
"mode",
"=",
"\"rw\"",
",",
"token",
"=",
"None",
",",
"aff4_type",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"not",
"data_store",
".",
"AFF4Enab... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.MultiOpenOrdered | Opens many URNs and returns handles in the same order.
`MultiOpen` can return file handles in arbitrary order. This makes it more
efficient and in most cases the order does not matter. However, there are
cases where order is important and this function should be used instead.
Args:
urns: A list ... | grr/server/grr_response_server/aff4.py | def MultiOpenOrdered(self, urns, **kwargs):
"""Opens many URNs and returns handles in the same order.
`MultiOpen` can return file handles in arbitrary order. This makes it more
efficient and in most cases the order does not matter. However, there are
cases where order is important and this function sho... | def MultiOpenOrdered(self, urns, **kwargs):
"""Opens many URNs and returns handles in the same order.
`MultiOpen` can return file handles in arbitrary order. This makes it more
efficient and in most cases the order does not matter. However, there are
cases where order is important and this function sho... | [
"Opens",
"many",
"URNs",
"and",
"returns",
"handles",
"in",
"the",
"same",
"order",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L834-L866 | [
"def",
"MultiOpenOrdered",
"(",
"self",
",",
"urns",
",",
"*",
"*",
"kwargs",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"urns",
",",
"rdfvalue",
".",
"RDFURN",
")",
"urn_filedescs",
"=",
"{",
"}",
"for",
"filedesc",
"in",
"self",
".",
"Mu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.OpenDiscreteVersions | Returns all the versions of the object as AFF4 objects.
This iterates through versions of an object, returning the newest version
first, then each older version until the beginning of time.
Note that versions are defined by changes to the TYPE attribute, and this
takes the version between two TYPE att... | grr/server/grr_response_server/aff4.py | def OpenDiscreteVersions(self,
urn,
mode="r",
token=None,
local_cache=None,
age=ALL_TIMES,
diffs_only=False,
follow_symlinks=True):... | def OpenDiscreteVersions(self,
urn,
mode="r",
token=None,
local_cache=None,
age=ALL_TIMES,
diffs_only=False,
follow_symlinks=True):... | [
"Returns",
"all",
"the",
"versions",
"of",
"the",
"object",
"as",
"AFF4",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L868-L981 | [
"def",
"OpenDiscreteVersions",
"(",
"self",
",",
"urn",
",",
"mode",
"=",
"\"r\"",
",",
"token",
"=",
"None",
",",
"local_cache",
"=",
"None",
",",
"age",
"=",
"ALL_TIMES",
",",
"diffs_only",
"=",
"False",
",",
"follow_symlinks",
"=",
"True",
")",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Stat | Returns metadata about all urns.
Currently the metadata include type, and last update time.
Args:
urns: The urns of the objects to open.
Yields:
A dict of metadata.
Raises:
ValueError: A string was passed instead of an iterable. | grr/server/grr_response_server/aff4.py | def Stat(self, urns):
"""Returns metadata about all urns.
Currently the metadata include type, and last update time.
Args:
urns: The urns of the objects to open.
Yields:
A dict of metadata.
Raises:
ValueError: A string was passed instead of an iterable.
"""
if isinstanc... | def Stat(self, urns):
"""Returns metadata about all urns.
Currently the metadata include type, and last update time.
Args:
urns: The urns of the objects to open.
Yields:
A dict of metadata.
Raises:
ValueError: A string was passed instead of an iterable.
"""
if isinstanc... | [
"Returns",
"metadata",
"about",
"all",
"urns",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L983-L1007 | [
"def",
"Stat",
"(",
"self",
",",
"urns",
")",
":",
"if",
"isinstance",
"(",
"urns",
",",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Expected an iterable, not string.\"",
")",
"for",
"subject",
",",
"values",
"in",
"data_store",
".",
"DB",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Create | Creates the urn if it does not already exist, otherwise opens it.
If the urn exists and is of a different type, this will also promote it to
the specified type.
Args:
urn: The object to create.
aff4_type: The desired type for this object.
mode: The desired mode for this object.
tok... | grr/server/grr_response_server/aff4.py | def Create(self,
urn,
aff4_type,
mode="w",
token=None,
age=NEWEST_TIME,
force_new_version=True,
object_exists=False,
mutation_pool=None,
transaction=None):
"""Creates the urn if it does not already e... | def Create(self,
urn,
aff4_type,
mode="w",
token=None,
age=NEWEST_TIME,
force_new_version=True,
object_exists=False,
mutation_pool=None,
transaction=None):
"""Creates the urn if it does not already e... | [
"Creates",
"the",
"urn",
"if",
"it",
"does",
"not",
"already",
"exist",
"otherwise",
"opens",
"it",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1009-L1092 | [
"def",
"Create",
"(",
"self",
",",
"urn",
",",
"aff4_type",
",",
"mode",
"=",
"\"w\"",
",",
"token",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
",",
"force_new_version",
"=",
"True",
",",
"object_exists",
"=",
"False",
",",
"mutation_pool",
"=",
"None"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.