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 | Factory.MultiDelete | Drop all the information about given objects.
DANGEROUS! This recursively deletes all objects contained within the
specified URN.
Args:
urns: Urns of objects to remove.
token: The Security Token to use for opening this item.
Raises:
ValueError: If one of the urns is too short. This ... | grr/server/grr_response_server/aff4.py | def MultiDelete(self, urns, token=None):
"""Drop all the information about given objects.
DANGEROUS! This recursively deletes all objects contained within the
specified URN.
Args:
urns: Urns of objects to remove.
token: The Security Token to use for opening this item.
Raises:
Va... | def MultiDelete(self, urns, token=None):
"""Drop all the information about given objects.
DANGEROUS! This recursively deletes all objects contained within the
specified URN.
Args:
urns: Urns of objects to remove.
token: The Security Token to use for opening this item.
Raises:
Va... | [
"Drop",
"all",
"the",
"information",
"about",
"given",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1094-L1148 | [
"def",
"MultiDelete",
"(",
"self",
",",
"urns",
",",
"token",
"=",
"None",
")",
":",
"urns",
"=",
"[",
"rdfvalue",
".",
"RDFURN",
"(",
"urn",
")",
"for",
"urn",
"in",
"urns",
"]",
"if",
"token",
"is",
"None",
":",
"token",
"=",
"data_store",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.MultiListChildren | Lists bunch of directories efficiently.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range.
Yields:
Tuples of Subjects and a list of... | grr/server/grr_response_server/aff4.py | def MultiListChildren(self, urns, limit=None, age=NEWEST_TIME):
"""Lists bunch of directories efficiently.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWES... | def MultiListChildren(self, urns, limit=None, age=NEWEST_TIME):
"""Lists bunch of directories efficiently.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWES... | [
"Lists",
"bunch",
"of",
"directories",
"efficiently",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1166-L1194 | [
"def",
"MultiListChildren",
"(",
"self",
",",
"urns",
",",
"limit",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"checked_subjects",
"=",
"set",
"(",
")",
"for",
"subject",
",",
"values",
"in",
"data_store",
".",
"DB",
".",
"AFF4MultiFetchChildre... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.ListChildren | Lists bunch of directories efficiently.
Args:
urn: Urn to list children.
limit: Max number of children to list.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range.
Returns:
RDFURNs instances of each child. | grr/server/grr_response_server/aff4.py | def ListChildren(self, urn, limit=None, age=NEWEST_TIME):
"""Lists bunch of directories efficiently.
Args:
urn: Urn to list children.
limit: Max number of children to list.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range.
Returns:
R... | def ListChildren(self, urn, limit=None, age=NEWEST_TIME):
"""Lists bunch of directories efficiently.
Args:
urn: Urn to list children.
limit: Max number of children to list.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range.
Returns:
R... | [
"Lists",
"bunch",
"of",
"directories",
"efficiently",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1196-L1210 | [
"def",
"ListChildren",
"(",
"self",
",",
"urn",
",",
"limit",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"_",
",",
"children_urns",
"=",
"list",
"(",
"self",
".",
"MultiListChildren",
"(",
"[",
"urn",
"]",
",",
"limit",
"=",
"limit",
",",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.RecursiveMultiListChildren | Recursively lists bunch of directories.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range.
Yields:
(subject<->children urns) tuples... | grr/server/grr_response_server/aff4.py | def RecursiveMultiListChildren(self, urns, limit=None, age=NEWEST_TIME):
"""Recursively lists bunch of directories.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
... | def RecursiveMultiListChildren(self, urns, limit=None, age=NEWEST_TIME):
"""Recursively lists bunch of directories.
Args:
urns: List of urns to list children.
limit: Max number of children to list (NOTE: this is per urn).
age: The age of the items to retrieve. Should be one of ALL_TIMES,
... | [
"Recursively",
"lists",
"bunch",
"of",
"directories",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1212-L1250 | [
"def",
"RecursiveMultiListChildren",
"(",
"self",
",",
"urns",
",",
"limit",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"checked_urns",
"=",
"set",
"(",
")",
"urns_to_check",
"=",
"urns",
"while",
"True",
":",
"found_children",
"=",
"[",
"]",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Attribute.Copy | Return a copy without registering in the attribute registry. | grr/server/grr_response_server/aff4.py | def Copy(self):
"""Return a copy without registering in the attribute registry."""
return Attribute(
self.predicate,
self.attribute_type,
self.description,
self.name,
_copy=True) | def Copy(self):
"""Return a copy without registering in the attribute registry."""
return Attribute(
self.predicate,
self.attribute_type,
self.description,
self.name,
_copy=True) | [
"Return",
"a",
"copy",
"without",
"registering",
"in",
"the",
"attribute",
"registry",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1335-L1342 | [
"def",
"Copy",
"(",
"self",
")",
":",
"return",
"Attribute",
"(",
"self",
".",
"predicate",
",",
"self",
".",
"attribute_type",
",",
"self",
".",
"description",
",",
"self",
".",
"name",
",",
"_copy",
"=",
"True",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Attribute.GetRDFValueType | Returns this attribute's RDFValue class. | grr/server/grr_response_server/aff4.py | def GetRDFValueType(self):
"""Returns this attribute's RDFValue class."""
result = self.attribute_type
for field_name in self.field_names:
# Support the new semantic protobufs.
try:
result = result.type_infos.get(field_name).type
except AttributeError:
raise AttributeError(... | def GetRDFValueType(self):
"""Returns this attribute's RDFValue class."""
result = self.attribute_type
for field_name in self.field_names:
# Support the new semantic protobufs.
try:
result = result.type_infos.get(field_name).type
except AttributeError:
raise AttributeError(... | [
"Returns",
"this",
"attribute",
"s",
"RDFValue",
"class",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1403-L1413 | [
"def",
"GetRDFValueType",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"attribute_type",
"for",
"field_name",
"in",
"self",
".",
"field_names",
":",
"# Support the new semantic protobufs.",
"try",
":",
"result",
"=",
"result",
".",
"type_infos",
".",
"get"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Attribute.GetSubFields | Gets all the subfields indicated by field_names.
This resolves specifications like "Users.special_folders.app_data" where for
each entry in the Users protobuf the corresponding app_data folder entry
should be returned.
Args:
fd: The base RDFValue or Array.
field_names: A list of strings in... | grr/server/grr_response_server/aff4.py | def GetSubFields(self, fd, field_names):
"""Gets all the subfields indicated by field_names.
This resolves specifications like "Users.special_folders.app_data" where for
each entry in the Users protobuf the corresponding app_data folder entry
should be returned.
Args:
fd: The base RDFValue o... | def GetSubFields(self, fd, field_names):
"""Gets all the subfields indicated by field_names.
This resolves specifications like "Users.special_folders.app_data" where for
each entry in the Users protobuf the corresponding app_data folder entry
should be returned.
Args:
fd: The base RDFValue o... | [
"Gets",
"all",
"the",
"subfields",
"indicated",
"by",
"field_names",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1426-L1447 | [
"def",
"GetSubFields",
"(",
"self",
",",
"fd",
",",
"field_names",
")",
":",
"if",
"isinstance",
"(",
"fd",
",",
"rdf_protodict",
".",
"RDFValueArray",
")",
":",
"for",
"value",
"in",
"fd",
":",
"for",
"res",
"in",
"self",
".",
"_GetSubField",
"(",
"va... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Attribute.GetValues | Return the values for this attribute as stored in an AFF4Object. | grr/server/grr_response_server/aff4.py | def GetValues(self, fd):
"""Return the values for this attribute as stored in an AFF4Object."""
result = None
for result in fd.new_attributes.get(self, []):
# We need to interpolate sub fields in this rdfvalue.
if self.field_names:
for x in self.GetSubFields(result, self.field_names):
... | def GetValues(self, fd):
"""Return the values for this attribute as stored in an AFF4Object."""
result = None
for result in fd.new_attributes.get(self, []):
# We need to interpolate sub fields in this rdfvalue.
if self.field_names:
for x in self.GetSubFields(result, self.field_names):
... | [
"Return",
"the",
"values",
"for",
"this",
"attribute",
"as",
"stored",
"in",
"an",
"AFF4Object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1449-L1476 | [
"def",
"GetValues",
"(",
"self",
",",
"fd",
")",
":",
"result",
"=",
"None",
"for",
"result",
"in",
"fd",
".",
"new_attributes",
".",
"get",
"(",
"self",
",",
"[",
"]",
")",
":",
"# We need to interpolate sub fields in this rdfvalue.",
"if",
"self",
".",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Attribute.GetDefault | Returns a default attribute if it is not set. | grr/server/grr_response_server/aff4.py | def GetDefault(self, fd=None, default=None):
"""Returns a default attribute if it is not set."""
if callable(self.default):
return self.default(fd)
if self.default is not None:
# We can't return mutable objects here or the default might change for all
# objects of this class.
if isi... | def GetDefault(self, fd=None, default=None):
"""Returns a default attribute if it is not set."""
if callable(self.default):
return self.default(fd)
if self.default is not None:
# We can't return mutable objects here or the default might change for all
# objects of this class.
if isi... | [
"Returns",
"a",
"default",
"attribute",
"if",
"it",
"is",
"not",
"set",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1478-L1497 | [
"def",
"GetDefault",
"(",
"self",
",",
"fd",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"callable",
"(",
"self",
".",
"default",
")",
":",
"return",
"self",
".",
"default",
"(",
"fd",
")",
"if",
"self",
".",
"default",
"is",
"not",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.DecodeValueFromAttribute | Given a serialized value, decode the attribute.
Only attributes which have been previously defined are permitted.
Args:
attribute_name: The string name of the attribute.
value: The serialized attribute value.
ts: The timestamp of this attribute. | grr/server/grr_response_server/aff4.py | def DecodeValueFromAttribute(self, attribute_name, value, ts):
"""Given a serialized value, decode the attribute.
Only attributes which have been previously defined are permitted.
Args:
attribute_name: The string name of the attribute.
value: The serialized attribute value.
ts: The ti... | def DecodeValueFromAttribute(self, attribute_name, value, ts):
"""Given a serialized value, decode the attribute.
Only attributes which have been previously defined are permitted.
Args:
attribute_name: The string name of the attribute.
value: The serialized attribute value.
ts: The ti... | [
"Given",
"a",
"serialized",
"value",
"decode",
"the",
"attribute",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1793-L1813 | [
"def",
"DecodeValueFromAttribute",
"(",
"self",
",",
"attribute_name",
",",
"value",
",",
"ts",
")",
":",
"try",
":",
"# Get the Attribute object from our schema.",
"attribute",
"=",
"Attribute",
".",
"PREDICATES",
"[",
"attribute_name",
"]",
"cls",
"=",
"attribute"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object._AddAttributeToCache | Helper to add a new attribute to a cache. | grr/server/grr_response_server/aff4.py | def _AddAttributeToCache(self, attribute_name, value, cache):
"""Helper to add a new attribute to a cache."""
# If there's another value in cache with the same timestamp, the last added
# one takes precedence. This helps a lot in tests that use FakeTime.
attribute_list = cache.setdefault(attribute_name,... | def _AddAttributeToCache(self, attribute_name, value, cache):
"""Helper to add a new attribute to a cache."""
# If there's another value in cache with the same timestamp, the last added
# one takes precedence. This helps a lot in tests that use FakeTime.
attribute_list = cache.setdefault(attribute_name,... | [
"Helper",
"to",
"add",
"a",
"new",
"attribute",
"to",
"a",
"cache",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1815-L1823 | [
"def",
"_AddAttributeToCache",
"(",
"self",
",",
"attribute_name",
",",
"value",
",",
"cache",
")",
":",
"# If there's another value in cache with the same timestamp, the last added",
"# one takes precedence. This helps a lot in tests that use FakeTime.",
"attribute_list",
"=",
"cach... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.UpdateLease | Updates the lease and flushes the object.
The lease is set to expire after the "duration" time from the present
moment.
This method is supposed to be used when operation that requires locking
may run for a time that exceeds the lease time specified in OpenWithLock().
See flows/hunts locking for an ... | grr/server/grr_response_server/aff4.py | def UpdateLease(self, duration):
"""Updates the lease and flushes the object.
The lease is set to expire after the "duration" time from the present
moment.
This method is supposed to be used when operation that requires locking
may run for a time that exceeds the lease time specified in OpenWithLoc... | def UpdateLease(self, duration):
"""Updates the lease and flushes the object.
The lease is set to expire after the "duration" time from the present
moment.
This method is supposed to be used when operation that requires locking
may run for a time that exceeds the lease time specified in OpenWithLoc... | [
"Updates",
"the",
"lease",
"and",
"flushes",
"the",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1843-L1867 | [
"def",
"UpdateLease",
"(",
"self",
",",
"duration",
")",
":",
"if",
"not",
"self",
".",
"locked",
":",
"raise",
"LockError",
"(",
"\"Object must be locked to update the lease: %s.\"",
"%",
"self",
".",
"urn",
")",
"if",
"self",
".",
"CheckLease",
"(",
")",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.Flush | Syncs this object with the data store, maintaining object validity. | grr/server/grr_response_server/aff4.py | def Flush(self):
"""Syncs this object with the data store, maintaining object validity."""
if self.locked and self.CheckLease() == 0:
self._RaiseLockError("Flush")
self._WriteAttributes()
self._SyncAttributes()
if self.parent:
self.parent.Flush() | def Flush(self):
"""Syncs this object with the data store, maintaining object validity."""
if self.locked and self.CheckLease() == 0:
self._RaiseLockError("Flush")
self._WriteAttributes()
self._SyncAttributes()
if self.parent:
self.parent.Flush() | [
"Syncs",
"this",
"object",
"with",
"the",
"data",
"store",
"maintaining",
"object",
"validity",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1869-L1878 | [
"def",
"Flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
"and",
"self",
".",
"CheckLease",
"(",
")",
"==",
"0",
":",
"self",
".",
"_RaiseLockError",
"(",
"\"Flush\"",
")",
"self",
".",
"_WriteAttributes",
"(",
")",
"self",
".",
"_SyncAttribu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.Close | Close and destroy the object.
This is similar to Flush, but does not maintain object validity. Hence the
object should not be interacted with after Close().
Raises:
LockError: The lease for this object has expired. | grr/server/grr_response_server/aff4.py | def Close(self):
"""Close and destroy the object.
This is similar to Flush, but does not maintain object validity. Hence the
object should not be interacted with after Close().
Raises:
LockError: The lease for this object has expired.
"""
if self.locked and self.CheckLease() == 0:
... | def Close(self):
"""Close and destroy the object.
This is similar to Flush, but does not maintain object validity. Hence the
object should not be interacted with after Close().
Raises:
LockError: The lease for this object has expired.
"""
if self.locked and self.CheckLease() == 0:
... | [
"Close",
"and",
"destroy",
"the",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1880-L1903 | [
"def",
"Close",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
"and",
"self",
".",
"CheckLease",
"(",
")",
"==",
"0",
":",
"raise",
"LockError",
"(",
"\"Can not update lease that has already expired.\"",
")",
"self",
".",
"_WriteAttributes",
"(",
")",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object._WriteAttributes | Write the dirty attributes to the data store. | grr/server/grr_response_server/aff4.py | def _WriteAttributes(self):
"""Write the dirty attributes to the data store."""
# If the object is not opened for writing we do not need to flush it to the
# data_store.
if "w" not in self.mode:
return
if self.urn is None:
raise ValueError("Storing of anonymous AFF4 objects not supporte... | def _WriteAttributes(self):
"""Write the dirty attributes to the data store."""
# If the object is not opened for writing we do not need to flush it to the
# data_store.
if "w" not in self.mode:
return
if self.urn is None:
raise ValueError("Storing of anonymous AFF4 objects not supporte... | [
"Write",
"the",
"dirty",
"attributes",
"to",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1925-L1964 | [
"def",
"_WriteAttributes",
"(",
"self",
")",
":",
"# If the object is not opened for writing we do not need to flush it to the",
"# data_store.",
"if",
"\"w\"",
"not",
"in",
"self",
".",
"mode",
":",
"return",
"if",
"self",
".",
"urn",
"is",
"None",
":",
"raise",
"V... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object._SyncAttributes | Sync the new attributes to the synced attribute cache.
This maintains object validity. | grr/server/grr_response_server/aff4.py | def _SyncAttributes(self):
"""Sync the new attributes to the synced attribute cache.
This maintains object validity.
"""
# This effectively moves all the values from the new_attributes to the
# synced_attributes caches.
for attribute, value_array in iteritems(self.new_attributes):
if not ... | def _SyncAttributes(self):
"""Sync the new attributes to the synced attribute cache.
This maintains object validity.
"""
# This effectively moves all the values from the new_attributes to the
# synced_attributes caches.
for attribute, value_array in iteritems(self.new_attributes):
if not ... | [
"Sync",
"the",
"new",
"attributes",
"to",
"the",
"synced",
"attribute",
"cache",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1967-L1992 | [
"def",
"_SyncAttributes",
"(",
"self",
")",
":",
"# This effectively moves all the values from the new_attributes to the",
"# synced_attributes caches.",
"for",
"attribute",
",",
"value_array",
"in",
"iteritems",
"(",
"self",
".",
"new_attributes",
")",
":",
"if",
"not",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object._CheckAttribute | Check that the value is of the expected type.
Args:
attribute: An instance of Attribute().
value: An instance of RDFValue.
Raises:
ValueError: when the value is not of the expected type.
AttributeError: When the attribute is not of type Attribute(). | grr/server/grr_response_server/aff4.py | def _CheckAttribute(self, attribute, value):
"""Check that the value is of the expected type.
Args:
attribute: An instance of Attribute().
value: An instance of RDFValue.
Raises:
ValueError: when the value is not of the expected type.
AttributeError: When the attribute is not o... | def _CheckAttribute(self, attribute, value):
"""Check that the value is of the expected type.
Args:
attribute: An instance of Attribute().
value: An instance of RDFValue.
Raises:
ValueError: when the value is not of the expected type.
AttributeError: When the attribute is not o... | [
"Check",
"that",
"the",
"value",
"is",
"of",
"the",
"expected",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L1994-L2011 | [
"def",
"_CheckAttribute",
"(",
"self",
",",
"attribute",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"attribute",
",",
"Attribute",
")",
":",
"raise",
"AttributeError",
"(",
"\"Attribute %s must be of type aff4.Attribute()\"",
"%",
"attribute",
")",
"i... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.AddAttribute | Add an additional attribute to this object.
If value is None, attribute is expected to be already initialized with a
value. For example:
fd.AddAttribute(fd.Schema.CONTAINS("some data"))
Args:
attribute: The attribute name or an RDFValue derived from the attribute.
value: The value the a... | grr/server/grr_response_server/aff4.py | def AddAttribute(self, attribute, value=None, age=None):
"""Add an additional attribute to this object.
If value is None, attribute is expected to be already initialized with a
value. For example:
fd.AddAttribute(fd.Schema.CONTAINS("some data"))
Args:
attribute: The attribute name or an RD... | def AddAttribute(self, attribute, value=None, age=None):
"""Add an additional attribute to this object.
If value is None, attribute is expected to be already initialized with a
value. For example:
fd.AddAttribute(fd.Schema.CONTAINS("some data"))
Args:
attribute: The attribute name or an RD... | [
"Add",
"an",
"additional",
"attribute",
"to",
"this",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2035-L2084 | [
"def",
"AddAttribute",
"(",
"self",
",",
"attribute",
",",
"value",
"=",
"None",
",",
"age",
"=",
"None",
")",
":",
"if",
"\"w\"",
"not",
"in",
"self",
".",
"mode",
":",
"raise",
"IOError",
"(",
"\"Writing attribute %s to read only object.\"",
"%",
"attribut... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.DeleteAttribute | Clears the attribute from this object. | grr/server/grr_response_server/aff4.py | def DeleteAttribute(self, attribute):
"""Clears the attribute from this object."""
if "w" not in self.mode:
raise IOError("Deleting attribute %s from read only object." % attribute)
# Check if this object should be locked in order to delete the attribute.
# NOTE: We don't care about locking when ... | def DeleteAttribute(self, attribute):
"""Clears the attribute from this object."""
if "w" not in self.mode:
raise IOError("Deleting attribute %s from read only object." % attribute)
# Check if this object should be locked in order to delete the attribute.
# NOTE: We don't care about locking when ... | [
"Clears",
"the",
"attribute",
"from",
"this",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2087-L2108 | [
"def",
"DeleteAttribute",
"(",
"self",
",",
"attribute",
")",
":",
"if",
"\"w\"",
"not",
"in",
"self",
".",
"mode",
":",
"raise",
"IOError",
"(",
"\"Deleting attribute %s from read only object.\"",
"%",
"attribute",
")",
"# Check if this object should be locked in order... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.Get | Gets the attribute from this object. | grr/server/grr_response_server/aff4.py | def Get(self, attribute, default=None):
"""Gets the attribute from this object."""
if attribute is None:
return default
# Allow the user to specify the attribute by name.
elif isinstance(attribute, str):
attribute = Attribute.GetAttributeByName(attribute)
# We can't read attributes fro... | def Get(self, attribute, default=None):
"""Gets the attribute from this object."""
if attribute is None:
return default
# Allow the user to specify the attribute by name.
elif isinstance(attribute, str):
attribute = Attribute.GetAttributeByName(attribute)
# We can't read attributes fro... | [
"Gets",
"the",
"attribute",
"from",
"this",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2125-L2151 | [
"def",
"Get",
"(",
"self",
",",
"attribute",
",",
"default",
"=",
"None",
")",
":",
"if",
"attribute",
"is",
"None",
":",
"return",
"default",
"# Allow the user to specify the attribute by name.",
"elif",
"isinstance",
"(",
"attribute",
",",
"str",
")",
":",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.GetValuesForAttribute | Returns a list of values from this attribute. | grr/server/grr_response_server/aff4.py | def GetValuesForAttribute(self, attribute, only_one=False):
"""Returns a list of values from this attribute."""
if not only_one and self.age_policy == NEWEST_TIME:
raise ValueError("Attempting to read all attribute versions for an "
"object opened for NEWEST_TIME. This is probably "... | def GetValuesForAttribute(self, attribute, only_one=False):
"""Returns a list of values from this attribute."""
if not only_one and self.age_policy == NEWEST_TIME:
raise ValueError("Attempting to read all attribute versions for an "
"object opened for NEWEST_TIME. This is probably "... | [
"Returns",
"a",
"list",
"of",
"values",
"from",
"this",
"attribute",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2153-L2166 | [
"def",
"GetValuesForAttribute",
"(",
"self",
",",
"attribute",
",",
"only_one",
"=",
"False",
")",
":",
"if",
"not",
"only_one",
"and",
"self",
".",
"age_policy",
"==",
"NEWEST_TIME",
":",
"raise",
"ValueError",
"(",
"\"Attempting to read all attribute versions for ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.Upgrade | Upgrades this object to the type specified.
AFF4 Objects can be upgraded on the fly to other type - As long as the new
type is derived from the current type. This feature allows creation of
placeholder objects which can later be upgraded to the fully featured
object.
Note: It is not allowed to dow... | grr/server/grr_response_server/aff4.py | def Upgrade(self, aff4_class):
"""Upgrades this object to the type specified.
AFF4 Objects can be upgraded on the fly to other type - As long as the new
type is derived from the current type. This feature allows creation of
placeholder objects which can later be upgraded to the fully featured
objec... | def Upgrade(self, aff4_class):
"""Upgrades this object to the type specified.
AFF4 Objects can be upgraded on the fly to other type - As long as the new
type is derived from the current type. This feature allows creation of
placeholder objects which can later be upgraded to the fully featured
objec... | [
"Upgrades",
"this",
"object",
"to",
"the",
"type",
"specified",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2171-L2243 | [
"def",
"Upgrade",
"(",
"self",
",",
"aff4_class",
")",
":",
"_ValidateAFF4Type",
"(",
"aff4_class",
")",
"# We are already of the required type",
"if",
"self",
".",
"__class__",
"==",
"aff4_class",
":",
"return",
"self",
"# Check that we have the right type.",
"if",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.AddLabels | Add labels to the AFF4Object. | grr/server/grr_response_server/aff4.py | def AddLabels(self, labels_names, owner=None):
"""Add labels to the AFF4Object."""
if owner is None and not self.token:
raise ValueError("Can't set label: No owner specified and "
"no access token available.")
if isinstance(labels_names, string_types):
raise ValueError("La... | def AddLabels(self, labels_names, owner=None):
"""Add labels to the AFF4Object."""
if owner is None and not self.token:
raise ValueError("Can't set label: No owner specified and "
"no access token available.")
if isinstance(labels_names, string_types):
raise ValueError("La... | [
"Add",
"labels",
"to",
"the",
"AFF4Object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2286-L2302 | [
"def",
"AddLabels",
"(",
"self",
",",
"labels_names",
",",
"owner",
"=",
"None",
")",
":",
"if",
"owner",
"is",
"None",
"and",
"not",
"self",
".",
"token",
":",
"raise",
"ValueError",
"(",
"\"Can't set label: No owner specified and \"",
"\"no access token availabl... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Object.RemoveLabels | Remove specified labels from the AFF4Object. | grr/server/grr_response_server/aff4.py | def RemoveLabels(self, labels_names, owner=None):
"""Remove specified labels from the AFF4Object."""
if owner is None and not self.token:
raise ValueError("Can't remove label: No owner specified and "
"no access token available.")
if isinstance(labels_names, string_types):
... | def RemoveLabels(self, labels_names, owner=None):
"""Remove specified labels from the AFF4Object."""
if owner is None and not self.token:
raise ValueError("Can't remove label: No owner specified and "
"no access token available.")
if isinstance(labels_names, string_types):
... | [
"Remove",
"specified",
"labels",
"from",
"the",
"AFF4Object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2307-L2322 | [
"def",
"RemoveLabels",
"(",
"self",
",",
"labels_names",
",",
"owner",
"=",
"None",
")",
":",
"if",
"owner",
"is",
"None",
"and",
"not",
"self",
".",
"token",
":",
"raise",
"ValueError",
"(",
"\"Can't remove label: No owner specified and \"",
"\"no access token av... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AttributeExpression.SetAttribute | Checks that attribute is a valid Attribute() instance. | grr/server/grr_response_server/aff4.py | def SetAttribute(self, attribute):
"""Checks that attribute is a valid Attribute() instance."""
# Grab the attribute registered for this name
self.attribute = attribute
self.attribute_obj = Attribute.GetAttributeByName(attribute)
if self.attribute_obj is None:
raise lexer.ParseError("Attribute... | def SetAttribute(self, attribute):
"""Checks that attribute is a valid Attribute() instance."""
# Grab the attribute registered for this name
self.attribute = attribute
self.attribute_obj = Attribute.GetAttributeByName(attribute)
if self.attribute_obj is None:
raise lexer.ParseError("Attribute... | [
"Checks",
"that",
"attribute",
"is",
"a",
"valid",
"Attribute",
"()",
"instance",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2348-L2354 | [
"def",
"SetAttribute",
"(",
"self",
",",
"attribute",
")",
":",
"# Grab the attribute registered for this name",
"self",
".",
"attribute",
"=",
"attribute",
"self",
".",
"attribute_obj",
"=",
"Attribute",
".",
"GetAttributeByName",
"(",
"attribute",
")",
"if",
"self... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AttributeExpression.SetOperator | Sets the operator for this expression. | grr/server/grr_response_server/aff4.py | def SetOperator(self, operator):
"""Sets the operator for this expression."""
self.operator = operator
# Find the appropriate list of operators for this attribute
attribute_type = self.attribute_obj.GetRDFValueType()
operators = attribute_type.operators
# Do we have such an operator?
self.n... | def SetOperator(self, operator):
"""Sets the operator for this expression."""
self.operator = operator
# Find the appropriate list of operators for this attribute
attribute_type = self.attribute_obj.GetRDFValueType()
operators = attribute_type.operators
# Do we have such an operator?
self.n... | [
"Sets",
"the",
"operator",
"for",
"this",
"expression",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2356-L2371 | [
"def",
"SetOperator",
"(",
"self",
",",
"operator",
")",
":",
"self",
".",
"operator",
"=",
"operator",
"# Find the appropriate list of operators for this attribute",
"attribute_type",
"=",
"self",
".",
"attribute_obj",
".",
"GetRDFValueType",
"(",
")",
"operators",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AttributeExpression.Compile | Returns the data_store filter implementation from the attribute. | grr/server/grr_response_server/aff4.py | def Compile(self, filter_implemention):
"""Returns the data_store filter implementation from the attribute."""
return self.operator_method(self.attribute_obj, filter_implemention,
*self.args) | def Compile(self, filter_implemention):
"""Returns the data_store filter implementation from the attribute."""
return self.operator_method(self.attribute_obj, filter_implemention,
*self.args) | [
"Returns",
"the",
"data_store",
"filter",
"implementation",
"from",
"the",
"attribute",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2373-L2376 | [
"def",
"Compile",
"(",
"self",
",",
"filter_implemention",
")",
":",
"return",
"self",
".",
"operator_method",
"(",
"self",
".",
"attribute_obj",
",",
"filter_implemention",
",",
"*",
"self",
".",
"args",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Volume.ListChildren | Yields RDFURNs of all the children of this object.
Args:
limit: Total number of items we will attempt to retrieve.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range in microseconds.
Yields:
RDFURNs instances of each child. | grr/server/grr_response_server/aff4.py | def ListChildren(self, limit=None, age=NEWEST_TIME):
"""Yields RDFURNs of all the children of this object.
Args:
limit: Total number of items we will attempt to retrieve.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range in microseconds.
Yields:
... | def ListChildren(self, limit=None, age=NEWEST_TIME):
"""Yields RDFURNs of all the children of this object.
Args:
limit: Total number of items we will attempt to retrieve.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range in microseconds.
Yields:
... | [
"Yields",
"RDFURNs",
"of",
"all",
"the",
"children",
"of",
"this",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2393-L2409 | [
"def",
"ListChildren",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"# Just grab all the children from the index.",
"for",
"predicate",
",",
"timestamp",
"in",
"data_store",
".",
"DB",
".",
"AFF4FetchChildren",
"(",
"self",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Volume.OpenChildren | Yields AFF4 Objects of all our direct children.
This method efficiently returns all attributes for our children directly, in
a few data store round trips. We use the directory indexes to query the data
store.
Args:
children: A list of children RDFURNs to open. If None open all our
childr... | grr/server/grr_response_server/aff4.py | def OpenChildren(self,
children=None,
mode="r",
limit=None,
chunk_limit=100000,
age=NEWEST_TIME):
"""Yields AFF4 Objects of all our direct children.
This method efficiently returns all attributes for our children dir... | def OpenChildren(self,
children=None,
mode="r",
limit=None,
chunk_limit=100000,
age=NEWEST_TIME):
"""Yields AFF4 Objects of all our direct children.
This method efficiently returns all attributes for our children dir... | [
"Yields",
"AFF4",
"Objects",
"of",
"all",
"our",
"direct",
"children",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2411-L2452 | [
"def",
"OpenChildren",
"(",
"self",
",",
"children",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
",",
"limit",
"=",
"None",
",",
"chunk_limit",
"=",
"100000",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"if",
"children",
"is",
"None",
":",
"# No age passed her... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Volume.real_pathspec | Returns a pathspec for an aff4 object even if there is none stored. | grr/server/grr_response_server/aff4.py | def real_pathspec(self):
"""Returns a pathspec for an aff4 object even if there is none stored."""
pathspec = self.Get(self.Schema.PATHSPEC)
stripped_components = []
parent = self
# TODO(user): this code is potentially slow due to multiple separate
# aff4.FACTORY.Open() calls. OTOH the loop be... | def real_pathspec(self):
"""Returns a pathspec for an aff4 object even if there is none stored."""
pathspec = self.Get(self.Schema.PATHSPEC)
stripped_components = []
parent = self
# TODO(user): this code is potentially slow due to multiple separate
# aff4.FACTORY.Open() calls. OTOH the loop be... | [
"Returns",
"a",
"pathspec",
"for",
"an",
"aff4",
"object",
"even",
"if",
"there",
"is",
"none",
"stored",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2455-L2485 | [
"def",
"real_pathspec",
"(",
"self",
")",
":",
"pathspec",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"PATHSPEC",
")",
"stripped_components",
"=",
"[",
"]",
"parent",
"=",
"self",
"# TODO(user): this code is potentially slow due to multiple separate",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Stream._MultiStream | Method overriden by subclasses to optimize the MultiStream behavior. | grr/server/grr_response_server/aff4.py | def _MultiStream(cls, fds):
"""Method overriden by subclasses to optimize the MultiStream behavior."""
for fd in fds:
fd.Seek(0)
while True:
chunk = fd.Read(cls.MULTI_STREAM_CHUNK_SIZE)
if not chunk:
break
yield fd, chunk, None | def _MultiStream(cls, fds):
"""Method overriden by subclasses to optimize the MultiStream behavior."""
for fd in fds:
fd.Seek(0)
while True:
chunk = fd.Read(cls.MULTI_STREAM_CHUNK_SIZE)
if not chunk:
break
yield fd, chunk, None | [
"Method",
"overriden",
"by",
"subclasses",
"to",
"optimize",
"the",
"MultiStream",
"behavior",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2553-L2561 | [
"def",
"_MultiStream",
"(",
"cls",
",",
"fds",
")",
":",
"for",
"fd",
"in",
"fds",
":",
"fd",
".",
"Seek",
"(",
"0",
")",
"while",
"True",
":",
"chunk",
"=",
"fd",
".",
"Read",
"(",
"cls",
".",
"MULTI_STREAM_CHUNK_SIZE",
")",
"if",
"not",
"chunk",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4Stream.MultiStream | Effectively streams data from multiple opened AFF4Stream objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd) where chunk is a binary blob of data and fd is an
object from the fds argument. Chunks within one file are not shuffled:
... | grr/server/grr_response_server/aff4.py | def MultiStream(cls, fds):
"""Effectively streams data from multiple opened AFF4Stream objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd) where chunk is a binary blob of data and fd is an
object from the fds argument. Chunks wi... | def MultiStream(cls, fds):
"""Effectively streams data from multiple opened AFF4Stream objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd) where chunk is a binary blob of data and fd is an
object from the fds argument. Chunks wi... | [
"Effectively",
"streams",
"data",
"from",
"multiple",
"opened",
"AFF4Stream",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2564-L2601 | [
"def",
"MultiStream",
"(",
"cls",
",",
"fds",
")",
":",
"for",
"fd",
"in",
"fds",
":",
"if",
"not",
"isinstance",
"(",
"fd",
",",
"AFF4Stream",
")",
":",
"raise",
"ValueError",
"(",
"\"All object to be streamed have to inherit from \"",
"\"AFF4Stream (found one in... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4MemoryStreamBase.Initialize | Try to load the data from the store. | grr/server/grr_response_server/aff4.py | def Initialize(self):
"""Try to load the data from the store."""
super(AFF4MemoryStreamBase, self).Initialize()
contents = b""
if "r" in self.mode:
contents = self.Get(self.Schema.CONTENT).AsBytes()
try:
if contents is not None:
contents = zlib.decompress(contents)
e... | def Initialize(self):
"""Try to load the data from the store."""
super(AFF4MemoryStreamBase, self).Initialize()
contents = b""
if "r" in self.mode:
contents = self.Get(self.Schema.CONTENT).AsBytes()
try:
if contents is not None:
contents = zlib.decompress(contents)
e... | [
"Try",
"to",
"load",
"the",
"data",
"from",
"the",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2657-L2672 | [
"def",
"Initialize",
"(",
"self",
")",
":",
"super",
"(",
"AFF4MemoryStreamBase",
",",
"self",
")",
".",
"Initialize",
"(",
")",
"contents",
"=",
"b\"\"",
"if",
"\"r\"",
"in",
"self",
".",
"mode",
":",
"contents",
"=",
"self",
".",
"Get",
"(",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4MemoryStreamBase.OverwriteAndClose | Directly overwrite the current contents.
Replaces the data currently in the stream with compressed_data,
and closes the object. Makes it possible to avoid recompressing
the data.
Args:
compressed_data: The data to write, must be zlib compressed.
size: The uncompressed size of the data. | grr/server/grr_response_server/aff4.py | def OverwriteAndClose(self, compressed_data, size):
"""Directly overwrite the current contents.
Replaces the data currently in the stream with compressed_data,
and closes the object. Makes it possible to avoid recompressing
the data.
Args:
compressed_data: The data to write, must be zlib comp... | def OverwriteAndClose(self, compressed_data, size):
"""Directly overwrite the current contents.
Replaces the data currently in the stream with compressed_data,
and closes the object. Makes it possible to avoid recompressing
the data.
Args:
compressed_data: The data to write, must be zlib comp... | [
"Directly",
"overwrite",
"the",
"current",
"contents",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2713-L2725 | [
"def",
"OverwriteAndClose",
"(",
"self",
",",
"compressed_data",
",",
"size",
")",
":",
"self",
".",
"Set",
"(",
"self",
".",
"Schema",
".",
"CONTENT",
"(",
"compressed_data",
")",
")",
"self",
".",
"Set",
"(",
"self",
".",
"Schema",
".",
"SIZE",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase._MultiStream | Effectively streams data from multiple opened AFF4ImageBase objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argument.
If one or more chunks ... | grr/server/grr_response_server/aff4.py | def _MultiStream(cls, fds):
"""Effectively streams data from multiple opened AFF4ImageBase objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argu... | def _MultiStream(cls, fds):
"""Effectively streams data from multiple opened AFF4ImageBase objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argu... | [
"Effectively",
"streams",
"data",
"from",
"multiple",
"opened",
"AFF4ImageBase",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2819-L2861 | [
"def",
"_MultiStream",
"(",
"cls",
",",
"fds",
")",
":",
"missing_chunks_by_fd",
"=",
"{",
"}",
"for",
"chunk_fd_pairs",
"in",
"collection",
".",
"Batch",
"(",
"cls",
".",
"_GenerateChunkPaths",
"(",
"fds",
")",
",",
"cls",
".",
"MULTI_STREAM_CHUNKS_READ_AHEAD... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase.Initialize | Build a cache for our chunks. | grr/server/grr_response_server/aff4.py | def Initialize(self):
"""Build a cache for our chunks."""
super(AFF4ImageBase, self).Initialize()
self.offset = 0
# A cache for segments.
self.chunk_cache = ChunkCache(self._WriteChunk, 100)
if "r" in self.mode:
self.size = int(self.Get(self.Schema.SIZE))
# pylint: disable=protected... | def Initialize(self):
"""Build a cache for our chunks."""
super(AFF4ImageBase, self).Initialize()
self.offset = 0
# A cache for segments.
self.chunk_cache = ChunkCache(self._WriteChunk, 100)
if "r" in self.mode:
self.size = int(self.Get(self.Schema.SIZE))
# pylint: disable=protected... | [
"Build",
"a",
"cache",
"for",
"our",
"chunks",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2863-L2878 | [
"def",
"Initialize",
"(",
"self",
")",
":",
"super",
"(",
"AFF4ImageBase",
",",
"self",
")",
".",
"Initialize",
"(",
")",
"self",
".",
"offset",
"=",
"0",
"# A cache for segments.",
"self",
".",
"chunk_cache",
"=",
"ChunkCache",
"(",
"self",
".",
"_WriteCh... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase._ReadPartial | Read as much as possible, but not more than length. | grr/server/grr_response_server/aff4.py | def _ReadPartial(self, length):
"""Read as much as possible, but not more than length."""
chunk = self.offset // self.chunksize
chunk_offset = self.offset % self.chunksize
available_to_read = min(length, self.chunksize - chunk_offset)
retries = 0
while retries < self.NUM_RETRIES:
fd = se... | def _ReadPartial(self, length):
"""Read as much as possible, but not more than length."""
chunk = self.offset // self.chunksize
chunk_offset = self.offset % self.chunksize
available_to_read = min(length, self.chunksize - chunk_offset)
retries = 0
while retries < self.NUM_RETRIES:
fd = se... | [
"Read",
"as",
"much",
"as",
"possible",
"but",
"not",
"more",
"than",
"length",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2981-L3008 | [
"def",
"_ReadPartial",
"(",
"self",
",",
"length",
")",
":",
"chunk",
"=",
"self",
".",
"offset",
"//",
"self",
".",
"chunksize",
"chunk_offset",
"=",
"self",
".",
"offset",
"%",
"self",
".",
"chunksize",
"available_to_read",
"=",
"min",
"(",
"length",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase.Read | Read a block of data from the file. | grr/server/grr_response_server/aff4.py | def Read(self, length):
"""Read a block of data from the file."""
result = b""
# The total available size in the file
length = int(length)
length = min(length, self.size - self.offset)
while length > 0:
data = self._ReadPartial(length)
if not data:
break
length -= le... | def Read(self, length):
"""Read a block of data from the file."""
result = b""
# The total available size in the file
length = int(length)
length = min(length, self.size - self.offset)
while length > 0:
data = self._ReadPartial(length)
if not data:
break
length -= le... | [
"Read",
"a",
"block",
"of",
"data",
"from",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L3010-L3025 | [
"def",
"Read",
"(",
"self",
",",
"length",
")",
":",
"result",
"=",
"b\"\"",
"# The total available size in the file",
"length",
"=",
"int",
"(",
"length",
")",
"length",
"=",
"min",
"(",
"length",
",",
"self",
".",
"size",
"-",
"self",
".",
"offset",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase._WritePartial | Writes at most one chunk of data. | grr/server/grr_response_server/aff4.py | def _WritePartial(self, data):
"""Writes at most one chunk of data."""
chunk = self.offset // self.chunksize
chunk_offset = self.offset % self.chunksize
data = utils.SmartStr(data)
available_to_write = min(len(data), self.chunksize - chunk_offset)
fd = self._GetChunkForWriting(chunk)
fd.s... | def _WritePartial(self, data):
"""Writes at most one chunk of data."""
chunk = self.offset // self.chunksize
chunk_offset = self.offset % self.chunksize
data = utils.SmartStr(data)
available_to_write = min(len(data), self.chunksize - chunk_offset)
fd = self._GetChunkForWriting(chunk)
fd.s... | [
"Writes",
"at",
"most",
"one",
"chunk",
"of",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L3027-L3042 | [
"def",
"_WritePartial",
"(",
"self",
",",
"data",
")",
":",
"chunk",
"=",
"self",
".",
"offset",
"//",
"self",
".",
"chunksize",
"chunk_offset",
"=",
"self",
".",
"offset",
"%",
"self",
".",
"chunksize",
"data",
"=",
"utils",
".",
"SmartStr",
"(",
"dat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AFF4ImageBase.Flush | Sync the chunk cache to storage. | grr/server/grr_response_server/aff4.py | def Flush(self):
"""Sync the chunk cache to storage."""
if self._dirty:
self.Set(self.Schema.SIZE(self.size))
if self.content_last is not None:
self.Set(self.Schema.CONTENT_LAST, self.content_last)
# Flushing the cache will write all chunks to the blob store.
self.chunk_cache.Flush(... | def Flush(self):
"""Sync the chunk cache to storage."""
if self._dirty:
self.Set(self.Schema.SIZE(self.size))
if self.content_last is not None:
self.Set(self.Schema.CONTENT_LAST, self.content_last)
# Flushing the cache will write all chunks to the blob store.
self.chunk_cache.Flush(... | [
"Sync",
"the",
"chunk",
"cache",
"to",
"storage",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L3054-L3063 | [
"def",
"Flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirty",
":",
"self",
".",
"Set",
"(",
"self",
".",
"Schema",
".",
"SIZE",
"(",
"self",
".",
"size",
")",
")",
"if",
"self",
".",
"content_last",
"is",
"not",
"None",
":",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValueConverter.Encode | Encode the value for the attribute. | grr/server/grr_response_server/aff4.py | def Encode(self, attribute, value):
"""Encode the value for the attribute."""
required_type = self._attribute_types.get(attribute, "bytes")
if required_type == "integer":
return rdf_structs.SignedVarintEncode(int(value))
elif required_type == "unsigned_integer":
return rdf_structs.VarintEnc... | def Encode(self, attribute, value):
"""Encode the value for the attribute."""
required_type = self._attribute_types.get(attribute, "bytes")
if required_type == "integer":
return rdf_structs.SignedVarintEncode(int(value))
elif required_type == "unsigned_integer":
return rdf_structs.VarintEnc... | [
"Encode",
"the",
"value",
"for",
"the",
"attribute",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L3120-L3135 | [
"def",
"Encode",
"(",
"self",
",",
"attribute",
",",
"value",
")",
":",
"required_type",
"=",
"self",
".",
"_attribute_types",
".",
"get",
"(",
"attribute",
",",
"\"bytes\"",
")",
"if",
"required_type",
"==",
"\"integer\"",
":",
"return",
"rdf_structs",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValueConverter.Decode | Decode the value to the required type. | grr/server/grr_response_server/aff4.py | def Decode(self, attribute, value):
"""Decode the value to the required type."""
required_type = self._attribute_types.get(attribute, "bytes")
if required_type == "integer":
return rdf_structs.SignedVarintReader(value, 0)[0]
elif required_type == "unsigned_integer":
return rdf_structs.Varint... | def Decode(self, attribute, value):
"""Decode the value to the required type."""
required_type = self._attribute_types.get(attribute, "bytes")
if required_type == "integer":
return rdf_structs.SignedVarintReader(value, 0)[0]
elif required_type == "unsigned_integer":
return rdf_structs.Varint... | [
"Decode",
"the",
"value",
"to",
"the",
"required",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L3137-L3150 | [
"def",
"Decode",
"(",
"self",
",",
"attribute",
",",
"value",
")",
":",
"required_type",
"=",
"self",
".",
"_attribute_types",
".",
"get",
"(",
"attribute",
",",
"\"bytes\"",
")",
"if",
"required_type",
"==",
"\"integer\"",
":",
"return",
"rdf_structs",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CleanHuntsMixin.CleanAff4Hunts | Cleans up old hunt data from aff4. | grr/server/grr_response_server/flows/cron/data_retention.py | def CleanAff4Hunts(self):
"""Cleans up old hunt data from aff4."""
hunts_ttl = config.CONFIG["DataRetention.hunts_ttl"]
if not hunts_ttl:
self.Log("TTL not set - nothing to do...")
return
exception_label = config.CONFIG["DataRetention.hunts_ttl_exception_label"]
hunts_root = aff4.FACT... | def CleanAff4Hunts(self):
"""Cleans up old hunt data from aff4."""
hunts_ttl = config.CONFIG["DataRetention.hunts_ttl"]
if not hunts_ttl:
self.Log("TTL not set - nothing to do...")
return
exception_label = config.CONFIG["DataRetention.hunts_ttl_exception_label"]
hunts_root = aff4.FACT... | [
"Cleans",
"up",
"old",
"hunt",
"data",
"from",
"aff4",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/data_retention.py#L22-L50 | [
"def",
"CleanAff4Hunts",
"(",
"self",
")",
":",
"hunts_ttl",
"=",
"config",
".",
"CONFIG",
"[",
"\"DataRetention.hunts_ttl\"",
"]",
"if",
"not",
"hunts_ttl",
":",
"self",
".",
"Log",
"(",
"\"TTL not set - nothing to do...\"",
")",
"return",
"exception_label",
"=",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CleanCronJobs.Start | Cleans up old cron job data. | grr/server/grr_response_server/flows/cron/data_retention.py | def Start(self):
"""Cleans up old cron job data."""
cron_jobs_ttl = config.CONFIG["DataRetention.cron_jobs_flows_ttl"]
if not cron_jobs_ttl:
self.Log("TTL not set - nothing to do...")
return
manager = aff4_cronjobs.GetCronManager()
cutoff_timestamp = rdfvalue.RDFDatetime.Now() - cron_jo... | def Start(self):
"""Cleans up old cron job data."""
cron_jobs_ttl = config.CONFIG["DataRetention.cron_jobs_flows_ttl"]
if not cron_jobs_ttl:
self.Log("TTL not set - nothing to do...")
return
manager = aff4_cronjobs.GetCronManager()
cutoff_timestamp = rdfvalue.RDFDatetime.Now() - cron_jo... | [
"Cleans",
"up",
"old",
"cron",
"job",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/data_retention.py#L87-L106 | [
"def",
"Start",
"(",
"self",
")",
":",
"cron_jobs_ttl",
"=",
"config",
".",
"CONFIG",
"[",
"\"DataRetention.cron_jobs_flows_ttl\"",
"]",
"if",
"not",
"cron_jobs_ttl",
":",
"self",
".",
"Log",
"(",
"\"TTL not set - nothing to do...\"",
")",
"return",
"manager",
"="... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CleanInactiveClientsMixin.CleanAff4Clients | Cleans up old client data from aff4. | grr/server/grr_response_server/flows/cron/data_retention.py | def CleanAff4Clients(self):
"""Cleans up old client data from aff4."""
inactive_client_ttl = config.CONFIG["DataRetention.inactive_client_ttl"]
if not inactive_client_ttl:
self.Log("TTL not set - nothing to do...")
return
exception_label = config.CONFIG[
"DataRetention.inactive_cli... | def CleanAff4Clients(self):
"""Cleans up old client data from aff4."""
inactive_client_ttl = config.CONFIG["DataRetention.inactive_client_ttl"]
if not inactive_client_ttl:
self.Log("TTL not set - nothing to do...")
return
exception_label = config.CONFIG[
"DataRetention.inactive_cli... | [
"Cleans",
"up",
"old",
"client",
"data",
"from",
"aff4",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/cron/data_retention.py#L137-L172 | [
"def",
"CleanAff4Clients",
"(",
"self",
")",
":",
"inactive_client_ttl",
"=",
"config",
".",
"CONFIG",
"[",
"\"DataRetention.inactive_client_ttl\"",
"]",
"if",
"not",
"inactive_client_ttl",
":",
"self",
".",
"Log",
"(",
"\"TTL not set - nothing to do...\"",
")",
"retu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValidateToken | Does basic token validation.
Args:
token: User's credentials as access_control.ACLToken.
targets: List of targets that were meant to be accessed by the token. This
is used for logging purposes only.
Returns:
True if token is valid.
Raises:
access_control.UnauthorizedAccess: if token is no... | grr/server/grr_response_server/aff4_objects/user_managers.py | def ValidateToken(token, targets):
"""Does basic token validation.
Args:
token: User's credentials as access_control.ACLToken.
targets: List of targets that were meant to be accessed by the token. This
is used for logging purposes only.
Returns:
True if token is valid.
Raises:
access_co... | def ValidateToken(token, targets):
"""Does basic token validation.
Args:
token: User's credentials as access_control.ACLToken.
targets: List of targets that were meant to be accessed by the token. This
is used for logging purposes only.
Returns:
True if token is valid.
Raises:
access_co... | [
"Does",
"basic",
"token",
"validation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L82-L119 | [
"def",
"ValidateToken",
"(",
"token",
",",
"targets",
")",
":",
"def",
"GetSubjectForError",
"(",
")",
":",
"if",
"len",
"(",
"targets",
")",
"==",
"1",
":",
"return",
"list",
"(",
"targets",
")",
"[",
"0",
"]",
"else",
":",
"return",
"None",
"# All ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValidateAccessAndSubjects | Does basic requested access validation.
Args:
requested_access: String consisting or 'r', 'w' and 'q' characters.
subjects: A list of subjects that are about to be accessed with a given
requested_access. Used for logging purposes only.
Returns:
True if requested_access is valid.
Raises:
a... | grr/server/grr_response_server/aff4_objects/user_managers.py | def ValidateAccessAndSubjects(requested_access, subjects):
"""Does basic requested access validation.
Args:
requested_access: String consisting or 'r', 'w' and 'q' characters.
subjects: A list of subjects that are about to be accessed with a given
requested_access. Used for logging purposes only.
... | def ValidateAccessAndSubjects(requested_access, subjects):
"""Does basic requested access validation.
Args:
requested_access: String consisting or 'r', 'w' and 'q' characters.
subjects: A list of subjects that are about to be accessed with a given
requested_access. Used for logging purposes only.
... | [
"Does",
"basic",
"requested",
"access",
"validation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L122-L153 | [
"def",
"ValidateAccessAndSubjects",
"(",
"requested_access",
",",
"subjects",
")",
":",
"if",
"not",
"requested_access",
":",
"raise",
"access_control",
".",
"UnauthorizedAccess",
"(",
"\"Must specify requested access type for %s\"",
"%",
"subjects",
")",
"for",
"s",
"i... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckUserForLabels | Verify that the username has all the authorized_labels set. | grr/server/grr_response_server/aff4_objects/user_managers.py | def CheckUserForLabels(username, authorized_labels, token=None):
"""Verify that the username has all the authorized_labels set."""
authorized_labels = set(authorized_labels)
try:
user = aff4.FACTORY.Open(
"aff4:/users/%s" % username, aff4_type=aff4_users.GRRUser, token=token)
# Only return if al... | def CheckUserForLabels(username, authorized_labels, token=None):
"""Verify that the username has all the authorized_labels set."""
authorized_labels = set(authorized_labels)
try:
user = aff4.FACTORY.Open(
"aff4:/users/%s" % username, aff4_type=aff4_users.GRRUser, token=token)
# Only return if al... | [
"Verify",
"that",
"the",
"username",
"has",
"all",
"the",
"authorized_labels",
"set",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L156-L174 | [
"def",
"CheckUserForLabels",
"(",
"username",
",",
"authorized_labels",
",",
"token",
"=",
"None",
")",
":",
"authorized_labels",
"=",
"set",
"(",
"authorized_labels",
")",
"try",
":",
"user",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"\"aff4:/users/%s\""... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckFlowCanBeStartedOnClient | Checks if flow can be started on a particular client.
Only flows with a category can bestarted. Having a category means that the
flow will be accessible from the UI.
Args:
flow_name: Name of the flow to check access for.
Returns:
True if flow is externally accessible.
Raises:
access_control.Una... | grr/server/grr_response_server/aff4_objects/user_managers.py | def CheckFlowCanBeStartedOnClient(flow_name):
"""Checks if flow can be started on a particular client.
Only flows with a category can bestarted. Having a category means that the
flow will be accessible from the UI.
Args:
flow_name: Name of the flow to check access for.
Returns:
True if flow is exte... | def CheckFlowCanBeStartedOnClient(flow_name):
"""Checks if flow can be started on a particular client.
Only flows with a category can bestarted. Having a category means that the
flow will be accessible from the UI.
Args:
flow_name: Name of the flow to check access for.
Returns:
True if flow is exte... | [
"Checks",
"if",
"flow",
"can",
"be",
"started",
"on",
"a",
"particular",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L177-L197 | [
"def",
"CheckFlowCanBeStartedOnClient",
"(",
"flow_name",
")",
":",
"flow_cls",
"=",
"flow",
".",
"GRRFlow",
".",
"GetPlugin",
"(",
"flow_name",
")",
"if",
"flow_cls",
".",
"category",
":",
"return",
"True",
"else",
":",
"raise",
"access_control",
".",
"Unauth... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckAccessHelper.Allow | Checks if given path pattern fits the subject passed in constructor.
Registers "allow" check in this helper. "Allow" check consists of
fnmatch path pattern and optional "require" check. *args and *kwargs will
be passed to the optional "require" check function.
All registered "allow" checks are execute... | grr/server/grr_response_server/aff4_objects/user_managers.py | def Allow(self, path, require=None, *args, **kwargs):
"""Checks if given path pattern fits the subject passed in constructor.
Registers "allow" check in this helper. "Allow" check consists of
fnmatch path pattern and optional "require" check. *args and *kwargs will
be passed to the optional "require" c... | def Allow(self, path, require=None, *args, **kwargs):
"""Checks if given path pattern fits the subject passed in constructor.
Registers "allow" check in this helper. "Allow" check consists of
fnmatch path pattern and optional "require" check. *args and *kwargs will
be passed to the optional "require" c... | [
"Checks",
"if",
"given",
"path",
"pattern",
"fits",
"the",
"subject",
"passed",
"in",
"constructor",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L212-L245 | [
"def",
"Allow",
"(",
"self",
",",
"path",
",",
"require",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"regex_text",
"=",
"fnmatch",
".",
"translate",
"(",
"path",
")",
"regex",
"=",
"re",
".",
"compile",
"(",
"regex_text",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckAccessHelper.CheckAccess | Checks for access to given subject with a given token.
CheckAccess runs given subject through all "allow" clauses that
were previously registered with Allow() calls. It returns True on
first match and raises access_control.UnauthorizedAccess if there
are no matches or if any of the additional checks fa... | grr/server/grr_response_server/aff4_objects/user_managers.py | def CheckAccess(self, subject, token):
"""Checks for access to given subject with a given token.
CheckAccess runs given subject through all "allow" clauses that
were previously registered with Allow() calls. It returns True on
first match and raises access_control.UnauthorizedAccess if there
are no... | def CheckAccess(self, subject, token):
"""Checks for access to given subject with a given token.
CheckAccess runs given subject through all "allow" clauses that
were previously registered with Allow() calls. It returns True on
first match and raises access_control.UnauthorizedAccess if there
are no... | [
"Checks",
"for",
"access",
"to",
"given",
"subject",
"with",
"a",
"given",
"token",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L247-L291 | [
"def",
"CheckAccess",
"(",
"self",
",",
"subject",
",",
"token",
")",
":",
"subject",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"subject",
")",
"subject_str",
"=",
"subject",
".",
"SerializeToString",
"(",
")",
"for",
"check_tuple",
"in",
"self",
".",
"checks",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FullAccessControlManager._HasAccessToClient | Checks if user has access to a client under given URN. | grr/server/grr_response_server/aff4_objects/user_managers.py | def _HasAccessToClient(self, subject, token):
"""Checks if user has access to a client under given URN."""
client_id, _ = rdfvalue.RDFURN(subject).Split(2)
client_urn = rdf_client.ClientURN(client_id)
return self.CheckClientAccess(token, client_urn) | def _HasAccessToClient(self, subject, token):
"""Checks if user has access to a client under given URN."""
client_id, _ = rdfvalue.RDFURN(subject).Split(2)
client_urn = rdf_client.ClientURN(client_id)
return self.CheckClientAccess(token, client_urn) | [
"Checks",
"if",
"user",
"has",
"access",
"to",
"a",
"client",
"under",
"given",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L318-L323 | [
"def",
"_HasAccessToClient",
"(",
"self",
",",
"subject",
",",
"token",
")",
":",
"client_id",
",",
"_",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"subject",
")",
".",
"Split",
"(",
"2",
")",
"client_urn",
"=",
"rdf_client",
".",
"ClientURN",
"(",
"client_id"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FullAccessControlManager._IsHomeDir | Checks user access permissions for paths under aff4:/users. | grr/server/grr_response_server/aff4_objects/user_managers.py | def _IsHomeDir(self, subject, token):
"""Checks user access permissions for paths under aff4:/users."""
h = CheckAccessHelper("IsHomeDir")
h.Allow("aff4:/users/%s" % token.username)
h.Allow("aff4:/users/%s/*" % token.username)
try:
return h.CheckAccess(subject, token)
except access_control... | def _IsHomeDir(self, subject, token):
"""Checks user access permissions for paths under aff4:/users."""
h = CheckAccessHelper("IsHomeDir")
h.Allow("aff4:/users/%s" % token.username)
h.Allow("aff4:/users/%s/*" % token.username)
try:
return h.CheckAccess(subject, token)
except access_control... | [
"Checks",
"user",
"access",
"permissions",
"for",
"paths",
"under",
"aff4",
":",
"/",
"users",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L329-L339 | [
"def",
"_IsHomeDir",
"(",
"self",
",",
"subject",
",",
"token",
")",
":",
"h",
"=",
"CheckAccessHelper",
"(",
"\"IsHomeDir\"",
")",
"h",
".",
"Allow",
"(",
"\"aff4:/users/%s\"",
"%",
"token",
".",
"username",
")",
"h",
".",
"Allow",
"(",
"\"aff4:/users/%s/... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FullAccessControlManager._CreateReadAccessHelper | Creates a CheckAccessHelper for controlling read access.
This function and _CreateQueryAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Read access gives you the ability to open and read aff4 objects for which
you already ha... | grr/server/grr_response_server/aff4_objects/user_managers.py | def _CreateReadAccessHelper(self):
"""Creates a CheckAccessHelper for controlling read access.
This function and _CreateQueryAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Read access gives you the ability to open and read... | def _CreateReadAccessHelper(self):
"""Creates a CheckAccessHelper for controlling read access.
This function and _CreateQueryAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Read access gives you the ability to open and read... | [
"Creates",
"a",
"CheckAccessHelper",
"for",
"controlling",
"read",
"access",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L351-L444 | [
"def",
"_CreateReadAccessHelper",
"(",
"self",
")",
":",
"h",
"=",
"CheckAccessHelper",
"(",
"\"read\"",
")",
"h",
".",
"Allow",
"(",
"\"aff4:/\"",
")",
"# In order to open directories below aff4:/users, we have to have access to",
"# aff4:/users directory itself.",
"h",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FullAccessControlManager._CreateQueryAccessHelper | Creates a CheckAccessHelper for controlling query access.
This function and _CreateReadAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Query access gives you the ability to find objects in the tree without
knowing their URN... | grr/server/grr_response_server/aff4_objects/user_managers.py | def _CreateQueryAccessHelper(self):
"""Creates a CheckAccessHelper for controlling query access.
This function and _CreateReadAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Query access gives you the ability to find object... | def _CreateQueryAccessHelper(self):
"""Creates a CheckAccessHelper for controlling query access.
This function and _CreateReadAccessHelper essentially define GRR's ACL
policy. Please refer to these 2 functions to either review or modify
GRR's ACLs.
Query access gives you the ability to find object... | [
"Creates",
"a",
"CheckAccessHelper",
"for",
"controlling",
"query",
"access",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L446-L522 | [
"def",
"_CreateQueryAccessHelper",
"(",
"self",
")",
":",
"h",
"=",
"CheckAccessHelper",
"(",
"\"query\"",
")",
"# User is allowed to do anything in their home dir.",
"h",
".",
"Allow",
"(",
"\"aff4:/users/*\"",
",",
"self",
".",
"_IsHomeDir",
")",
"# Querying is allowe... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FullAccessControlManager.CheckDataStoreAccess | Allow all access if token and requested access are valid. | grr/server/grr_response_server/aff4_objects/user_managers.py | def CheckDataStoreAccess(self, token, subjects, requested_access="r"):
"""Allow all access if token and requested access are valid."""
if any(not x for x in subjects):
raise ValueError("Subjects list can't contain empty URNs.")
subjects = list(map(rdfvalue.RDFURN, subjects))
return (ValidateAcces... | def CheckDataStoreAccess(self, token, subjects, requested_access="r"):
"""Allow all access if token and requested access are valid."""
if any(not x for x in subjects):
raise ValueError("Subjects list can't contain empty URNs.")
subjects = list(map(rdfvalue.RDFURN, subjects))
return (ValidateAcces... | [
"Allow",
"all",
"access",
"if",
"token",
"and",
"requested",
"access",
"are",
"valid",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/user_managers.py#L609-L618 | [
"def",
"CheckDataStoreAccess",
"(",
"self",
",",
"token",
",",
"subjects",
",",
"requested_access",
"=",
"\"r\"",
")",
":",
"if",
"any",
"(",
"not",
"x",
"for",
"x",
"in",
"subjects",
")",
":",
"raise",
"ValueError",
"(",
"\"Subjects list can't contain empty U... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Streamer.StreamFile | Streams chunks of a given file starting at given offset.
Args:
filedesc: A `file` object to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to read.
Returns:
Generator over `Chunk` instances. | grr/client/grr_response_client/streaming.py | def StreamFile(self, filedesc, offset=0, amount=None):
"""Streams chunks of a given file starting at given offset.
Args:
filedesc: A `file` object to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to read.
Returns:
... | def StreamFile(self, filedesc, offset=0, amount=None):
"""Streams chunks of a given file starting at given offset.
Args:
filedesc: A `file` object to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to read.
Returns:
... | [
"Streams",
"chunks",
"of",
"a",
"given",
"file",
"starting",
"at",
"given",
"offset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/streaming.py#L34-L46 | [
"def",
"StreamFile",
"(",
"self",
",",
"filedesc",
",",
"offset",
"=",
"0",
",",
"amount",
"=",
"None",
")",
":",
"reader",
"=",
"FileReader",
"(",
"filedesc",
",",
"offset",
"=",
"offset",
")",
"return",
"self",
".",
"Stream",
"(",
"reader",
",",
"a... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Streamer.StreamFilePath | Streams chunks of a file located at given path starting at given offset.
Args:
filepath: A path to the file to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to read.
Yields:
`Chunk` instances. | grr/client/grr_response_client/streaming.py | def StreamFilePath(self, filepath, offset=0, amount=None):
"""Streams chunks of a file located at given path starting at given offset.
Args:
filepath: A path to the file to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to... | def StreamFilePath(self, filepath, offset=0, amount=None):
"""Streams chunks of a file located at given path starting at given offset.
Args:
filepath: A path to the file to stream.
offset: An integer offset at which the file stream should start on.
amount: An upper bound on number of bytes to... | [
"Streams",
"chunks",
"of",
"a",
"file",
"located",
"at",
"given",
"path",
"starting",
"at",
"given",
"offset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/streaming.py#L48-L61 | [
"def",
"StreamFilePath",
"(",
"self",
",",
"filepath",
",",
"offset",
"=",
"0",
",",
"amount",
"=",
"None",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"\"rb\"",
")",
"as",
"filedesc",
":",
"for",
"chunk",
"in",
"self",
".",
"StreamFile",
"(",
"f... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Streamer.StreamMemory | Streams chunks of memory of a given process starting at given offset.
Args:
process: A platform-specific `Process` instance.
offset: An integer offset at which the memory stream should start on.
amount: An upper bound on number of bytes to read.
Returns:
Generator over `Chunk` instance... | grr/client/grr_response_client/streaming.py | def StreamMemory(self, process, offset=0, amount=None):
"""Streams chunks of memory of a given process starting at given offset.
Args:
process: A platform-specific `Process` instance.
offset: An integer offset at which the memory stream should start on.
amount: An upper bound on number of byt... | def StreamMemory(self, process, offset=0, amount=None):
"""Streams chunks of memory of a given process starting at given offset.
Args:
process: A platform-specific `Process` instance.
offset: An integer offset at which the memory stream should start on.
amount: An upper bound on number of byt... | [
"Streams",
"chunks",
"of",
"memory",
"of",
"a",
"given",
"process",
"starting",
"at",
"given",
"offset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/streaming.py#L63-L75 | [
"def",
"StreamMemory",
"(",
"self",
",",
"process",
",",
"offset",
"=",
"0",
",",
"amount",
"=",
"None",
")",
":",
"reader",
"=",
"MemoryReader",
"(",
"process",
",",
"offset",
"=",
"offset",
")",
"return",
"self",
".",
"Stream",
"(",
"reader",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Streamer.Stream | Streams chunks of a given file starting at given offset.
Args:
reader: A `Reader` instance.
amount: An upper bound on number of bytes to read.
Yields:
`Chunk` instances. | grr/client/grr_response_client/streaming.py | def Stream(self, reader, amount=None):
"""Streams chunks of a given file starting at given offset.
Args:
reader: A `Reader` instance.
amount: An upper bound on number of bytes to read.
Yields:
`Chunk` instances.
"""
if amount is None:
amount = float("inf")
data = reade... | def Stream(self, reader, amount=None):
"""Streams chunks of a given file starting at given offset.
Args:
reader: A `Reader` instance.
amount: An upper bound on number of bytes to read.
Yields:
`Chunk` instances.
"""
if amount is None:
amount = float("inf")
data = reade... | [
"Streams",
"chunks",
"of",
"a",
"given",
"file",
"starting",
"at",
"given",
"offset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/streaming.py#L77-L110 | [
"def",
"Stream",
"(",
"self",
",",
"reader",
",",
"amount",
"=",
"None",
")",
":",
"if",
"amount",
"is",
"None",
":",
"amount",
"=",
"float",
"(",
"\"inf\"",
")",
"data",
"=",
"reader",
".",
"Read",
"(",
"min",
"(",
"self",
".",
"chunk_size",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Chunk.Scan | Yields spans occurrences of a given pattern within the chunk.
Only matches that span over regular (non-overlapped) chunk bytes are
returned. Matches lying completely within the overlapped zone are ought to
be returned by the previous chunk.
Args:
matcher: A `Matcher` instance corresponding to th... | grr/client/grr_response_client/streaming.py | def Scan(self, matcher):
"""Yields spans occurrences of a given pattern within the chunk.
Only matches that span over regular (non-overlapped) chunk bytes are
returned. Matches lying completely within the overlapped zone are ought to
be returned by the previous chunk.
Args:
matcher: A `Match... | def Scan(self, matcher):
"""Yields spans occurrences of a given pattern within the chunk.
Only matches that span over regular (non-overlapped) chunk bytes are
returned. Matches lying completely within the overlapped zone are ought to
be returned by the previous chunk.
Args:
matcher: A `Match... | [
"Yields",
"spans",
"occurrences",
"of",
"a",
"given",
"pattern",
"within",
"the",
"chunk",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/streaming.py#L137-L168 | [
"def",
"Scan",
"(",
"self",
",",
"matcher",
")",
":",
"position",
"=",
"0",
"while",
"True",
":",
"span",
"=",
"matcher",
".",
"Match",
"(",
"self",
".",
"data",
",",
"position",
")",
"if",
"span",
"is",
"None",
":",
"return",
"# We are not interested ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetMountpoints | List all the filesystems mounted on the system. | grr/client/grr_response_client/client_utils_linux.py | def GetMountpoints(data=None):
"""List all the filesystems mounted on the system."""
expiry = 60 # 1 min
insert_time = MOUNTPOINT_CACHE[0]
if insert_time + expiry > time.time():
return MOUNTPOINT_CACHE[1]
devices = {}
# Check all the mounted filesystems.
if data is None:
data = "\n".join(
... | def GetMountpoints(data=None):
"""List all the filesystems mounted on the system."""
expiry = 60 # 1 min
insert_time = MOUNTPOINT_CACHE[0]
if insert_time + expiry > time.time():
return MOUNTPOINT_CACHE[1]
devices = {}
# Check all the mounted filesystems.
if data is None:
data = "\n".join(
... | [
"List",
"all",
"the",
"filesystems",
"mounted",
"on",
"the",
"system",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_linux.py#L38-L66 | [
"def",
"GetMountpoints",
"(",
"data",
"=",
"None",
")",
":",
"expiry",
"=",
"60",
"# 1 min",
"insert_time",
"=",
"MOUNTPOINT_CACHE",
"[",
"0",
"]",
"if",
"insert_time",
"+",
"expiry",
">",
"time",
".",
"time",
"(",
")",
":",
"return",
"MOUNTPOINT_CACHE",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Execute | Executes commands on the client.
This function is the only place where commands will be executed
by the GRR client. This makes sure that all issued commands are compared to a
white list and no malicious commands are issued on the client machine.
Args:
cmd: The command to be executed.
args: List of arg... | grr/client/grr_response_client/client_utils_common.py | def Execute(cmd,
args,
time_limit=-1,
bypass_whitelist=False,
daemon=False,
use_client_context=False,
cwd=None):
"""Executes commands on the client.
This function is the only place where commands will be executed
by the GRR client. This make... | def Execute(cmd,
args,
time_limit=-1,
bypass_whitelist=False,
daemon=False,
use_client_context=False,
cwd=None):
"""Executes commands on the client.
This function is the only place where commands will be executed
by the GRR client. This make... | [
"Executes",
"commands",
"on",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L35-L86 | [
"def",
"Execute",
"(",
"cmd",
",",
"args",
",",
"time_limit",
"=",
"-",
"1",
",",
"bypass_whitelist",
"=",
"False",
",",
"daemon",
"=",
"False",
",",
"use_client_context",
"=",
"False",
",",
"cwd",
"=",
"None",
")",
":",
"if",
"not",
"bypass_whitelist",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _Execute | Executes cmd. | grr/client/grr_response_client/client_utils_common.py | def _Execute(cmd, args, time_limit=-1, use_client_context=False, cwd=None):
"""Executes cmd."""
run = [cmd]
run.extend(args)
env = os.environ.copy()
if use_client_context:
env.pop("LD_LIBRARY_PATH", None)
env.pop("PYTHON_PATH", None)
context = "client"
else:
context = "system"
logging.info... | def _Execute(cmd, args, time_limit=-1, use_client_context=False, cwd=None):
"""Executes cmd."""
run = [cmd]
run.extend(args)
env = os.environ.copy()
if use_client_context:
env.pop("LD_LIBRARY_PATH", None)
env.pop("PYTHON_PATH", None)
context = "client"
else:
context = "system"
logging.info... | [
"Executes",
"cmd",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L89-L128 | [
"def",
"_Execute",
"(",
"cmd",
",",
"args",
",",
"time_limit",
"=",
"-",
"1",
",",
"use_client_context",
"=",
"False",
",",
"cwd",
"=",
"None",
")",
":",
"run",
"=",
"[",
"cmd",
"]",
"run",
".",
"extend",
"(",
"args",
")",
"env",
"=",
"os",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IsExecutionWhitelisted | Check if a binary and args is whitelisted.
Args:
cmd: Canonical path to the binary.
args: List of arguments to be passed to the binary.
Returns:
Bool, True if it is whitelisted.
These whitelists could also go in the platform specific client files
client_utils_<platform>.py. We chose to leave them... | grr/client/grr_response_client/client_utils_common.py | def IsExecutionWhitelisted(cmd, args):
"""Check if a binary and args is whitelisted.
Args:
cmd: Canonical path to the binary.
args: List of arguments to be passed to the binary.
Returns:
Bool, True if it is whitelisted.
These whitelists could also go in the platform specific client files
client... | def IsExecutionWhitelisted(cmd, args):
"""Check if a binary and args is whitelisted.
Args:
cmd: Canonical path to the binary.
args: List of arguments to be passed to the binary.
Returns:
Bool, True if it is whitelisted.
These whitelists could also go in the platform specific client files
client... | [
"Check",
"if",
"a",
"binary",
"and",
"args",
"is",
"whitelisted",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L131-L203 | [
"def",
"IsExecutionWhitelisted",
"(",
"cmd",
",",
"args",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Windows\"",
":",
"whitelist",
"=",
"[",
"(",
"\"arp.exe\"",
",",
"[",
"\"-a\"",
"]",
")",
",",
"(",
"\"driverquery.exe\"",
",",
"[",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiHasher.HashFilePath | Updates underlying hashers with file on a given path.
Args:
path: A path to the file that is going to be fed to the hashers.
byte_count: A maximum numbers of bytes that are going to be processed. | grr/client/grr_response_client/client_utils_common.py | def HashFilePath(self, path, byte_count):
"""Updates underlying hashers with file on a given path.
Args:
path: A path to the file that is going to be fed to the hashers.
byte_count: A maximum numbers of bytes that are going to be processed.
"""
with open(path, "rb") as fd:
self.HashFi... | def HashFilePath(self, path, byte_count):
"""Updates underlying hashers with file on a given path.
Args:
path: A path to the file that is going to be fed to the hashers.
byte_count: A maximum numbers of bytes that are going to be processed.
"""
with open(path, "rb") as fd:
self.HashFi... | [
"Updates",
"underlying",
"hashers",
"with",
"file",
"on",
"a",
"given",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L232-L240 | [
"def",
"HashFilePath",
"(",
"self",
",",
"path",
",",
"byte_count",
")",
":",
"with",
"open",
"(",
"path",
",",
"\"rb\"",
")",
"as",
"fd",
":",
"self",
".",
"HashFile",
"(",
"fd",
",",
"byte_count",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiHasher.HashFile | Updates underlying hashers with a given file.
Args:
fd: A file object that is going to be fed to the hashers.
byte_count: A maximum number of bytes that are going to be processed. | grr/client/grr_response_client/client_utils_common.py | def HashFile(self, fd, byte_count):
"""Updates underlying hashers with a given file.
Args:
fd: A file object that is going to be fed to the hashers.
byte_count: A maximum number of bytes that are going to be processed.
"""
while byte_count > 0:
buf_size = min(byte_count, constants.CLI... | def HashFile(self, fd, byte_count):
"""Updates underlying hashers with a given file.
Args:
fd: A file object that is going to be fed to the hashers.
byte_count: A maximum number of bytes that are going to be processed.
"""
while byte_count > 0:
buf_size = min(byte_count, constants.CLI... | [
"Updates",
"underlying",
"hashers",
"with",
"a",
"given",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L242-L256 | [
"def",
"HashFile",
"(",
"self",
",",
"fd",
",",
"byte_count",
")",
":",
"while",
"byte_count",
">",
"0",
":",
"buf_size",
"=",
"min",
"(",
"byte_count",
",",
"constants",
".",
"CLIENT_MAX_BUFFER_SIZE",
")",
"buf",
"=",
"fd",
".",
"read",
"(",
"buf_size",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiHasher.HashBuffer | Updates underlying hashers with a given buffer.
Args:
buf: A byte buffer (string object) that is going to be fed to the hashers. | grr/client/grr_response_client/client_utils_common.py | def HashBuffer(self, buf):
"""Updates underlying hashers with a given buffer.
Args:
buf: A byte buffer (string object) that is going to be fed to the hashers.
"""
for hasher in itervalues(self._hashers):
hasher.update(buf)
if self._progress:
self._progress()
self._bytes_r... | def HashBuffer(self, buf):
"""Updates underlying hashers with a given buffer.
Args:
buf: A byte buffer (string object) that is going to be fed to the hashers.
"""
for hasher in itervalues(self._hashers):
hasher.update(buf)
if self._progress:
self._progress()
self._bytes_r... | [
"Updates",
"underlying",
"hashers",
"with",
"a",
"given",
"buffer",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L258-L269 | [
"def",
"HashBuffer",
"(",
"self",
",",
"buf",
")",
":",
"for",
"hasher",
"in",
"itervalues",
"(",
"self",
".",
"_hashers",
")",
":",
"hasher",
".",
"update",
"(",
"buf",
")",
"if",
"self",
".",
"_progress",
":",
"self",
".",
"_progress",
"(",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiHasher.GetHashObject | Returns a `Hash` object with appropriate fields filled-in. | grr/client/grr_response_client/client_utils_common.py | def GetHashObject(self):
"""Returns a `Hash` object with appropriate fields filled-in."""
hash_object = rdf_crypto.Hash()
hash_object.num_bytes = self._bytes_read
for algorithm in self._hashers:
setattr(hash_object, algorithm, self._hashers[algorithm].digest())
return hash_object | def GetHashObject(self):
"""Returns a `Hash` object with appropriate fields filled-in."""
hash_object = rdf_crypto.Hash()
hash_object.num_bytes = self._bytes_read
for algorithm in self._hashers:
setattr(hash_object, algorithm, self._hashers[algorithm].digest())
return hash_object | [
"Returns",
"a",
"Hash",
"object",
"with",
"appropriate",
"fields",
"filled",
"-",
"in",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_common.py#L271-L277 | [
"def",
"GetHashObject",
"(",
"self",
")",
":",
"hash_object",
"=",
"rdf_crypto",
".",
"Hash",
"(",
")",
"hash_object",
".",
"num_bytes",
"=",
"self",
".",
"_bytes_read",
"for",
"algorithm",
"in",
"self",
".",
"_hashers",
":",
"setattr",
"(",
"hash_object",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetAllClientLabels | Get the set of all label names applied to all clients.
Args:
token: token to use when opening the index.
include_catchall: If true, we include ALL_CLIENTS_LABEL in the results.
Returns:
set of label name strings, including the catchall "All" | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def GetAllClientLabels(token, include_catchall=False):
"""Get the set of all label names applied to all clients.
Args:
token: token to use when opening the index.
include_catchall: If true, we include ALL_CLIENTS_LABEL in the results.
Returns:
set of label name strings, including the catchall "All"
... | def GetAllClientLabels(token, include_catchall=False):
"""Get the set of all label names applied to all clients.
Args:
token: token to use when opening the index.
include_catchall: If true, we include ALL_CLIENTS_LABEL in the results.
Returns:
set of label name strings, including the catchall "All"
... | [
"Get",
"the",
"set",
"of",
"all",
"label",
"names",
"applied",
"to",
"all",
"clients",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L907-L925 | [
"def",
"GetAllClientLabels",
"(",
"token",
",",
"include_catchall",
"=",
"False",
")",
":",
"labels_index",
"=",
"aff4",
".",
"FACTORY",
".",
"Create",
"(",
"standard",
".",
"LabelSet",
".",
"CLIENT_LABELS_URN",
",",
"standard",
".",
"LabelSet",
",",
"mode",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSGRRClient.age | RDFDatetime at which the object was created. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def age(self):
"""RDFDatetime at which the object was created."""
# TODO(user) move up to AFF4Object after some analysis of how .age is
# used in the codebase.
aff4_type = self.Get(self.Schema.TYPE)
if aff4_type:
return aff4_type.age
else:
# If there is no type attribute yet, we hav... | def age(self):
"""RDFDatetime at which the object was created."""
# TODO(user) move up to AFF4Object after some analysis of how .age is
# used in the codebase.
aff4_type = self.Get(self.Schema.TYPE)
if aff4_type:
return aff4_type.age
else:
# If there is no type attribute yet, we hav... | [
"RDFDatetime",
"at",
"which",
"the",
"object",
"was",
"created",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L242-L253 | [
"def",
"age",
"(",
"self",
")",
":",
"# TODO(user) move up to AFF4Object after some analysis of how .age is",
"# used in the codebase.",
"aff4_type",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"TYPE",
")",
"if",
"aff4_type",
":",
"return",
"aff4_type",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSGRRClient.GetSummary | Gets a client summary object.
Returns:
rdf_client.ClientSummary
Raises:
ValueError: on bad cloud type | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def GetSummary(self):
"""Gets a client summary object.
Returns:
rdf_client.ClientSummary
Raises:
ValueError: on bad cloud type
"""
self.max_age = 0
summary = rdf_client.ClientSummary(client_id=self.urn)
summary.system_info.system = self.Get(self.Schema.SYSTEM)
summary.system... | def GetSummary(self):
"""Gets a client summary object.
Returns:
rdf_client.ClientSummary
Raises:
ValueError: on bad cloud type
"""
self.max_age = 0
summary = rdf_client.ClientSummary(client_id=self.urn)
summary.system_info.system = self.Get(self.Schema.SYSTEM)
summary.system... | [
"Gets",
"a",
"client",
"summary",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L280-L318 | [
"def",
"GetSummary",
"(",
"self",
")",
":",
"self",
".",
"max_age",
"=",
"0",
"summary",
"=",
"rdf_client",
".",
"ClientSummary",
"(",
"client_id",
"=",
"self",
".",
"urn",
")",
"summary",
".",
"system_info",
".",
"system",
"=",
"self",
".",
"Get",
"("... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UpdateVFSFile.Start | Calls the Update() method of a given VFSFile/VFSDirectory object. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def Start(self):
"""Calls the Update() method of a given VFSFile/VFSDirectory object."""
self.Init()
fd = aff4.FACTORY.Open(self.args.vfs_file_urn, mode="rw", token=self.token)
# Account for implicit directories.
if fd.Get(fd.Schema.TYPE) is None:
fd = fd.Upgrade(standard.VFSDirectory)
s... | def Start(self):
"""Calls the Update() method of a given VFSFile/VFSDirectory object."""
self.Init()
fd = aff4.FACTORY.Open(self.args.vfs_file_urn, mode="rw", token=self.token)
# Account for implicit directories.
if fd.Get(fd.Schema.TYPE) is None:
fd = fd.Upgrade(standard.VFSDirectory)
s... | [
"Calls",
"the",
"Update",
"()",
"method",
"of",
"a",
"given",
"VFSFile",
"/",
"VFSDirectory",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L345-L354 | [
"def",
"Start",
"(",
"self",
")",
":",
"self",
".",
"Init",
"(",
")",
"fd",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"self",
".",
"args",
".",
"vfs_file_urn",
",",
"mode",
"=",
"\"rw\"",
",",
"token",
"=",
"self",
".",
"token",
")",
"# Acco... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSFile.Update | Update an attribute from the client. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def Update(self, attribute=None):
"""Update an attribute from the client."""
# List the directory on the client
currently_running = self.Get(self.Schema.CONTENT_LOCK)
# Is this flow still active?
if currently_running:
flow_obj = aff4.FACTORY.Open(currently_running, token=self.token)
if ... | def Update(self, attribute=None):
"""Update an attribute from the client."""
# List the directory on the client
currently_running = self.Get(self.Schema.CONTENT_LOCK)
# Is this flow still active?
if currently_running:
flow_obj = aff4.FACTORY.Open(currently_running, token=self.token)
if ... | [
"Update",
"an",
"attribute",
"from",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L374-L400 | [
"def",
"Update",
"(",
"self",
",",
"attribute",
"=",
"None",
")",
":",
"# List the directory on the client",
"currently_running",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"CONTENT_LOCK",
")",
"# Is this flow still active?",
"if",
"currently_running"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRForeman.ExpireRules | Removes any rules with an expiration date in the past. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def ExpireRules(self):
"""Removes any rules with an expiration date in the past."""
rules = self.Get(self.Schema.RULES)
new_rules = self.Schema.RULES()
now = time.time() * 1e6
expired_session_ids = set()
for rule in rules:
if rule.expires > now:
new_rules.Append(rule)
else:
... | def ExpireRules(self):
"""Removes any rules with an expiration date in the past."""
rules = self.Get(self.Schema.RULES)
new_rules = self.Schema.RULES()
now = time.time() * 1e6
expired_session_ids = set()
for rule in rules:
if rule.expires > now:
new_rules.Append(rule)
else:
... | [
"Removes",
"any",
"rules",
"with",
"an",
"expiration",
"date",
"in",
"the",
"past",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L428-L455 | [
"def",
"ExpireRules",
"(",
"self",
")",
":",
"rules",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"RULES",
")",
"new_rules",
"=",
"self",
".",
"Schema",
".",
"RULES",
"(",
")",
"now",
"=",
"time",
".",
"time",
"(",
")",
"*",
"1e6",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRForeman._CheckIfHuntTaskWasAssigned | Will return True if hunt's task was assigned to this client before. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def _CheckIfHuntTaskWasAssigned(self, client_id, hunt_id):
"""Will return True if hunt's task was assigned to this client before."""
client_urn = rdfvalue.RDFURN(client_id)
for _ in aff4.FACTORY.Stat([
client_urn.Add("flows/%s:hunt" % rdfvalue.RDFURN(hunt_id).Basename())
]):
return True
... | def _CheckIfHuntTaskWasAssigned(self, client_id, hunt_id):
"""Will return True if hunt's task was assigned to this client before."""
client_urn = rdfvalue.RDFURN(client_id)
for _ in aff4.FACTORY.Stat([
client_urn.Add("flows/%s:hunt" % rdfvalue.RDFURN(hunt_id).Basename())
]):
return True
... | [
"Will",
"return",
"True",
"if",
"hunt",
"s",
"task",
"was",
"assigned",
"to",
"this",
"client",
"before",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L457-L465 | [
"def",
"_CheckIfHuntTaskWasAssigned",
"(",
"self",
",",
"client_id",
",",
"hunt_id",
")",
":",
"client_urn",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"client_id",
")",
"for",
"_",
"in",
"aff4",
".",
"FACTORY",
".",
"Stat",
"(",
"[",
"client_urn",
".",
"Add",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRForeman._RunActions | Run all the actions specified in the rule.
Args:
rule: Rule which actions are to be executed.
client_id: Id of a client where rule's actions are to be executed.
Returns:
Number of actions started. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def _RunActions(self, rule, client_id):
"""Run all the actions specified in the rule.
Args:
rule: Rule which actions are to be executed.
client_id: Id of a client where rule's actions are to be executed.
Returns:
Number of actions started.
"""
actions_count = 0
for action in... | def _RunActions(self, rule, client_id):
"""Run all the actions specified in the rule.
Args:
rule: Rule which actions are to be executed.
client_id: Id of a client where rule's actions are to be executed.
Returns:
Number of actions started.
"""
actions_count = 0
for action in... | [
"Run",
"all",
"the",
"actions",
"specified",
"in",
"the",
"rule",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L471-L515 | [
"def",
"_RunActions",
"(",
"self",
",",
"rule",
",",
"client_id",
")",
":",
"actions_count",
"=",
"0",
"for",
"action",
"in",
"rule",
".",
"actions",
":",
"try",
":",
"# Say this flow came from the foreman.",
"token",
"=",
"self",
".",
"token",
".",
"Copy",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRForeman.AssignTasksToClient | Examines our rules and starts up flows based on the client.
Args:
client_id: Client id of the client for tasks to be assigned.
Returns:
Number of assigned tasks. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def AssignTasksToClient(self, client_id):
"""Examines our rules and starts up flows based on the client.
Args:
client_id: Client id of the client for tasks to be assigned.
Returns:
Number of assigned tasks.
"""
rules = self.Get(self.Schema.RULES)
if not rules:
return 0
i... | def AssignTasksToClient(self, client_id):
"""Examines our rules and starts up flows based on the client.
Args:
client_id: Client id of the client for tasks to be assigned.
Returns:
Number of assigned tasks.
"""
rules = self.Get(self.Schema.RULES)
if not rules:
return 0
i... | [
"Examines",
"our",
"rules",
"and",
"starts",
"up",
"flows",
"based",
"on",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L541-L605 | [
"def",
"AssignTasksToClient",
"(",
"self",
",",
"client_id",
")",
":",
"rules",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"RULES",
")",
"if",
"not",
"rules",
":",
"return",
"0",
"if",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSFileSymlink.Initialize | Open the delegate object. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def Initialize(self):
"""Open the delegate object."""
if "r" in self.mode:
delegate = self.Get(self.Schema.DELEGATE)
if delegate:
self.delegate = aff4.FACTORY.Open(
delegate, mode=self.mode, token=self.token, age=self.age_policy) | def Initialize(self):
"""Open the delegate object."""
if "r" in self.mode:
delegate = self.Get(self.Schema.DELEGATE)
if delegate:
self.delegate = aff4.FACTORY.Open(
delegate, mode=self.mode, token=self.token, age=self.age_policy) | [
"Open",
"the",
"delegate",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L636-L642 | [
"def",
"Initialize",
"(",
"self",
")",
":",
"if",
"\"r\"",
"in",
"self",
".",
"mode",
":",
"delegate",
"=",
"self",
".",
"Get",
"(",
"self",
".",
"Schema",
".",
"DELEGATE",
")",
"if",
"delegate",
":",
"self",
".",
"delegate",
"=",
"aff4",
".",
"FAC... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSBlobImage._MultiStream | Effectively streams data from multiple opened BlobImage objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argument.
If one or more chunks are ... | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def _MultiStream(cls, fds):
"""Effectively streams data from multiple opened BlobImage objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argument... | def _MultiStream(cls, fds):
"""Effectively streams data from multiple opened BlobImage objects.
Args:
fds: A list of opened AFF4Stream (or AFF4Stream descendants) objects.
Yields:
Tuples (chunk, fd, exception) where chunk is a binary blob of data and fd
is an object from the fds argument... | [
"Effectively",
"streams",
"data",
"from",
"multiple",
"opened",
"BlobImage",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L694-L737 | [
"def",
"_MultiStream",
"(",
"cls",
",",
"fds",
")",
":",
"broken_fds",
"=",
"set",
"(",
")",
"missing_blobs_fd_pairs",
"=",
"[",
"]",
"for",
"chunk_fd_pairs",
"in",
"collection",
".",
"Batch",
"(",
"cls",
".",
"_GenerateChunkIds",
"(",
"fds",
")",
",",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSBlobImage._GetChunkForReading | Retrieve the relevant blob from the AFF4 data store or cache. | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def _GetChunkForReading(self, chunk):
"""Retrieve the relevant blob from the AFF4 data store or cache."""
offset = chunk * self._HASH_SIZE
self.index.seek(offset)
chunk_name = self.index.read(self._HASH_SIZE)
try:
return self.chunk_cache.Get(chunk_name)
except KeyError:
pass
#... | def _GetChunkForReading(self, chunk):
"""Retrieve the relevant blob from the AFF4 data store or cache."""
offset = chunk * self._HASH_SIZE
self.index.seek(offset)
chunk_name = self.index.read(self._HASH_SIZE)
try:
return self.chunk_cache.Get(chunk_name)
except KeyError:
pass
#... | [
"Retrieve",
"the",
"relevant",
"blob",
"from",
"the",
"AFF4",
"data",
"store",
"or",
"cache",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L766-L793 | [
"def",
"_GetChunkForReading",
"(",
"self",
",",
"chunk",
")",
":",
"offset",
"=",
"chunk",
"*",
"self",
".",
"_HASH_SIZE",
"self",
".",
"index",
".",
"seek",
"(",
"offset",
")",
"chunk_name",
"=",
"self",
".",
"index",
".",
"read",
"(",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSBlobImage.AppendContent | Create new blob hashes and append to BlobImage.
We don't support writing at arbitrary file offsets, but this method provides
a convenient way to add blobs for a new file, or append content to an
existing one.
Args:
src_fd: source file handle open for read
Raises:
IOError: if blob has ... | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def AppendContent(self, src_fd):
"""Create new blob hashes and append to BlobImage.
We don't support writing at arbitrary file offsets, but this method provides
a convenient way to add blobs for a new file, or append content to an
existing one.
Args:
src_fd: source file handle open for read
... | def AppendContent(self, src_fd):
"""Create new blob hashes and append to BlobImage.
We don't support writing at arbitrary file offsets, but this method provides
a convenient way to add blobs for a new file, or append content to an
existing one.
Args:
src_fd: source file handle open for read
... | [
"Create",
"new",
"blob",
"hashes",
"and",
"append",
"to",
"BlobImage",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L814-L835 | [
"def",
"AppendContent",
"(",
"self",
",",
"src_fd",
")",
":",
"while",
"1",
":",
"blob",
"=",
"src_fd",
".",
"read",
"(",
"self",
".",
"chunksize",
")",
"if",
"not",
"blob",
":",
"break",
"blob_id",
"=",
"data_store",
".",
"BLOBS",
".",
"WriteBlobWithU... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSBlobImage.AddBlob | Add another blob to this image using its hash.
Once a blob is added that is smaller than the chunksize we finalize the
file, since handling adding more blobs makes the code much more complex.
Args:
blob_id: rdf_objects.BlobID object.
length: int length of blob
Raises:
IOError: if bl... | grr/server/grr_response_server/aff4_objects/aff4_grr.py | def AddBlob(self, blob_id, length):
"""Add another blob to this image using its hash.
Once a blob is added that is smaller than the chunksize we finalize the
file, since handling adding more blobs makes the code much more complex.
Args:
blob_id: rdf_objects.BlobID object.
length: int lengt... | def AddBlob(self, blob_id, length):
"""Add another blob to this image using its hash.
Once a blob is added that is smaller than the chunksize we finalize the
file, since handling adding more blobs makes the code much more complex.
Args:
blob_id: rdf_objects.BlobID object.
length: int lengt... | [
"Add",
"another",
"blob",
"to",
"this",
"image",
"using",
"its",
"hash",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_grr.py#L837-L859 | [
"def",
"AddBlob",
"(",
"self",
",",
"blob_id",
",",
"length",
")",
":",
"if",
"self",
".",
"finalized",
"and",
"length",
">",
"0",
":",
"raise",
"IOError",
"(",
"\"Can't add blobs to finalized BlobImage\"",
")",
"self",
".",
"content_dirty",
"=",
"True",
"se... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRSignedBlob.NewFromContent | Alternate constructor for GRRSignedBlob.
Creates a GRRSignedBlob from a content string by chunking it and signing
each chunk.
Args:
content: The data to stored in the GRRSignedBlob.
urn: The AFF4 URN to create.
chunk_size: Data will be chunked into this size (each chunk is
indiv... | grr/server/grr_response_server/aff4_objects/collects.py | def NewFromContent(cls,
content,
urn,
chunk_size=1024,
token=None,
private_key=None,
public_key=None):
"""Alternate constructor for GRRSignedBlob.
Creates a GRRSignedBlob from a content... | def NewFromContent(cls,
content,
urn,
chunk_size=1024,
token=None,
private_key=None,
public_key=None):
"""Alternate constructor for GRRSignedBlob.
Creates a GRRSignedBlob from a content... | [
"Alternate",
"constructor",
"for",
"GRRSignedBlob",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/collects.py#L23-L58 | [
"def",
"NewFromContent",
"(",
"cls",
",",
"content",
",",
"urn",
",",
"chunk_size",
"=",
"1024",
",",
"token",
"=",
"None",
",",
"private_key",
"=",
"None",
",",
"public_key",
"=",
"None",
")",
":",
"aff4",
".",
"FACTORY",
".",
"Delete",
"(",
"urn",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Substitution.Substitute | Formats given pattern with this substitution environment.
A pattern can contain placeholders for variables (`%%foo%%`) and scopes
(`%%bar.baz%%`) that are replaced with concrete values in this substiution
environment (specified in the constructor).
Args:
pattern: A pattern with placeholders to s... | grr/core/grr_response_core/lib/interpolation.py | def Substitute(self, pattern):
"""Formats given pattern with this substitution environment.
A pattern can contain placeholders for variables (`%%foo%%`) and scopes
(`%%bar.baz%%`) that are replaced with concrete values in this substiution
environment (specified in the constructor).
Args:
pat... | def Substitute(self, pattern):
"""Formats given pattern with this substitution environment.
A pattern can contain placeholders for variables (`%%foo%%`) and scopes
(`%%bar.baz%%`) that are replaced with concrete values in this substiution
environment (specified in the constructor).
Args:
pat... | [
"Formats",
"given",
"pattern",
"with",
"this",
"substitution",
"environment",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/interpolation.py#L56-L91 | [
"def",
"Substitute",
"(",
"self",
",",
"pattern",
")",
":",
"if",
"isinstance",
"(",
"pattern",
",",
"bytes",
")",
":",
"substs",
"=",
"[",
"re",
".",
"escape",
"(",
"subst",
".",
"encode",
"(",
"\"ascii\"",
")",
")",
"for",
"subst",
"in",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Interpolator.BindVar | Associates a value with given variable.
This can be called multiple times to associate multiple values.
Args:
var_id: A variable id to bind the values to.
value: A value to bind to the specified variable.
Raises:
KeyError: If given variable is not specified in the pattern. | grr/core/grr_response_core/lib/interpolation.py | def BindVar(self, var_id, value):
"""Associates a value with given variable.
This can be called multiple times to associate multiple values.
Args:
var_id: A variable id to bind the values to.
value: A value to bind to the specified variable.
Raises:
KeyError: If given variable is no... | def BindVar(self, var_id, value):
"""Associates a value with given variable.
This can be called multiple times to associate multiple values.
Args:
var_id: A variable id to bind the values to.
value: A value to bind to the specified variable.
Raises:
KeyError: If given variable is no... | [
"Associates",
"a",
"value",
"with",
"given",
"variable",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/interpolation.py#L156-L171 | [
"def",
"BindVar",
"(",
"self",
",",
"var_id",
",",
"value",
")",
":",
"if",
"var_id",
"not",
"in",
"self",
".",
"_vars",
":",
"raise",
"KeyError",
"(",
"var_id",
")",
"self",
".",
"_var_bindings",
"[",
"var_id",
"]",
".",
"append",
"(",
"value",
")"
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Interpolator.BindScope | Associates given values with given scope.
This can be called multiple times to associate multiple values.
Args:
scope_id: A scope id to bind the values to.
values: A mapping from scope variable ids to values to bind in scope.
Raises:
KeyError: If given scope or scope variable is not spe... | grr/core/grr_response_core/lib/interpolation.py | def BindScope(self, scope_id, values):
"""Associates given values with given scope.
This can be called multiple times to associate multiple values.
Args:
scope_id: A scope id to bind the values to.
values: A mapping from scope variable ids to values to bind in scope.
Raises:
KeyErro... | def BindScope(self, scope_id, values):
"""Associates given values with given scope.
This can be called multiple times to associate multiple values.
Args:
scope_id: A scope id to bind the values to.
values: A mapping from scope variable ids to values to bind in scope.
Raises:
KeyErro... | [
"Associates",
"given",
"values",
"with",
"given",
"scope",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/interpolation.py#L173-L193 | [
"def",
"BindScope",
"(",
"self",
",",
"scope_id",
",",
"values",
")",
":",
"if",
"scope_id",
"not",
"in",
"self",
".",
"_scopes",
":",
"raise",
"KeyError",
"(",
"scope_id",
")",
"keys",
"=",
"set",
"(",
"iterkeys",
"(",
"values",
")",
")",
"if",
"key... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Interpolator.Interpolate | Interpolates the pattern.
Yields:
All possible interpolation results. | grr/core/grr_response_core/lib/interpolation.py | def Interpolate(self):
"""Interpolates the pattern.
Yields:
All possible interpolation results.
"""
for var_config in collection.DictProduct(self._var_bindings):
for scope_config in collection.DictProduct(self._scope_bindings):
subst = Substitution(var_config=var_config, scope_confi... | def Interpolate(self):
"""Interpolates the pattern.
Yields:
All possible interpolation results.
"""
for var_config in collection.DictProduct(self._var_bindings):
for scope_config in collection.DictProduct(self._scope_bindings):
subst = Substitution(var_config=var_config, scope_confi... | [
"Interpolates",
"the",
"pattern",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/interpolation.py#L195-L204 | [
"def",
"Interpolate",
"(",
"self",
")",
":",
"for",
"var_config",
"in",
"collection",
".",
"DictProduct",
"(",
"self",
".",
"_var_bindings",
")",
":",
"for",
"scope_config",
"in",
"collection",
".",
"DictProduct",
"(",
"self",
".",
"_scope_bindings",
")",
":... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _Registry.RegisterPlugin | Registers a report plugin for use in the GRR UI. | grr/server/grr_response_server/gui/api_plugins/report_plugins/report_plugins.py | def RegisterPlugin(self, report_plugin_cls):
"""Registers a report plugin for use in the GRR UI."""
name = report_plugin_cls.__name__
if name in self.plugins:
raise RuntimeError("Can't register two report plugins with the same "
"name. In particular, can't register the same "... | def RegisterPlugin(self, report_plugin_cls):
"""Registers a report plugin for use in the GRR UI."""
name = report_plugin_cls.__name__
if name in self.plugins:
raise RuntimeError("Can't register two report plugins with the same "
"name. In particular, can't register the same "... | [
"Registers",
"a",
"report",
"plugin",
"for",
"use",
"in",
"the",
"GRR",
"UI",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/report_plugins.py#L49-L58 | [
"def",
"RegisterPlugin",
"(",
"self",
",",
"report_plugin_cls",
")",
":",
"name",
"=",
"report_plugin_cls",
".",
"__name__",
"if",
"name",
"in",
"self",
".",
"plugins",
":",
"raise",
"RuntimeError",
"(",
"\"Can't register two report plugins with the same \"",
"\"name.... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DarwinClientBuilder.MakeExecutableTemplate | Create the executable template. | grr/client_builder/grr_response_client_builder/builders/osx.py | def MakeExecutableTemplate(self, output_file=None):
"""Create the executable template."""
super(DarwinClientBuilder,
self).MakeExecutableTemplate(output_file=output_file)
self.SetBuildVars()
self.MakeBuildDirectory()
self.BuildWithPyInstaller()
self.CopyMissingModules()
self.BuildI... | def MakeExecutableTemplate(self, output_file=None):
"""Create the executable template."""
super(DarwinClientBuilder,
self).MakeExecutableTemplate(output_file=output_file)
self.SetBuildVars()
self.MakeBuildDirectory()
self.BuildWithPyInstaller()
self.CopyMissingModules()
self.BuildI... | [
"Create",
"the",
"executable",
"template",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/osx.py#L30-L39 | [
"def",
"MakeExecutableTemplate",
"(",
"self",
",",
"output_file",
"=",
"None",
")",
":",
"super",
"(",
"DarwinClientBuilder",
",",
"self",
")",
".",
"MakeExecutableTemplate",
"(",
"output_file",
"=",
"output_file",
")",
"self",
".",
"SetBuildVars",
"(",
")",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DarwinClientBuilder.MakeZip | Add a zip to the end of the .xar containing build.yaml.
The build.yaml is already inside the .xar file, but we can't easily open
this on linux. To make repacking easier we add a zip to the end of the .xar
and add in the build.yaml. The repack step will then look at the build.yaml
and insert the config.... | grr/client_builder/grr_response_client_builder/builders/osx.py | def MakeZip(self, xar_file, output_file):
"""Add a zip to the end of the .xar containing build.yaml.
The build.yaml is already inside the .xar file, but we can't easily open
this on linux. To make repacking easier we add a zip to the end of the .xar
and add in the build.yaml. The repack step will then ... | def MakeZip(self, xar_file, output_file):
"""Add a zip to the end of the .xar containing build.yaml.
The build.yaml is already inside the .xar file, but we can't easily open
this on linux. To make repacking easier we add a zip to the end of the .xar
and add in the build.yaml. The repack step will then ... | [
"Add",
"a",
"zip",
"to",
"the",
"end",
"of",
"the",
".",
"xar",
"containing",
"build",
".",
"yaml",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/osx.py#L80-L100 | [
"def",
"MakeZip",
"(",
"self",
",",
"xar_file",
",",
"output_file",
")",
":",
"logging",
".",
"info",
"(",
"\"Generating zip template file at %s\"",
",",
"output_file",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"output_file",
",",
"mode",
"=",
"\"a\"",
")",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DarwinClientBuilder.BuildInstallerPkg | Builds a package (.pkg) using PackageMaker. | grr/client_builder/grr_response_client_builder/builders/osx.py | def BuildInstallerPkg(self, output_file):
"""Builds a package (.pkg) using PackageMaker."""
self.CreateInstallDirs()
self.InterpolateFiles()
self.RenameGRRPyinstallerBinaries()
self.SignGRRPyinstallerBinaries()
self.WriteClientConfig()
self.Set755Permissions()
self.RunPkgBuild()
self... | def BuildInstallerPkg(self, output_file):
"""Builds a package (.pkg) using PackageMaker."""
self.CreateInstallDirs()
self.InterpolateFiles()
self.RenameGRRPyinstallerBinaries()
self.SignGRRPyinstallerBinaries()
self.WriteClientConfig()
self.Set755Permissions()
self.RunPkgBuild()
self... | [
"Builds",
"a",
"package",
"(",
".",
"pkg",
")",
"using",
"PackageMaker",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client_builder/grr_response_client_builder/builders/osx.py#L233-L243 | [
"def",
"BuildInstallerPkg",
"(",
"self",
",",
"output_file",
")",
":",
"self",
".",
"CreateInstallDirs",
"(",
")",
"self",
".",
"InterpolateFiles",
"(",
")",
"self",
".",
"RenameGRRPyinstallerBinaries",
"(",
")",
"self",
".",
"SignGRRPyinstallerBinaries",
"(",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ClientPathToString | Returns a path-like String of client_path with optional prefix. | grr/server/grr_response_server/gui/archive_generator.py | def _ClientPathToString(client_path, prefix=""):
"""Returns a path-like String of client_path with optional prefix."""
return os.path.join(prefix, client_path.client_id, client_path.vfs_path) | def _ClientPathToString(client_path, prefix=""):
"""Returns a path-like String of client_path with optional prefix."""
return os.path.join(prefix, client_path.client_id, client_path.vfs_path) | [
"Returns",
"a",
"path",
"-",
"like",
"String",
"of",
"client_path",
"with",
"optional",
"prefix",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator.py#L44-L46 | [
"def",
"_ClientPathToString",
"(",
"client_path",
",",
"prefix",
"=",
"\"\"",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"prefix",
",",
"client_path",
".",
"client_id",
",",
"client_path",
".",
"vfs_path",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CollectionArchiveGenerator._GenerateDescription | Generates description into a MANIFEST file in the archive. | grr/server/grr_response_server/gui/archive_generator.py | def _GenerateDescription(self):
"""Generates description into a MANIFEST file in the archive."""
manifest = {
"description": self.description,
"processed_files": len(self.processed_files),
"archived_files": len(self.archived_files),
"ignored_files": len(self.ignored_files),
... | def _GenerateDescription(self):
"""Generates description into a MANIFEST file in the archive."""
manifest = {
"description": self.description,
"processed_files": len(self.processed_files),
"archived_files": len(self.archived_files),
"ignored_files": len(self.ignored_files),
... | [
"Generates",
"description",
"into",
"a",
"MANIFEST",
"file",
"in",
"the",
"archive",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator.py#L118-L148 | [
"def",
"_GenerateDescription",
"(",
"self",
")",
":",
"manifest",
"=",
"{",
"\"description\"",
":",
"self",
".",
"description",
",",
"\"processed_files\"",
":",
"len",
"(",
"self",
".",
"processed_files",
")",
",",
"\"archived_files\"",
":",
"len",
"(",
"self"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CollectionArchiveGenerator._GenerateClientInfo | Yields chucks of archive information for given client. | grr/server/grr_response_server/gui/archive_generator.py | def _GenerateClientInfo(self, client_id, client_fd):
"""Yields chucks of archive information for given client."""
summary_dict = client_fd.ToPrimitiveDict(stringify_leaf_fields=True)
summary = yaml.Dump(summary_dict).encode("utf-8")
client_info_path = os.path.join(self.prefix, client_id, "client_info.y... | def _GenerateClientInfo(self, client_id, client_fd):
"""Yields chucks of archive information for given client."""
summary_dict = client_fd.ToPrimitiveDict(stringify_leaf_fields=True)
summary = yaml.Dump(summary_dict).encode("utf-8")
client_info_path = os.path.join(self.prefix, client_id, "client_info.y... | [
"Yields",
"chucks",
"of",
"archive",
"information",
"for",
"given",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator.py#L150-L159 | [
"def",
"_GenerateClientInfo",
"(",
"self",
",",
"client_id",
",",
"client_fd",
")",
":",
"summary_dict",
"=",
"client_fd",
".",
"ToPrimitiveDict",
"(",
"stringify_leaf_fields",
"=",
"True",
")",
"summary",
"=",
"yaml",
".",
"Dump",
"(",
"summary_dict",
")",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CollectionArchiveGenerator.Generate | Generates archive from a given collection.
Iterates the collection and generates an archive by yielding contents
of every referenced AFF4Stream.
Args:
items: Iterable of rdf_client_fs.StatEntry objects
token: User's ACLToken.
Yields:
Binary chunks comprising the generated archive. | grr/server/grr_response_server/gui/archive_generator.py | def Generate(self, items, token=None):
"""Generates archive from a given collection.
Iterates the collection and generates an archive by yielding contents
of every referenced AFF4Stream.
Args:
items: Iterable of rdf_client_fs.StatEntry objects
token: User's ACLToken.
Yields:
Bin... | def Generate(self, items, token=None):
"""Generates archive from a given collection.
Iterates the collection and generates an archive by yielding contents
of every referenced AFF4Stream.
Args:
items: Iterable of rdf_client_fs.StatEntry objects
token: User's ACLToken.
Yields:
Bin... | [
"Generates",
"archive",
"from",
"a",
"given",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator.py#L161-L214 | [
"def",
"Generate",
"(",
"self",
",",
"items",
",",
"token",
"=",
"None",
")",
":",
"del",
"token",
"# unused, to be removed with AFF4 code",
"client_ids",
"=",
"set",
"(",
")",
"for",
"item_batch",
"in",
"collection",
".",
"Batch",
"(",
"items",
",",
"self",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CollectionArchiveGenerator._WriteFileChunk | Yields binary chunks, respecting archive file headers and footers.
Args:
chunk: the StreamedFileChunk to be written | grr/server/grr_response_server/gui/archive_generator.py | def _WriteFileChunk(self, chunk):
"""Yields binary chunks, respecting archive file headers and footers.
Args:
chunk: the StreamedFileChunk to be written
"""
if chunk.chunk_index == 0:
# Make sure size of the original file is passed. It's required
# when output_writer is StreamingTarWr... | def _WriteFileChunk(self, chunk):
"""Yields binary chunks, respecting archive file headers and footers.
Args:
chunk: the StreamedFileChunk to be written
"""
if chunk.chunk_index == 0:
# Make sure size of the original file is passed. It's required
# when output_writer is StreamingTarWr... | [
"Yields",
"binary",
"chunks",
"respecting",
"archive",
"file",
"headers",
"and",
"footers",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/archive_generator.py#L216-L233 | [
"def",
"_WriteFileChunk",
"(",
"self",
",",
"chunk",
")",
":",
"if",
"chunk",
".",
"chunk_index",
"==",
"0",
":",
"# Make sure size of the original file is passed. It's required",
"# when output_writer is StreamingTarWriter.",
"st",
"=",
"os",
".",
"stat_result",
"(",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DefineFromProtobuf | Add type info definitions from an existing protobuf.
We support building this class by copying definitions from an annotated
protobuf using the semantic protobuf. This is ideal for interoperability
with other languages and non-semantic protobuf implementations. In that case
it might be easier to simply annotat... | grr/core/grr_response_core/lib/rdfvalues/proto2.py | def DefineFromProtobuf(cls, protobuf):
"""Add type info definitions from an existing protobuf.
We support building this class by copying definitions from an annotated
protobuf using the semantic protobuf. This is ideal for interoperability
with other languages and non-semantic protobuf implementations. In that... | def DefineFromProtobuf(cls, protobuf):
"""Add type info definitions from an existing protobuf.
We support building this class by copying definitions from an annotated
protobuf using the semantic protobuf. This is ideal for interoperability
with other languages and non-semantic protobuf implementations. In that... | [
"Add",
"type",
"info",
"definitions",
"from",
"an",
"existing",
"protobuf",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/proto2.py#L80-L333 | [
"def",
"DefineFromProtobuf",
"(",
"cls",
",",
"protobuf",
")",
":",
"mro_chain",
"=",
"[",
"c",
".",
"__name__",
"for",
"c",
"in",
"inspect",
".",
"getmro",
"(",
"cls",
")",
"]",
"if",
"(",
"protobuf",
".",
"__name__",
"not",
"in",
"mro_chain",
"and",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | main | Sets up all the component in their own threads. | grr/server/grr_response_server/bin/grr_server.py | def main(argv):
"""Sets up all the component in their own threads."""
if flags.FLAGS.version:
print("GRR server {}".format(config_server.VERSION["packageversion"]))
return
# We use .startswith so that multiple copies of services can easily be
# created using systemd as worker1 worker2 ... worker25 etc... | def main(argv):
"""Sets up all the component in their own threads."""
if flags.FLAGS.version:
print("GRR server {}".format(config_server.VERSION["packageversion"]))
return
# We use .startswith so that multiple copies of services can easily be
# created using systemd as worker1 worker2 ... worker25 etc... | [
"Sets",
"up",
"all",
"the",
"component",
"in",
"their",
"own",
"threads",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/grr_server.py#L32-L60 | [
"def",
"main",
"(",
"argv",
")",
":",
"if",
"flags",
".",
"FLAGS",
".",
"version",
":",
"print",
"(",
"\"GRR server {}\"",
".",
"format",
"(",
"config_server",
".",
"VERSION",
"[",
"\"packageversion\"",
"]",
")",
")",
"return",
"# We use .startswith so that mu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InSet.Operation | Whether x is fully contained in y. | grr/core/grr_response_core/lib/objectfilter.py | def Operation(self, x, y):
"""Whether x is fully contained in y."""
if x in y:
return True
# x might be an iterable
# first we need to skip strings or we'll do silly things
if isinstance(x, string_types) or isinstance(x, bytes):
return False
try:
for value in x:
if va... | def Operation(self, x, y):
"""Whether x is fully contained in y."""
if x in y:
return True
# x might be an iterable
# first we need to skip strings or we'll do silly things
if isinstance(x, string_types) or isinstance(x, bytes):
return False
try:
for value in x:
if va... | [
"Whether",
"x",
"is",
"fully",
"contained",
"in",
"y",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L334-L350 | [
"def",
"Operation",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"x",
"in",
"y",
":",
"return",
"True",
"# x might be an iterable",
"# first we need to skip strings or we'll do silly things",
"if",
"isinstance",
"(",
"x",
",",
"string_types",
")",
"or",
"isi... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.