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 | Timeseries.ToDeltas | Convert the sequence to the sequence of differences between points.
The value of each point v[i] is replaced by v[i+1] - v[i], except for the
last point which is dropped. | grr/server/grr_response_server/timeseries.py | def ToDeltas(self):
"""Convert the sequence to the sequence of differences between points.
The value of each point v[i] is replaced by v[i+1] - v[i], except for the
last point which is dropped.
"""
if len(self.data) < 2:
self.data = []
return
for i in range(0, len(self.data) - 1):
... | def ToDeltas(self):
"""Convert the sequence to the sequence of differences between points.
The value of each point v[i] is replaced by v[i+1] - v[i], except for the
last point which is dropped.
"""
if len(self.data) < 2:
self.data = []
return
for i in range(0, len(self.data) - 1):
... | [
"Convert",
"the",
"sequence",
"to",
"the",
"sequence",
"of",
"differences",
"between",
"points",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L177-L191 | [
"def",
"ToDeltas",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
")",
"<",
"2",
":",
"self",
".",
"data",
"=",
"[",
"]",
"return",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"data",
")",
"-",
"1",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Timeseries.Add | Add other to self pointwise.
Requires that both self and other are of the same length, and contain
identical timestamps. Typically this means that Normalize has been called
on both with identical time parameters.
Args:
other: The sequence to add to self.
Raises:
RuntimeError: other do... | grr/server/grr_response_server/timeseries.py | def Add(self, other):
"""Add other to self pointwise.
Requires that both self and other are of the same length, and contain
identical timestamps. Typically this means that Normalize has been called
on both with identical time parameters.
Args:
other: The sequence to add to self.
Raises:... | def Add(self, other):
"""Add other to self pointwise.
Requires that both self and other are of the same length, and contain
identical timestamps. Typically this means that Normalize has been called
on both with identical time parameters.
Args:
other: The sequence to add to self.
Raises:... | [
"Add",
"other",
"to",
"self",
"pointwise",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L193-L213 | [
"def",
"Add",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
")",
"!=",
"len",
"(",
"other",
".",
"data",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Can only add series of identical lengths.\"",
")",
"for",
"i",
"in",
"range"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Timeseries.Mean | Return the arithmatic mean of all values. | grr/server/grr_response_server/timeseries.py | def Mean(self):
"""Return the arithmatic mean of all values."""
values = [v for v, _ in self.data if v is not None]
if not values:
return None
# TODO(hanuszczak): Why do we return a floored division result instead of
# the exact value?
return sum(values) // len(values) | def Mean(self):
"""Return the arithmatic mean of all values."""
values = [v for v, _ in self.data if v is not None]
if not values:
return None
# TODO(hanuszczak): Why do we return a floored division result instead of
# the exact value?
return sum(values) // len(values) | [
"Return",
"the",
"arithmatic",
"mean",
"of",
"all",
"values",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/timeseries.py#L221-L229 | [
"def",
"Mean",
"(",
"self",
")",
":",
"values",
"=",
"[",
"v",
"for",
"v",
",",
"_",
"in",
"self",
".",
"data",
"if",
"v",
"is",
"not",
"None",
"]",
"if",
"not",
"values",
":",
"return",
"None",
"# TODO(hanuszczak): Why do we return a floored division resu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactSource.Validate | Check the source is well constructed. | grr/core/grr_response_core/lib/rdfvalues/artifacts.py | def Validate(self):
"""Check the source is well constructed."""
self._ValidateReturnedTypes()
self._ValidatePaths()
self._ValidateType()
self._ValidateRequiredAttributes()
self._ValidateCommandArgs() | def Validate(self):
"""Check the source is well constructed."""
self._ValidateReturnedTypes()
self._ValidatePaths()
self._ValidateType()
self._ValidateRequiredAttributes()
self._ValidateCommandArgs() | [
"Check",
"the",
"source",
"is",
"well",
"constructed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/artifacts.py#L173-L179 | [
"def",
"Validate",
"(",
"self",
")",
":",
"self",
".",
"_ValidateReturnedTypes",
"(",
")",
"self",
".",
"_ValidatePaths",
"(",
")",
"self",
".",
"_ValidateType",
"(",
")",
"self",
".",
"_ValidateRequiredAttributes",
"(",
")",
"self",
".",
"_ValidateCommandArgs... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Artifact.ToPrimitiveDict | Handle dict generation specifically for Artifacts. | grr/core/grr_response_core/lib/rdfvalues/artifacts.py | def ToPrimitiveDict(self):
"""Handle dict generation specifically for Artifacts."""
artifact_dict = super(Artifact, self).ToPrimitiveDict()
# ArtifactName is not JSON-serializable, so convert name to string.
artifact_dict["name"] = utils.SmartStr(self.name)
# Convert proto enum to simple strings s... | def ToPrimitiveDict(self):
"""Handle dict generation specifically for Artifacts."""
artifact_dict = super(Artifact, self).ToPrimitiveDict()
# ArtifactName is not JSON-serializable, so convert name to string.
artifact_dict["name"] = utils.SmartStr(self.name)
# Convert proto enum to simple strings s... | [
"Handle",
"dict",
"generation",
"specifically",
"for",
"Artifacts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/artifacts.py#L306-L328 | [
"def",
"ToPrimitiveDict",
"(",
"self",
")",
":",
"artifact_dict",
"=",
"super",
"(",
"Artifact",
",",
"self",
")",
".",
"ToPrimitiveDict",
"(",
")",
"# ArtifactName is not JSON-serializable, so convert name to string.",
"artifact_dict",
"[",
"\"name\"",
"]",
"=",
"uti... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BaseHandler.Validate | Verifies this filter set can process the result data. | grr/server/grr_response_server/check_lib/filters.py | def Validate(self):
"""Verifies this filter set can process the result data."""
# All filters can handle the input type.
bad_filters = []
for f in self.filters:
try:
f.Validate()
except DefinitionError as e:
bad_filters.append("%s: %s" % (f.expression, e))
if bad_filters:... | def Validate(self):
"""Verifies this filter set can process the result data."""
# All filters can handle the input type.
bad_filters = []
for f in self.filters:
try:
f.Validate()
except DefinitionError as e:
bad_filters.append("%s: %s" % (f.expression, e))
if bad_filters:... | [
"Verifies",
"this",
"filter",
"set",
"can",
"process",
"the",
"result",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L60-L71 | [
"def",
"Validate",
"(",
"self",
")",
":",
"# All filters can handle the input type.",
"bad_filters",
"=",
"[",
"]",
"for",
"f",
"in",
"self",
".",
"filters",
":",
"try",
":",
"f",
".",
"Validate",
"(",
")",
"except",
"DefinitionError",
"as",
"e",
":",
"bad... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ParallelHandler.Parse | Take the data and yield results that passed through the filters.
The output of each filter is added to a result set. So long as the filter
selects, but does not modify, raw data, the result count will remain
accurate.
Args:
raw_data: An iterable series of rdf values.
Returns:
A list o... | grr/server/grr_response_server/check_lib/filters.py | def Parse(self, raw_data):
"""Take the data and yield results that passed through the filters.
The output of each filter is added to a result set. So long as the filter
selects, but does not modify, raw data, the result count will remain
accurate.
Args:
raw_data: An iterable series of rdf va... | def Parse(self, raw_data):
"""Take the data and yield results that passed through the filters.
The output of each filter is added to a result set. So long as the filter
selects, but does not modify, raw data, the result count will remain
accurate.
Args:
raw_data: An iterable series of rdf va... | [
"Take",
"the",
"data",
"and",
"yield",
"results",
"that",
"passed",
"through",
"the",
"filters",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L89-L108 | [
"def",
"Parse",
"(",
"self",
",",
"raw_data",
")",
":",
"self",
".",
"results",
"=",
"set",
"(",
")",
"if",
"not",
"self",
".",
"filters",
":",
"self",
".",
"results",
".",
"update",
"(",
"raw_data",
")",
"else",
":",
"for",
"f",
"in",
"self",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SerialHandler.Parse | Take the results and yield results that passed through the filters.
The output of each filter is used as the input for successive filters.
Args:
raw_data: An iterable series of rdf values.
Returns:
A list of rdf values that matched all filters. | grr/server/grr_response_server/check_lib/filters.py | def Parse(self, raw_data):
"""Take the results and yield results that passed through the filters.
The output of each filter is used as the input for successive filters.
Args:
raw_data: An iterable series of rdf values.
Returns:
A list of rdf values that matched all filters.
"""
se... | def Parse(self, raw_data):
"""Take the results and yield results that passed through the filters.
The output of each filter is used as the input for successive filters.
Args:
raw_data: An iterable series of rdf values.
Returns:
A list of rdf values that matched all filters.
"""
se... | [
"Take",
"the",
"results",
"and",
"yield",
"results",
"that",
"passed",
"through",
"the",
"filters",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L114-L128 | [
"def",
"Parse",
"(",
"self",
",",
"raw_data",
")",
":",
"self",
".",
"results",
"=",
"raw_data",
"for",
"f",
"in",
"self",
".",
"filters",
":",
"self",
".",
"results",
"=",
"f",
".",
"Parse",
"(",
"self",
".",
"results",
")",
"return",
"self",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Filter.GetFilter | Return an initialized filter. Only initialize filters once.
Args:
filter_name: The name of the filter, as a string.
Returns:
an initialized instance of the filter.
Raises:
DefinitionError if the type of filter has not been defined. | grr/server/grr_response_server/check_lib/filters.py | def GetFilter(cls, filter_name):
"""Return an initialized filter. Only initialize filters once.
Args:
filter_name: The name of the filter, as a string.
Returns:
an initialized instance of the filter.
Raises:
DefinitionError if the type of filter has not been defined.
"""
# C... | def GetFilter(cls, filter_name):
"""Return an initialized filter. Only initialize filters once.
Args:
filter_name: The name of the filter, as a string.
Returns:
an initialized instance of the filter.
Raises:
DefinitionError if the type of filter has not been defined.
"""
# C... | [
"Return",
"an",
"initialized",
"filter",
".",
"Only",
"initialize",
"filters",
"once",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L141-L159 | [
"def",
"GetFilter",
"(",
"cls",
",",
"filter_name",
")",
":",
"# Check if the filter is defined in the registry.",
"try",
":",
"filt_cls",
"=",
"cls",
".",
"GetPlugin",
"(",
"filter_name",
")",
"except",
"KeyError",
":",
"raise",
"DefinitionError",
"(",
"\"Filter %s... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AttrFilter._GetVal | Recurse down an attribute chain to the actual result data. | grr/server/grr_response_server/check_lib/filters.py | def _GetVal(self, obj, key):
"""Recurse down an attribute chain to the actual result data."""
if "." in key:
lhs, rhs = key.split(".", 1)
obj2 = getattr(obj, lhs, None)
if obj2 is None:
return None
return self._GetVal(obj2, rhs)
else:
return getattr(obj, key, None) | def _GetVal(self, obj, key):
"""Recurse down an attribute chain to the actual result data."""
if "." in key:
lhs, rhs = key.split(".", 1)
obj2 = getattr(obj, lhs, None)
if obj2 is None:
return None
return self._GetVal(obj2, rhs)
else:
return getattr(obj, key, None) | [
"Recurse",
"down",
"an",
"attribute",
"chain",
"to",
"the",
"actual",
"result",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L199-L208 | [
"def",
"_GetVal",
"(",
"self",
",",
"obj",
",",
"key",
")",
":",
"if",
"\".\"",
"in",
"key",
":",
"lhs",
",",
"rhs",
"=",
"key",
".",
"split",
"(",
"\".\"",
",",
"1",
")",
"obj2",
"=",
"getattr",
"(",
"obj",
",",
"lhs",
",",
"None",
")",
"if"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ObjectFilter.ParseObjs | Parse one or more objects using an objectfilter expression. | grr/server/grr_response_server/check_lib/filters.py | def ParseObjs(self, objs, expression):
"""Parse one or more objects using an objectfilter expression."""
filt = self._Compile(expression)
for result in filt.Filter(objs):
yield result | def ParseObjs(self, objs, expression):
"""Parse one or more objects using an objectfilter expression."""
filt = self._Compile(expression)
for result in filt.Filter(objs):
yield result | [
"Parse",
"one",
"or",
"more",
"objects",
"using",
"an",
"objectfilter",
"expression",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L236-L240 | [
"def",
"ParseObjs",
"(",
"self",
",",
"objs",
",",
"expression",
")",
":",
"filt",
"=",
"self",
".",
"_Compile",
"(",
"expression",
")",
"for",
"result",
"in",
"filt",
".",
"Filter",
"(",
"objs",
")",
":",
"yield",
"result"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StatFilter._Comparator | Generate lambdas for uid and gid comparison. | grr/server/grr_response_server/check_lib/filters.py | def _Comparator(self, operator):
"""Generate lambdas for uid and gid comparison."""
if operator == "=":
return lambda x, y: x == y
elif operator == ">=":
return lambda x, y: x >= y
elif operator == ">":
return lambda x, y: x > y
elif operator == "<=":
return lambda x, y: x <=... | def _Comparator(self, operator):
"""Generate lambdas for uid and gid comparison."""
if operator == "=":
return lambda x, y: x == y
elif operator == ">=":
return lambda x, y: x >= y
elif operator == ">":
return lambda x, y: x > y
elif operator == "<=":
return lambda x, y: x <=... | [
"Generate",
"lambdas",
"for",
"uid",
"and",
"gid",
"comparison",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L360-L374 | [
"def",
"_Comparator",
"(",
"self",
",",
"operator",
")",
":",
"if",
"operator",
"==",
"\"=\"",
":",
"return",
"lambda",
"x",
",",
"y",
":",
"x",
"==",
"y",
"elif",
"operator",
"==",
"\">=\"",
":",
"return",
"lambda",
"x",
",",
"y",
":",
"x",
">=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StatFilter._Initialize | Initialize the filter configuration from a validated configuration.
The configuration is read. Active filters are added to the matcher list,
which is used to process the Stat values. | grr/server/grr_response_server/check_lib/filters.py | def _Initialize(self):
"""Initialize the filter configuration from a validated configuration.
The configuration is read. Active filters are added to the matcher list,
which is used to process the Stat values.
"""
if self.cfg.mask:
self.mask = int(self.cfg.mask[0], 8)
else:
self.mas... | def _Initialize(self):
"""Initialize the filter configuration from a validated configuration.
The configuration is read. Active filters are added to the matcher list,
which is used to process the Stat values.
"""
if self.cfg.mask:
self.mask = int(self.cfg.mask[0], 8)
else:
self.mas... | [
"Initialize",
"the",
"filter",
"configuration",
"from",
"a",
"validated",
"configuration",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L397-L438 | [
"def",
"_Initialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"cfg",
".",
"mask",
":",
"self",
".",
"mask",
"=",
"int",
"(",
"self",
".",
"cfg",
".",
"mask",
"[",
"0",
"]",
",",
"8",
")",
"else",
":",
"self",
".",
"mask",
"=",
"0o7777",
"if... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StatFilter.ParseObjs | Parse one or more objects by testing if it has matching stat results.
Args:
objs: An iterable of objects that should be checked.
expression: A StatFilter expression, e.g.:
"uid:>0 gid:=0 file_type:link"
Yields:
matching objects. | grr/server/grr_response_server/check_lib/filters.py | def ParseObjs(self, objs, expression):
"""Parse one or more objects by testing if it has matching stat results.
Args:
objs: An iterable of objects that should be checked.
expression: A StatFilter expression, e.g.:
"uid:>0 gid:=0 file_type:link"
Yields:
matching objects.
"""
... | def ParseObjs(self, objs, expression):
"""Parse one or more objects by testing if it has matching stat results.
Args:
objs: An iterable of objects that should be checked.
expression: A StatFilter expression, e.g.:
"uid:>0 gid:=0 file_type:link"
Yields:
matching objects.
"""
... | [
"Parse",
"one",
"or",
"more",
"objects",
"by",
"testing",
"if",
"it",
"has",
"matching",
"stat",
"results",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L440-L460 | [
"def",
"ParseObjs",
"(",
"self",
",",
"objs",
",",
"expression",
")",
":",
"self",
".",
"Validate",
"(",
"expression",
")",
"for",
"obj",
"in",
"objs",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"rdf_client_fs",
".",
"StatEntry",
")",
":",
"conti... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StatFilter.Validate | Validates that a parsed rule entry is valid for fschecker.
Args:
expression: A rule expression.
Raises:
DefinitionError: If the filter definition could not be validated.
Returns:
True if the expression validated OK. | grr/server/grr_response_server/check_lib/filters.py | def Validate(self, expression):
"""Validates that a parsed rule entry is valid for fschecker.
Args:
expression: A rule expression.
Raises:
DefinitionError: If the filter definition could not be validated.
Returns:
True if the expression validated OK.
"""
parsed = self._Load(... | def Validate(self, expression):
"""Validates that a parsed rule entry is valid for fschecker.
Args:
expression: A rule expression.
Raises:
DefinitionError: If the filter definition could not be validated.
Returns:
True if the expression validated OK.
"""
parsed = self._Load(... | [
"Validates",
"that",
"a",
"parsed",
"rule",
"entry",
"is",
"valid",
"for",
"fschecker",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L462-L539 | [
"def",
"Validate",
"(",
"self",
",",
"expression",
")",
":",
"parsed",
"=",
"self",
".",
"_Load",
"(",
"expression",
")",
"if",
"not",
"parsed",
":",
"raise",
"DefinitionError",
"(",
"\"Empty StatFilter expression.\"",
")",
"bad_keys",
"=",
"set",
"(",
"pars... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | RDFFilter.ParseObjs | Parse one or more objects by testing if it is a known RDF class. | grr/server/grr_response_server/check_lib/filters.py | def ParseObjs(self, objs, type_names):
"""Parse one or more objects by testing if it is a known RDF class."""
for obj in objs:
for type_name in self._RDFTypes(type_names):
if isinstance(obj, self._GetClass(type_name)):
yield obj | def ParseObjs(self, objs, type_names):
"""Parse one or more objects by testing if it is a known RDF class."""
for obj in objs:
for type_name in self._RDFTypes(type_names):
if isinstance(obj, self._GetClass(type_name)):
yield obj | [
"Parse",
"one",
"or",
"more",
"objects",
"by",
"testing",
"if",
"it",
"is",
"a",
"known",
"RDF",
"class",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L552-L557 | [
"def",
"ParseObjs",
"(",
"self",
",",
"objs",
",",
"type_names",
")",
":",
"for",
"obj",
"in",
"objs",
":",
"for",
"type_name",
"in",
"self",
".",
"_RDFTypes",
"(",
"type_names",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"self",
".",
"_GetClass",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | RDFFilter.Validate | Filtered types need to be RDFValues. | grr/server/grr_response_server/check_lib/filters.py | def Validate(self, type_names):
"""Filtered types need to be RDFValues."""
errs = [n for n in self._RDFTypes(type_names) if not self._GetClass(n)]
if errs:
raise DefinitionError("Undefined RDF Types: %s" % ",".join(errs)) | def Validate(self, type_names):
"""Filtered types need to be RDFValues."""
errs = [n for n in self._RDFTypes(type_names) if not self._GetClass(n)]
if errs:
raise DefinitionError("Undefined RDF Types: %s" % ",".join(errs)) | [
"Filtered",
"types",
"need",
"to",
"be",
"RDFValues",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/filters.py#L559-L563 | [
"def",
"Validate",
"(",
"self",
",",
"type_names",
")",
":",
"errs",
"=",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"_RDFTypes",
"(",
"type_names",
")",
"if",
"not",
"self",
".",
"_GetClass",
"(",
"n",
")",
"]",
"if",
"errs",
":",
"raise",
"Definiti... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | main | Main. | grr/server/grr_response_server/bin/worker.py | def main(argv):
"""Main."""
del argv # Unused.
if flags.FLAGS.version:
print("GRR worker {}".format(config_server.VERSION["packageversion"]))
return
config.CONFIG.AddContext(contexts.WORKER_CONTEXT,
"Context applied when running a worker.")
# Initialise flows and config_... | def main(argv):
"""Main."""
del argv # Unused.
if flags.FLAGS.version:
print("GRR worker {}".format(config_server.VERSION["packageversion"]))
return
config.CONFIG.AddContext(contexts.WORKER_CONTEXT,
"Context applied when running a worker.")
# Initialise flows and config_... | [
"Main",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/worker.py#L37-L56 | [
"def",
"main",
"(",
"argv",
")",
":",
"del",
"argv",
"# Unused.",
"if",
"flags",
".",
"FLAGS",
".",
"version",
":",
"print",
"(",
"\"GRR worker {}\"",
".",
"format",
"(",
"config_server",
".",
"VERSION",
"[",
"\"packageversion\"",
"]",
")",
")",
"return",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetName | A compatibility wrapper for getting object's name.
In Python 2 class names are returned as `bytes` (since class names can contain
only ASCII characters) whereas in Python 3 they are `unicode` (since class
names can contain arbitrary unicode characters).
This function makes this behaviour consistent and always... | grr/core/grr_response_core/lib/util/compatibility.py | def GetName(obj):
"""A compatibility wrapper for getting object's name.
In Python 2 class names are returned as `bytes` (since class names can contain
only ASCII characters) whereas in Python 3 they are `unicode` (since class
names can contain arbitrary unicode characters).
This function makes this behaviou... | def GetName(obj):
"""A compatibility wrapper for getting object's name.
In Python 2 class names are returned as `bytes` (since class names can contain
only ASCII characters) whereas in Python 3 they are `unicode` (since class
names can contain arbitrary unicode characters).
This function makes this behaviou... | [
"A",
"compatibility",
"wrapper",
"for",
"getting",
"object",
"s",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L80-L104 | [
"def",
"GetName",
"(",
"obj",
")",
":",
"precondition",
".",
"AssertType",
"(",
"obj",
",",
"(",
"type",
",",
"types",
".",
"FunctionType",
")",
")",
"if",
"PY2",
":",
"return",
"obj",
".",
"__name__",
".",
"decode",
"(",
"\"ascii\"",
")",
"else",
":... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SetName | A compatibility wrapper for setting object's name.
See documentation for `GetName` for more information.
Args:
obj: A type or function object to set the name for.
name: A name to set. | grr/core/grr_response_core/lib/util/compatibility.py | def SetName(obj, name):
"""A compatibility wrapper for setting object's name.
See documentation for `GetName` for more information.
Args:
obj: A type or function object to set the name for.
name: A name to set.
"""
# Not doing type assertion on obj, since it may be a mock object used
# in tests.
... | def SetName(obj, name):
"""A compatibility wrapper for setting object's name.
See documentation for `GetName` for more information.
Args:
obj: A type or function object to set the name for.
name: A name to set.
"""
# Not doing type assertion on obj, since it may be a mock object used
# in tests.
... | [
"A",
"compatibility",
"wrapper",
"for",
"setting",
"object",
"s",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L107-L123 | [
"def",
"SetName",
"(",
"obj",
",",
"name",
")",
":",
"# Not doing type assertion on obj, since it may be a mock object used",
"# in tests.",
"precondition",
".",
"AssertType",
"(",
"name",
",",
"str",
")",
"if",
"PY2",
":",
"obj",
".",
"__name__",
"=",
"name",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ListAttrs | A compatibility wrapper for listing class attributes.
This method solves similar Python 2 compatibility issues for `dir` function as
`GetName` does for `__name__` invocations. See documentation for `GetName` for
more details.
Once support for Python 2 is dropped all invocations of this function should
be re... | grr/core/grr_response_core/lib/util/compatibility.py | def ListAttrs(cls):
"""A compatibility wrapper for listing class attributes.
This method solves similar Python 2 compatibility issues for `dir` function as
`GetName` does for `__name__` invocations. See documentation for `GetName` for
more details.
Once support for Python 2 is dropped all invocations of thi... | def ListAttrs(cls):
"""A compatibility wrapper for listing class attributes.
This method solves similar Python 2 compatibility issues for `dir` function as
`GetName` does for `__name__` invocations. See documentation for `GetName` for
more details.
Once support for Python 2 is dropped all invocations of thi... | [
"A",
"compatibility",
"wrapper",
"for",
"listing",
"class",
"attributes",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L126-L149 | [
"def",
"ListAttrs",
"(",
"cls",
")",
":",
"precondition",
".",
"AssertType",
"(",
"cls",
",",
"type",
")",
"if",
"PY2",
":",
"# TODO(user): once https://github.com/google/pytype/issues/127 is fixed,",
"# pytype should be able to tell that this line is unreachable in py3.",
"ret... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MakeType | A compatibility wrapper for the `type` built-in function.
In Python 2 `type` (used as a type constructor) requires the name argument to
be a `bytes` object whereas in Python 3 it is required to be an `unicode`
object. Since class name is human readable text rather than arbitrary stream
of bytes, the Python 3 b... | grr/core/grr_response_core/lib/util/compatibility.py | def MakeType(name, base_classes,
namespace):
"""A compatibility wrapper for the `type` built-in function.
In Python 2 `type` (used as a type constructor) requires the name argument to
be a `bytes` object whereas in Python 3 it is required to be an `unicode`
object. Since class name is human readab... | def MakeType(name, base_classes,
namespace):
"""A compatibility wrapper for the `type` built-in function.
In Python 2 `type` (used as a type constructor) requires the name argument to
be a `bytes` object whereas in Python 3 it is required to be an `unicode`
object. Since class name is human readab... | [
"A",
"compatibility",
"wrapper",
"for",
"the",
"type",
"built",
"-",
"in",
"function",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L152-L179 | [
"def",
"MakeType",
"(",
"name",
",",
"base_classes",
",",
"namespace",
")",
":",
"precondition",
".",
"AssertType",
"(",
"name",
",",
"str",
")",
"if",
"PY2",
":",
"name",
"=",
"name",
".",
"encode",
"(",
"\"ascii\"",
")",
"return",
"type",
"(",
"name"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FormatTime | A compatibility wrapper for the `strftime` function.
It is guaranteed to always take unicode string as an argument and return an
unicode string as a result.
Args:
fmt: A format string specifying formatting of the output.
stime: A time representation as returned by `gmtime` or `localtime`.
Returns:
... | grr/core/grr_response_core/lib/util/compatibility.py | def FormatTime(fmt, stime = None):
"""A compatibility wrapper for the `strftime` function.
It is guaranteed to always take unicode string as an argument and return an
unicode string as a result.
Args:
fmt: A format string specifying formatting of the output.
stime: A time representation as returned by... | def FormatTime(fmt, stime = None):
"""A compatibility wrapper for the `strftime` function.
It is guaranteed to always take unicode string as an argument and return an
unicode string as a result.
Args:
fmt: A format string specifying formatting of the output.
stime: A time representation as returned by... | [
"A",
"compatibility",
"wrapper",
"for",
"the",
"strftime",
"function",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L182-L210 | [
"def",
"FormatTime",
"(",
"fmt",
",",
"stime",
"=",
"None",
")",
":",
"precondition",
".",
"AssertType",
"(",
"fmt",
",",
"str",
")",
"precondition",
".",
"AssertOptionalType",
"(",
"stime",
",",
"time",
".",
"struct_time",
")",
"# TODO(hanuszczak): https://gi... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ShlexSplit | A wrapper for `shlex.split` that works with unicode objects.
Args:
string: A unicode string to split.
Returns:
A list of unicode strings representing parts of the input string. | grr/core/grr_response_core/lib/util/compatibility.py | def ShlexSplit(string):
"""A wrapper for `shlex.split` that works with unicode objects.
Args:
string: A unicode string to split.
Returns:
A list of unicode strings representing parts of the input string.
"""
precondition.AssertType(string, Text)
if PY2:
string = string.encode("utf-8")
part... | def ShlexSplit(string):
"""A wrapper for `shlex.split` that works with unicode objects.
Args:
string: A unicode string to split.
Returns:
A list of unicode strings representing parts of the input string.
"""
precondition.AssertType(string, Text)
if PY2:
string = string.encode("utf-8")
part... | [
"A",
"wrapper",
"for",
"shlex",
".",
"split",
"that",
"works",
"with",
"unicode",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L214-L236 | [
"def",
"ShlexSplit",
"(",
"string",
")",
":",
"precondition",
".",
"AssertType",
"(",
"string",
",",
"Text",
")",
"if",
"PY2",
":",
"string",
"=",
"string",
".",
"encode",
"(",
"\"utf-8\"",
")",
"parts",
"=",
"shlex",
".",
"split",
"(",
"string",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Environ | A wrapper for `os.environ.get` that works the same way in both Pythons.
Args:
variable: A name of the variable to get the value of.
default: A default value to return in case no value for the given variable
is set.
Returns:
An environment value of the given variable. | grr/core/grr_response_core/lib/util/compatibility.py | def Environ(variable, default):
"""A wrapper for `os.environ.get` that works the same way in both Pythons.
Args:
variable: A name of the variable to get the value of.
default: A default value to return in case no value for the given variable
is set.
Returns:
An environment value of the given v... | def Environ(variable, default):
"""A wrapper for `os.environ.get` that works the same way in both Pythons.
Args:
variable: A name of the variable to get the value of.
default: A default value to return in case no value for the given variable
is set.
Returns:
An environment value of the given v... | [
"A",
"wrapper",
"for",
"os",
".",
"environ",
".",
"get",
"that",
"works",
"the",
"same",
"way",
"in",
"both",
"Pythons",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compatibility.py#L252-L271 | [
"def",
"Environ",
"(",
"variable",
",",
"default",
")",
":",
"precondition",
".",
"AssertType",
"(",
"variable",
",",
"Text",
")",
"value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"variable",
",",
"default",
")",
"if",
"value",
"is",
"None",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Dump | Stringifies a Python object into its JSON representation.
Args:
obj: A Python object to convert to JSON.
sort_keys: If True, output dictionaries keys in sorted (ascending) order.
encoder: An (optional) encoder class to use.
Returns:
A JSON representation of the given object. | grr/core/grr_response_core/lib/util/compat/json.py | def Dump(obj,
sort_keys = False,
encoder = None):
"""Stringifies a Python object into its JSON representation.
Args:
obj: A Python object to convert to JSON.
sort_keys: If True, output dictionaries keys in sorted (ascending) order.
encoder: An (optional) encoder class to use.
Retur... | def Dump(obj,
sort_keys = False,
encoder = None):
"""Stringifies a Python object into its JSON representation.
Args:
obj: A Python object to convert to JSON.
sort_keys: If True, output dictionaries keys in sorted (ascending) order.
encoder: An (optional) encoder class to use.
Retur... | [
"Stringifies",
"a",
"Python",
"object",
"into",
"its",
"JSON",
"representation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compat/json.py#L69-L101 | [
"def",
"Dump",
"(",
"obj",
",",
"sort_keys",
"=",
"False",
",",
"encoder",
"=",
"None",
")",
":",
"# Python 2 json.dumps expects separators as a tuple of bytes, while",
"# Python 3 expects them to be a tuple of unicode strings. Pytype",
"# is too dumb to infer the result of the if st... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DropPrivileges | Attempt to drop privileges if required. | grr/server/grr_response_server/server_startup.py | def DropPrivileges():
"""Attempt to drop privileges if required."""
if config.CONFIG["Server.username"]:
try:
os.setuid(pwd.getpwnam(config.CONFIG["Server.username"]).pw_uid)
except (KeyError, OSError):
logging.exception("Unable to switch to user %s",
config.CONFIG["Serve... | def DropPrivileges():
"""Attempt to drop privileges if required."""
if config.CONFIG["Server.username"]:
try:
os.setuid(pwd.getpwnam(config.CONFIG["Server.username"]).pw_uid)
except (KeyError, OSError):
logging.exception("Unable to switch to user %s",
config.CONFIG["Serve... | [
"Attempt",
"to",
"drop",
"privileges",
"if",
"required",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_startup.py#L41-L49 | [
"def",
"DropPrivileges",
"(",
")",
":",
"if",
"config",
".",
"CONFIG",
"[",
"\"Server.username\"",
"]",
":",
"try",
":",
"os",
".",
"setuid",
"(",
"pwd",
".",
"getpwnam",
"(",
"config",
".",
"CONFIG",
"[",
"\"Server.username\"",
"]",
")",
".",
"pw_uid",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Init | Run all required startup routines and initialization hooks. | grr/server/grr_response_server/server_startup.py | def Init():
"""Run all required startup routines and initialization hooks."""
global INIT_RAN
if INIT_RAN:
return
# Set up a temporary syslog handler so we have somewhere to log problems
# with ConfigInit() which needs to happen before we can start our create our
# proper logging setup.
syslog_logger... | def Init():
"""Run all required startup routines and initialization hooks."""
global INIT_RAN
if INIT_RAN:
return
# Set up a temporary syslog handler so we have somewhere to log problems
# with ConfigInit() which needs to happen before we can start our create our
# proper logging setup.
syslog_logger... | [
"Run",
"all",
"required",
"startup",
"routines",
"and",
"initialization",
"hooks",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/server_startup.py#L56-L101 | [
"def",
"Init",
"(",
")",
":",
"global",
"INIT_RAN",
"if",
"INIT_RAN",
":",
"return",
"# Set up a temporary syslog handler so we have somewhere to log problems",
"# with ConfigInit() which needs to happen before we can start our create our",
"# proper logging setup.",
"syslog_logger",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VersionPath | Returns a path to version.ini. | grr/core/grr_response_core/version.py | def VersionPath():
"""Returns a path to version.ini."""
# Try to get a version.ini. It should be in the resources if the code
# was packed with "pip sdist". It will be 2 levels up from grr_response_core
# if the code was installed via "pip install -e".
version_ini = (
package.ResourcePath("grr-response... | def VersionPath():
"""Returns a path to version.ini."""
# Try to get a version.ini. It should be in the resources if the code
# was packed with "pip sdist". It will be 2 levels up from grr_response_core
# if the code was installed via "pip install -e".
version_ini = (
package.ResourcePath("grr-response... | [
"Returns",
"a",
"path",
"to",
"version",
".",
"ini",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/version.py#L15-L28 | [
"def",
"VersionPath",
"(",
")",
":",
"# Try to get a version.ini. It should be in the resources if the code",
"# was packed with \"pip sdist\". It will be 2 levels up from grr_response_core",
"# if the code was installed via \"pip install -e\".",
"version_ini",
"=",
"(",
"package",
".",
"R... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Version | Return a dict with GRR version information. | grr/core/grr_response_core/version.py | def Version():
"""Return a dict with GRR version information."""
version_ini = VersionPath()
config = configparser.SafeConfigParser()
config.read(version_ini)
return dict(
packageversion=config.get("Version", "packageversion"),
major=config.getint("Version", "major"),
minor=config.getint("... | def Version():
"""Return a dict with GRR version information."""
version_ini = VersionPath()
config = configparser.SafeConfigParser()
config.read(version_ini)
return dict(
packageversion=config.get("Version", "packageversion"),
major=config.getint("Version", "major"),
minor=config.getint("... | [
"Return",
"a",
"dict",
"with",
"GRR",
"version",
"information",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/version.py#L31-L43 | [
"def",
"Version",
"(",
")",
":",
"version_ini",
"=",
"VersionPath",
"(",
")",
"config",
"=",
"configparser",
".",
"SafeConfigParser",
"(",
")",
"config",
".",
"read",
"(",
"version_ini",
")",
"return",
"dict",
"(",
"packageversion",
"=",
"config",
".",
"ge... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Process.Regions | Iterates over the readable regions for this process.
We use mach_vm_region_recurse here to get a fine grained view of
the process' memory space. The algorithm is that for some regions,
the function returns is_submap=True which means that there are
actually subregions that we need to examine by increasi... | grr/client/grr_response_client/osx/process.py | def Regions(self,
skip_executable_regions=False,
skip_shared_regions=False,
skip_readonly_regions=False):
"""Iterates over the readable regions for this process.
We use mach_vm_region_recurse here to get a fine grained view of
the process' memory space. The algorit... | def Regions(self,
skip_executable_regions=False,
skip_shared_regions=False,
skip_readonly_regions=False):
"""Iterates over the readable regions for this process.
We use mach_vm_region_recurse here to get a fine grained view of
the process' memory space. The algorit... | [
"Iterates",
"over",
"the",
"readable",
"regions",
"for",
"this",
"process",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/process.py#L96-L183 | [
"def",
"Regions",
"(",
"self",
",",
"skip_executable_regions",
"=",
"False",
",",
"skip_shared_regions",
"=",
"False",
",",
"skip_readonly_regions",
"=",
"False",
")",
":",
"address",
"=",
"ctypes",
".",
"c_ulong",
"(",
"0",
")",
"mapsize",
"=",
"ctypes",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Process.ReadBytes | Reads at most num_bytes starting from offset <address>. | grr/client/grr_response_client/osx/process.py | def ReadBytes(self, address, num_bytes):
"""Reads at most num_bytes starting from offset <address>."""
pdata = ctypes.c_void_p(0)
data_cnt = ctypes.c_uint32(0)
ret = libc.mach_vm_read(self.task, ctypes.c_ulonglong(address),
ctypes.c_longlong(num_bytes), ctypes.pointer(pdata)... | def ReadBytes(self, address, num_bytes):
"""Reads at most num_bytes starting from offset <address>."""
pdata = ctypes.c_void_p(0)
data_cnt = ctypes.c_uint32(0)
ret = libc.mach_vm_read(self.task, ctypes.c_ulonglong(address),
ctypes.c_longlong(num_bytes), ctypes.pointer(pdata)... | [
"Reads",
"at",
"most",
"num_bytes",
"starting",
"from",
"offset",
"<address",
">",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/process.py#L185-L197 | [
"def",
"ReadBytes",
"(",
"self",
",",
"address",
",",
"num_bytes",
")",
":",
"pdata",
"=",
"ctypes",
".",
"c_void_p",
"(",
"0",
")",
"data_cnt",
"=",
"ctypes",
".",
"c_uint32",
"(",
"0",
")",
"ret",
"=",
"libc",
".",
"mach_vm_read",
"(",
"self",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BinarySIDtoStringSID | Converts a binary SID to its string representation.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379597.aspx
The byte representation of an SID is as follows:
Offset Length Description
00 01 revision
01 01 sub-authority count
02 06 authority (big endian... | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def BinarySIDtoStringSID(sid):
"""Converts a binary SID to its string representation.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379597.aspx
The byte representation of an SID is as follows:
Offset Length Description
00 01 revision
01 01 sub-authority count
0... | def BinarySIDtoStringSID(sid):
"""Converts a binary SID to its string representation.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379597.aspx
The byte representation of an SID is as follows:
Offset Length Description
00 01 revision
01 01 sub-authority count
0... | [
"Converts",
"a",
"binary",
"SID",
"to",
"its",
"string",
"representation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L30-L91 | [
"def",
"BinarySIDtoStringSID",
"(",
"sid",
")",
":",
"precondition",
".",
"AssertType",
"(",
"sid",
",",
"bytes",
")",
"# TODO: This seemingly no-op is actually not a no-op. The reason",
"# is that `sid` might be either `bytes` from the future package or `str` (e.g.",
"# a bytes lite... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIEventConsumerParser.ParseMultiple | Parse WMI Event Consumers. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse WMI Event Consumers."""
for result_dict in result_dicts:
wmi_dict = result_dict.ToDict()
try:
creator_sid_bytes = bytes(wmi_dict["CreatorSID"])
wmi_dict["CreatorSID"] = BinarySIDtoStringSID(creator_sid_bytes)
except ValueError:
... | def ParseMultiple(self, result_dicts):
"""Parse WMI Event Consumers."""
for result_dict in result_dicts:
wmi_dict = result_dict.ToDict()
try:
creator_sid_bytes = bytes(wmi_dict["CreatorSID"])
wmi_dict["CreatorSID"] = BinarySIDtoStringSID(creator_sid_bytes)
except ValueError:
... | [
"Parse",
"WMI",
"Event",
"Consumers",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L99-L138 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"for",
"result_dict",
"in",
"result_dicts",
":",
"wmi_dict",
"=",
"result_dict",
".",
"ToDict",
"(",
")",
"try",
":",
"creator_sid_bytes",
"=",
"bytes",
"(",
"wmi_dict",
"[",
"\"CreatorSID\"",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIInstalledSoftwareParser.ParseMultiple | Parse the WMI packages output. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
status = rdf_client.SoftwarePackage.InstallState.INSTALLED
packages = []
for result_dict in result_dicts:
packages.append(
rdf_client.SoftwarePackage(
name=result_dict["Name"],
descrip... | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
status = rdf_client.SoftwarePackage.InstallState.INSTALLED
packages = []
for result_dict in result_dicts:
packages.append(
rdf_client.SoftwarePackage(
name=result_dict["Name"],
descrip... | [
"Parse",
"the",
"WMI",
"packages",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L167-L180 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"status",
"=",
"rdf_client",
".",
"SoftwarePackage",
".",
"InstallState",
".",
"INSTALLED",
"packages",
"=",
"[",
"]",
"for",
"result_dict",
"in",
"result_dicts",
":",
"packages",
".",
"append... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIHotfixesSoftwareParser.AmericanDateToEpoch | Take a US format date and return epoch. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def AmericanDateToEpoch(self, date_str):
"""Take a US format date and return epoch."""
try:
epoch = time.strptime(date_str, "%m/%d/%Y")
return int(calendar.timegm(epoch)) * 1000000
except ValueError:
return 0 | def AmericanDateToEpoch(self, date_str):
"""Take a US format date and return epoch."""
try:
epoch = time.strptime(date_str, "%m/%d/%Y")
return int(calendar.timegm(epoch)) * 1000000
except ValueError:
return 0 | [
"Take",
"a",
"US",
"format",
"date",
"and",
"return",
"epoch",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L189-L195 | [
"def",
"AmericanDateToEpoch",
"(",
"self",
",",
"date_str",
")",
":",
"try",
":",
"epoch",
"=",
"time",
".",
"strptime",
"(",
"date_str",
",",
"\"%m/%d/%Y\"",
")",
"return",
"int",
"(",
"calendar",
".",
"timegm",
"(",
"epoch",
")",
")",
"*",
"1000000",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIHotfixesSoftwareParser.ParseMultiple | Parse the WMI packages output. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
status = rdf_client.SoftwarePackage.InstallState.INSTALLED
packages = []
for result_dict in result_dicts:
result = result_dict.ToDict()
# InstalledOn comes back in a godawful format such as '7/10/2013'.
insta... | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
status = rdf_client.SoftwarePackage.InstallState.INSTALLED
packages = []
for result_dict in result_dicts:
result = result_dict.ToDict()
# InstalledOn comes back in a godawful format such as '7/10/2013'.
insta... | [
"Parse",
"the",
"WMI",
"packages",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L197-L216 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"status",
"=",
"rdf_client",
".",
"SoftwarePackage",
".",
"InstallState",
".",
"INSTALLED",
"packages",
"=",
"[",
"]",
"for",
"result_dict",
"in",
"result_dicts",
":",
"result",
"=",
"result_d... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIUserParser.ParseMultiple | Parse the WMI Win32_UserAccount output. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI Win32_UserAccount output."""
for result_dict in result_dicts:
kb_user = rdf_client.User()
for wmi_key, kb_key in iteritems(self.account_mapping):
try:
kb_user.Set(kb_key, result_dict[wmi_key])
except KeyError:
... | def ParseMultiple(self, result_dicts):
"""Parse the WMI Win32_UserAccount output."""
for result_dict in result_dicts:
kb_user = rdf_client.User()
for wmi_key, kb_key in iteritems(self.account_mapping):
try:
kb_user.Set(kb_key, result_dict[wmi_key])
except KeyError:
... | [
"Parse",
"the",
"WMI",
"Win32_UserAccount",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L236-L250 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"for",
"result_dict",
"in",
"result_dicts",
":",
"kb_user",
"=",
"rdf_client",
".",
"User",
"(",
")",
"for",
"wmi_key",
",",
"kb_key",
"in",
"iteritems",
"(",
"self",
".",
"account_mapping",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMILogicalDisksParser.ParseMultiple | Parse the WMI packages output. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
for result_dict in result_dicts:
result = result_dict.ToDict()
winvolume = rdf_client_fs.WindowsVolume(
drive_letter=result.get("DeviceID"),
drive_type=result.get("DriveType"))
try:
size = ... | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
for result_dict in result_dicts:
result = result_dict.ToDict()
winvolume = rdf_client_fs.WindowsVolume(
drive_letter=result.get("DeviceID"),
drive_type=result.get("DriveType"))
try:
size = ... | [
"Parse",
"the",
"WMI",
"packages",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L259-L286 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"for",
"result_dict",
"in",
"result_dicts",
":",
"result",
"=",
"result_dict",
".",
"ToDict",
"(",
")",
"winvolume",
"=",
"rdf_client_fs",
".",
"WindowsVolume",
"(",
"drive_letter",
"=",
"resu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIComputerSystemProductParser.ParseMultiple | Parse the WMI output to get Identifying Number. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI output to get Identifying Number."""
for result_dict in result_dicts:
# Currently we are only grabbing the Identifying Number
# as the serial number (catches the unique number for VMs).
# This could be changed to include more information ... | def ParseMultiple(self, result_dicts):
"""Parse the WMI output to get Identifying Number."""
for result_dict in result_dicts:
# Currently we are only grabbing the Identifying Number
# as the serial number (catches the unique number for VMs).
# This could be changed to include more information ... | [
"Parse",
"the",
"WMI",
"output",
"to",
"get",
"Identifying",
"Number",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L295-L305 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"for",
"result_dict",
"in",
"result_dicts",
":",
"# Currently we are only grabbing the Identifying Number",
"# as the serial number (catches the unique number for VMs).",
"# This could be changed to include more inform... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIInterfacesParser.WMITimeStrToRDFDatetime | Return RDFDatetime from string like 20140825162259.000000-420.
Args:
timestr: WMI time string
Returns:
rdfvalue.RDFDatetime
We have some timezone manipulation work to do here because the UTC offset is
in minutes rather than +-HHMM | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def WMITimeStrToRDFDatetime(self, timestr):
"""Return RDFDatetime from string like 20140825162259.000000-420.
Args:
timestr: WMI time string
Returns:
rdfvalue.RDFDatetime
We have some timezone manipulation work to do here because the UTC offset is
in minutes rather than +-HHMM
"""... | def WMITimeStrToRDFDatetime(self, timestr):
"""Return RDFDatetime from string like 20140825162259.000000-420.
Args:
timestr: WMI time string
Returns:
rdfvalue.RDFDatetime
We have some timezone manipulation work to do here because the UTC offset is
in minutes rather than +-HHMM
"""... | [
"Return",
"RDFDatetime",
"from",
"string",
"like",
"20140825162259",
".",
"000000",
"-",
"420",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L317-L343 | [
"def",
"WMITimeStrToRDFDatetime",
"(",
"self",
",",
"timestr",
")",
":",
"# We use manual parsing here because the time functions provided (datetime,",
"# dateutil) do not properly deal with timezone information.",
"offset_minutes",
"=",
"timestr",
"[",
"21",
":",
"]",
"year",
"=... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WMIInterfacesParser.ParseMultiple | Parse the WMI packages output. | grr/core/grr_response_core/lib/parsers/wmi_parser.py | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
for result_dict in result_dicts:
args = {"ifname": result_dict["Description"]}
args["mac_address"] = binascii.unhexlify(
result_dict["MACAddress"].replace(":", ""))
self._ConvertIPs([("IPAddress", "addresses... | def ParseMultiple(self, result_dicts):
"""Parse the WMI packages output."""
for result_dict in result_dicts:
args = {"ifname": result_dict["Description"]}
args["mac_address"] = binascii.unhexlify(
result_dict["MACAddress"].replace(":", ""))
self._ConvertIPs([("IPAddress", "addresses... | [
"Parse",
"the",
"WMI",
"packages",
"output",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L360-L383 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"result_dicts",
")",
":",
"for",
"result_dict",
"in",
"result_dicts",
":",
"args",
"=",
"{",
"\"ifname\"",
":",
"result_dict",
"[",
"\"Description\"",
"]",
"}",
"args",
"[",
"\"mac_address\"",
"]",
"=",
"binascii",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _ClientIDFromSessionID | Extracts the client id from a session id. | grr/server/grr_response_server/rdfvalues/flow_objects.py | def _ClientIDFromSessionID(session_id):
"""Extracts the client id from a session id."""
parts = session_id.Split(4)
client_id = parts[0]
if re.match(r"C\.[0-9a-f]{16}", client_id):
return client_id
# Maybe it's a legacy hunt id (aff4:/hunts/<hunt_id>/<client_id>/...
client_id = parts[2]
if re.match(... | def _ClientIDFromSessionID(session_id):
"""Extracts the client id from a session id."""
parts = session_id.Split(4)
client_id = parts[0]
if re.match(r"C\.[0-9a-f]{16}", client_id):
return client_id
# Maybe it's a legacy hunt id (aff4:/hunts/<hunt_id>/<client_id>/...
client_id = parts[2]
if re.match(... | [
"Extracts",
"the",
"client",
"id",
"from",
"a",
"session",
"id",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/flow_objects.py#L165-L178 | [
"def",
"_ClientIDFromSessionID",
"(",
"session_id",
")",
":",
"parts",
"=",
"session_id",
".",
"Split",
"(",
"4",
")",
"client_id",
"=",
"parts",
"[",
"0",
"]",
"if",
"re",
".",
"match",
"(",
"r\"C\\.[0-9a-f]{16}\"",
",",
"client_id",
")",
":",
"return",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowResponseForLegacyResponse | Helper function to convert legacy client replies to flow responses. | grr/server/grr_response_server/rdfvalues/flow_objects.py | def FlowResponseForLegacyResponse(legacy_msg):
"""Helper function to convert legacy client replies to flow responses."""
if legacy_msg.type == legacy_msg.Type.MESSAGE:
response = FlowResponse(
client_id=_ClientIDFromSessionID(legacy_msg.session_id),
flow_id=legacy_msg.session_id.Basename(),
... | def FlowResponseForLegacyResponse(legacy_msg):
"""Helper function to convert legacy client replies to flow responses."""
if legacy_msg.type == legacy_msg.Type.MESSAGE:
response = FlowResponse(
client_id=_ClientIDFromSessionID(legacy_msg.session_id),
flow_id=legacy_msg.session_id.Basename(),
... | [
"Helper",
"function",
"to",
"convert",
"legacy",
"client",
"replies",
"to",
"flow",
"responses",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/flow_objects.py#L197-L230 | [
"def",
"FlowResponseForLegacyResponse",
"(",
"legacy_msg",
")",
":",
"if",
"legacy_msg",
".",
"type",
"==",
"legacy_msg",
".",
"Type",
".",
"MESSAGE",
":",
"response",
"=",
"FlowResponse",
"(",
"client_id",
"=",
"_ClientIDFromSessionID",
"(",
"legacy_msg",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | OSXQuarantineEvents.Parse | Iterator returning dict for each entry in history. | grr/core/grr_response_core/lib/parsers/osx_quarantine.py | def Parse(self):
"""Iterator returning dict for each entry in history."""
for data in self.Query(self.EVENTS_QUERY):
(timestamp, agent_bundle_identifier, agent_name, url, sender,
sender_address, type_number, title, referrer, referrer_alias) = data
yield [
timestamp, "OSX_QUARANTINE"... | def Parse(self):
"""Iterator returning dict for each entry in history."""
for data in self.Query(self.EVENTS_QUERY):
(timestamp, agent_bundle_identifier, agent_name, url, sender,
sender_address, type_number, title, referrer, referrer_alias) = data
yield [
timestamp, "OSX_QUARANTINE"... | [
"Iterator",
"returning",
"dict",
"for",
"each",
"entry",
"in",
"history",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_quarantine.py#L30-L39 | [
"def",
"Parse",
"(",
"self",
")",
":",
"for",
"data",
"in",
"self",
".",
"Query",
"(",
"self",
".",
"EVENTS_QUERY",
")",
":",
"(",
"timestamp",
",",
"agent_bundle_identifier",
",",
"agent_name",
",",
"url",
",",
"sender",
",",
"sender_address",
",",
"typ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IPResolver.RetrieveIP4Info | Retrieves information for an IP4 address. | grr/server/grr_response_server/ip_resolver.py | def RetrieveIP4Info(self, ip):
"""Retrieves information for an IP4 address."""
if ip.is_private:
return (IPInfo.INTERNAL, "Internal IP address.")
try:
# It's an external IP, let's try to do a reverse lookup.
res = socket.getnameinfo((str(ip), 0), socket.NI_NAMEREQD)
return (IPInfo.EX... | def RetrieveIP4Info(self, ip):
"""Retrieves information for an IP4 address."""
if ip.is_private:
return (IPInfo.INTERNAL, "Internal IP address.")
try:
# It's an external IP, let's try to do a reverse lookup.
res = socket.getnameinfo((str(ip), 0), socket.NI_NAMEREQD)
return (IPInfo.EX... | [
"Retrieves",
"information",
"for",
"an",
"IP4",
"address",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/ip_resolver.py#L61-L70 | [
"def",
"RetrieveIP4Info",
"(",
"self",
",",
"ip",
")",
":",
"if",
"ip",
".",
"is_private",
":",
"return",
"(",
"IPInfo",
".",
"INTERNAL",
",",
"\"Internal IP address.\"",
")",
"try",
":",
"# It's an external IP, let's try to do a reverse lookup.",
"res",
"=",
"soc... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Pool.get | Gets a connection.
Args:
blocking: Whether to block when max_size connections are already in use.
If false, may return None.
Returns:
A connection to the database.
Raises:
PoolAlreadyClosedError: if close() method was already called on
this pool. | grr/server/grr_response_server/databases/mysql_pool.py | def get(self, blocking=True):
"""Gets a connection.
Args:
blocking: Whether to block when max_size connections are already in use.
If false, may return None.
Returns:
A connection to the database.
Raises:
PoolAlreadyClosedError: if close() method was already called on
... | def get(self, blocking=True):
"""Gets a connection.
Args:
blocking: Whether to block when max_size connections are already in use.
If false, may return None.
Returns:
A connection to the database.
Raises:
PoolAlreadyClosedError: if close() method was already called on
... | [
"Gets",
"a",
"connection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_pool.py#L47-L81 | [
"def",
"get",
"(",
"self",
",",
"blocking",
"=",
"True",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"PoolAlreadyClosedError",
"(",
"\"Connection pool is already closed.\"",
")",
"# NOTE: Once we acquire capacity from the semaphore, it is essential that we",
"# ret... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Sdist.CheckTemplates | Verify we have at least one template that matches maj.minor version. | grr/config/grr_response_templates/setup.py | def CheckTemplates(self, base_dir, version):
"""Verify we have at least one template that matches maj.minor version."""
major_minor = ".".join(version.split(".")[0:2])
templates = glob.glob(
os.path.join(base_dir, "templates/*%s*.zip" % major_minor))
required_templates = set(
[x.replace(... | def CheckTemplates(self, base_dir, version):
"""Verify we have at least one template that matches maj.minor version."""
major_minor = ".".join(version.split(".")[0:2])
templates = glob.glob(
os.path.join(base_dir, "templates/*%s*.zip" % major_minor))
required_templates = set(
[x.replace(... | [
"Verify",
"we",
"have",
"at",
"least",
"one",
"template",
"that",
"matches",
"maj",
".",
"minor",
"version",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/config/grr_response_templates/setup.py#L53-L69 | [
"def",
"CheckTemplates",
"(",
"self",
",",
"base_dir",
",",
"version",
")",
":",
"major_minor",
"=",
"\".\"",
".",
"join",
"(",
"version",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
":",
"2",
"]",
")",
"templates",
"=",
"glob",
".",
"glob",
"(",
"o... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _TerminateFlow | Does the actual termination. | grr/server/grr_response_server/flow_base.py | def _TerminateFlow(rdf_flow,
reason=None,
flow_state=rdf_flow_objects.Flow.FlowState.ERROR):
"""Does the actual termination."""
flow_cls = registry.FlowRegistry.FlowClassByName(rdf_flow.flow_class_name)
flow_obj = flow_cls(rdf_flow)
if not flow_obj.IsRunning():
# Nothi... | def _TerminateFlow(rdf_flow,
reason=None,
flow_state=rdf_flow_objects.Flow.FlowState.ERROR):
"""Does the actual termination."""
flow_cls = registry.FlowRegistry.FlowClassByName(rdf_flow.flow_class_name)
flow_obj = flow_cls(rdf_flow)
if not flow_obj.IsRunning():
# Nothi... | [
"Does",
"the",
"actual",
"termination",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L35-L61 | [
"def",
"_TerminateFlow",
"(",
"rdf_flow",
",",
"reason",
"=",
"None",
",",
"flow_state",
"=",
"rdf_flow_objects",
".",
"Flow",
".",
"FlowState",
".",
"ERROR",
")",
":",
"flow_cls",
"=",
"registry",
".",
"FlowRegistry",
".",
"FlowClassByName",
"(",
"rdf_flow",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TerminateFlow | Terminates a flow and all of its children.
Args:
client_id: Client ID of a flow to terminate.
flow_id: Flow ID of a flow to terminate.
reason: String with a termination reason.
flow_state: Flow state to be assigned to a flow after termination. Defaults
to FlowState.ERROR. | grr/server/grr_response_server/flow_base.py | def TerminateFlow(client_id,
flow_id,
reason=None,
flow_state=rdf_flow_objects.Flow.FlowState.ERROR):
"""Terminates a flow and all of its children.
Args:
client_id: Client ID of a flow to terminate.
flow_id: Flow ID of a flow to terminate.
reason: S... | def TerminateFlow(client_id,
flow_id,
reason=None,
flow_state=rdf_flow_objects.Flow.FlowState.ERROR):
"""Terminates a flow and all of its children.
Args:
client_id: Client ID of a flow to terminate.
flow_id: Flow ID of a flow to terminate.
reason: S... | [
"Terminates",
"a",
"flow",
"and",
"all",
"of",
"its",
"children",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L64-L87 | [
"def",
"TerminateFlow",
"(",
"client_id",
",",
"flow_id",
",",
"reason",
"=",
"None",
",",
"flow_state",
"=",
"rdf_flow_objects",
".",
"Flow",
".",
"FlowState",
".",
"ERROR",
")",
":",
"to_terminate",
"=",
"[",
"data_store",
".",
"REL_DB",
".",
"ReadFlowObje... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DualDBFlow | Decorator that creates AFF4 and RELDB flows from a given mixin. | grr/server/grr_response_server/flow_base.py | def DualDBFlow(cls):
"""Decorator that creates AFF4 and RELDB flows from a given mixin."""
if issubclass(cls, flow.GRRFlow):
raise ValueError("Mixin class shouldn't inherit from GRRFlow.")
if cls.__name__[-5:] != "Mixin":
raise ValueError("Flow mixin should have a name that ends in 'Mixin'.")
flow_na... | def DualDBFlow(cls):
"""Decorator that creates AFF4 and RELDB flows from a given mixin."""
if issubclass(cls, flow.GRRFlow):
raise ValueError("Mixin class shouldn't inherit from GRRFlow.")
if cls.__name__[-5:] != "Mixin":
raise ValueError("Flow mixin should have a name that ends in 'Mixin'.")
flow_na... | [
"Decorator",
"that",
"creates",
"AFF4",
"and",
"RELDB",
"flows",
"from",
"a",
"given",
"mixin",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L850-L868 | [
"def",
"DualDBFlow",
"(",
"cls",
")",
":",
"if",
"issubclass",
"(",
"cls",
",",
"flow",
".",
"GRRFlow",
")",
":",
"raise",
"ValueError",
"(",
"\"Mixin class shouldn't inherit from GRRFlow.\"",
")",
"if",
"cls",
".",
"__name__",
"[",
"-",
"5",
":",
"]",
"!=... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.CallState | This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.
start_time: Start the flow at this time. This delays... | grr/server/grr_response_server/flow_base.py | def CallState(self, next_state="", start_time=None):
"""This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.... | def CallState(self, next_state="", start_time=None):
"""This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.... | [
"This",
"method",
"is",
"used",
"to",
"schedule",
"a",
"new",
"state",
"on",
"a",
"different",
"worker",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L139-L165 | [
"def",
"CallState",
"(",
"self",
",",
"next_state",
"=",
"\"\"",
",",
"start_time",
"=",
"None",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"next_state",
")",
":",
"raise",
"ValueError",
"(",
"\"Next state %s is invalid.\"",
"%",
"next_state",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.CallClient | Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run action may
send back many responses that will be queued by the framework until a status
message is sent by the client. The status message will cause the entire
transaction to be committed to the specified s... | grr/server/grr_response_server/flow_base.py | def CallClient(self,
action_cls,
request=None,
next_state=None,
request_data=None,
**kwargs):
"""Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run action may
send back many re... | def CallClient(self,
action_cls,
request=None,
next_state=None,
request_data=None,
**kwargs):
"""Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run action may
send back many re... | [
"Calls",
"the",
"client",
"asynchronously",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L177-L268 | [
"def",
"CallClient",
"(",
"self",
",",
"action_cls",
",",
"request",
"=",
"None",
",",
"next_state",
"=",
"None",
",",
"request_data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"action_identifier",
"=",
"action_registry",
".",
"ID_BY_ACTI... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.CallFlow | Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send back many responses which will be
queued by the framework until the flow terminates. The final status message
will cause the entire transaction to be committed to the specified state.
Args:
flow_nam... | grr/server/grr_response_server/flow_base.py | def CallFlow(self,
flow_name=None,
next_state=None,
request_data=None,
client_id=None,
base_session_id=None,
**kwargs):
"""Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send b... | def CallFlow(self,
flow_name=None,
next_state=None,
request_data=None,
client_id=None,
base_session_id=None,
**kwargs):
"""Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send b... | [
"Creates",
"a",
"new",
"flow",
"and",
"send",
"its",
"responses",
"to",
"a",
"state",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L270-L322 | [
"def",
"CallFlow",
"(",
"self",
",",
"flow_name",
"=",
"None",
",",
"next_state",
"=",
"None",
",",
"request_data",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"base_session_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"getatt... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.SendReply | Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with this tag.
Raises:
ValueError: If responses is not of the correct ty... | grr/server/grr_response_server/flow_base.py | def SendReply(self, response, tag=None):
"""Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with this tag.
Raises:
V... | def SendReply(self, response, tag=None):
"""Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with this tag.
Raises:
V... | [
"Allows",
"this",
"flow",
"to",
"send",
"a",
"message",
"to",
"its",
"parent",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L324-L359 | [
"def",
"SendReply",
"(",
"self",
",",
"response",
",",
"tag",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"response",
",",
"rdfvalue",
".",
"RDFValue",
")",
":",
"raise",
"ValueError",
"(",
"\"SendReply can only send RDFValues\"",
")",
"if",
"self... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.SaveResourceUsage | Method to tally resources. | grr/server/grr_response_server/flow_base.py | def SaveResourceUsage(self, status):
"""Method to tally resources."""
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.rdf_flow.cpu_time_used.user_cpu_time += user_cpu
self.rdf_flow.cpu_time_used.system_cpu_time += system_cpu
self.rdf_flow.net... | def SaveResourceUsage(self, status):
"""Method to tally resources."""
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.rdf_flow.cpu_time_used.user_cpu_time += user_cpu
self.rdf_flow.cpu_time_used.system_cpu_time += system_cpu
self.rdf_flow.net... | [
"Method",
"to",
"tally",
"resources",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L361-L382 | [
"def",
"SaveResourceUsage",
"(",
"self",
",",
"status",
")",
":",
"user_cpu",
"=",
"status",
".",
"cpu_time_used",
".",
"user_cpu_time",
"system_cpu",
"=",
"status",
".",
"cpu_time_used",
".",
"system_cpu_time",
"self",
".",
"rdf_flow",
".",
"cpu_time_used",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.Error | Terminates this flow with an error. | grr/server/grr_response_server/flow_base.py | def Error(self, error_message=None, backtrace=None, status=None):
"""Terminates this flow with an error."""
stats_collector_instance.Get().IncrementCounter(
"flow_errors", fields=[compatibility.GetName(self.__class__)])
client_id = self.rdf_flow.client_id
flow_id = self.rdf_flow.flow_id
lo... | def Error(self, error_message=None, backtrace=None, status=None):
"""Terminates this flow with an error."""
stats_collector_instance.Get().IncrementCounter(
"flow_errors", fields=[compatibility.GetName(self.__class__)])
client_id = self.rdf_flow.client_id
flow_id = self.rdf_flow.flow_id
lo... | [
"Terminates",
"this",
"flow",
"with",
"an",
"error",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L384-L426 | [
"def",
"Error",
"(",
"self",
",",
"error_message",
"=",
"None",
",",
"backtrace",
"=",
"None",
",",
"status",
"=",
"None",
")",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"flow_errors\"",
",",
"fields",
"=",
"[",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.MarkDone | Marks this flow as done. | grr/server/grr_response_server/flow_base.py | def MarkDone(self, status=None):
"""Marks this flow as done."""
stats_collector_instance.Get().IncrementCounter(
"flow_completions", fields=[compatibility.GetName(self.__class__)])
# Notify our parent flow or hunt that we are done (if there's a parent flow
# or hunt).
if self.rdf_flow.paren... | def MarkDone(self, status=None):
"""Marks this flow as done."""
stats_collector_instance.Get().IncrementCounter(
"flow_completions", fields=[compatibility.GetName(self.__class__)])
# Notify our parent flow or hunt that we are done (if there's a parent flow
# or hunt).
if self.rdf_flow.paren... | [
"Marks",
"this",
"flow",
"as",
"done",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L470-L494 | [
"def",
"MarkDone",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"stats_collector_instance",
".",
"Get",
"(",
")",
".",
"IncrementCounter",
"(",
"\"flow_completions\"",
",",
"fields",
"=",
"[",
"compatibility",
".",
"GetName",
"(",
"self",
".",
"__class... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.Log | Logs the message using the flow's standard logging.
Args:
format_str: Format string
*args: arguments to the format string | grr/server/grr_response_server/flow_base.py | def Log(self, format_str, *args):
"""Logs the message using the flow's standard logging.
Args:
format_str: Format string
*args: arguments to the format string
"""
log_entry = rdf_flow_objects.FlowLogEntry(
client_id=self.rdf_flow.client_id,
flow_id=self.rdf_flow.flow_id,
... | def Log(self, format_str, *args):
"""Logs the message using the flow's standard logging.
Args:
format_str: Format string
*args: arguments to the format string
"""
log_entry = rdf_flow_objects.FlowLogEntry(
client_id=self.rdf_flow.client_id,
flow_id=self.rdf_flow.flow_id,
... | [
"Logs",
"the",
"message",
"using",
"the",
"flow",
"s",
"standard",
"logging",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L496-L510 | [
"def",
"Log",
"(",
"self",
",",
"format_str",
",",
"*",
"args",
")",
":",
"log_entry",
"=",
"rdf_flow_objects",
".",
"FlowLogEntry",
"(",
"client_id",
"=",
"self",
".",
"rdf_flow",
".",
"client_id",
",",
"flow_id",
"=",
"self",
".",
"rdf_flow",
".",
"flo... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.RunStateMethod | Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of FlowMessages responding to the request. | grr/server/grr_response_server/flow_base.py | def RunStateMethod(self, method_name, request=None, responses=None):
"""Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of FlowMessages responding to the request.
"""
if sel... | def RunStateMethod(self, method_name, request=None, responses=None):
"""Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of FlowMessages responding to the request.
"""
if sel... | [
"Completes",
"the",
"request",
"by",
"calling",
"the",
"state",
"method",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L512-L580 | [
"def",
"RunStateMethod",
"(",
"self",
",",
"method_name",
",",
"request",
"=",
"None",
",",
"responses",
"=",
"None",
")",
":",
"if",
"self",
".",
"rdf_flow",
".",
"pending_termination",
":",
"self",
".",
"Error",
"(",
"error_message",
"=",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.ProcessAllReadyRequests | Processes all requests that are due to run.
Returns:
The number of processed requests. | grr/server/grr_response_server/flow_base.py | def ProcessAllReadyRequests(self):
"""Processes all requests that are due to run.
Returns:
The number of processed requests.
"""
request_dict = data_store.REL_DB.ReadFlowRequestsReadyForProcessing(
self.rdf_flow.client_id,
self.rdf_flow.flow_id,
next_needed_request=self.rd... | def ProcessAllReadyRequests(self):
"""Processes all requests that are due to run.
Returns:
The number of processed requests.
"""
request_dict = data_store.REL_DB.ReadFlowRequestsReadyForProcessing(
self.rdf_flow.client_id,
self.rdf_flow.flow_id,
next_needed_request=self.rd... | [
"Processes",
"all",
"requests",
"that",
"are",
"due",
"to",
"run",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L582-L615 | [
"def",
"ProcessAllReadyRequests",
"(",
"self",
")",
":",
"request_dict",
"=",
"data_store",
".",
"REL_DB",
".",
"ReadFlowRequestsReadyForProcessing",
"(",
"self",
".",
"rdf_flow",
".",
"client_id",
",",
"self",
".",
"rdf_flow",
".",
"flow_id",
",",
"next_needed_re... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase._ProcessRepliesWithFlowOutputPlugins | Processes replies with output plugins. | grr/server/grr_response_server/flow_base.py | def _ProcessRepliesWithFlowOutputPlugins(self, replies):
"""Processes replies with output plugins."""
created_output_plugins = []
for index, output_plugin_state in enumerate(
self.rdf_flow.output_plugins_states):
plugin_descriptor = output_plugin_state.plugin_descriptor
output_plugin_cls... | def _ProcessRepliesWithFlowOutputPlugins(self, replies):
"""Processes replies with output plugins."""
created_output_plugins = []
for index, output_plugin_state in enumerate(
self.rdf_flow.output_plugins_states):
plugin_descriptor = output_plugin_state.plugin_descriptor
output_plugin_cls... | [
"Processes",
"replies",
"with",
"output",
"plugins",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_base.py#L718-L775 | [
"def",
"_ProcessRepliesWithFlowOutputPlugins",
"(",
"self",
",",
"replies",
")",
":",
"created_output_plugins",
"=",
"[",
"]",
"for",
"index",
",",
"output_plugin_state",
"in",
"enumerate",
"(",
"self",
".",
"rdf_flow",
".",
"output_plugins_states",
")",
":",
"plu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _SignedBinaryIDFromURN | Converts an AFF4 URN for a signed binary to a SignedBinaryID. | grr/server/grr_response_server/signed_binary_utils.py | def _SignedBinaryIDFromURN(binary_urn
):
"""Converts an AFF4 URN for a signed binary to a SignedBinaryID."""
if binary_urn.RelativeName(GetAFF4PythonHackRoot()):
return rdf_objects.SignedBinaryID(
binary_type=rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK,
path=binar... | def _SignedBinaryIDFromURN(binary_urn
):
"""Converts an AFF4 URN for a signed binary to a SignedBinaryID."""
if binary_urn.RelativeName(GetAFF4PythonHackRoot()):
return rdf_objects.SignedBinaryID(
binary_type=rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK,
path=binar... | [
"Converts",
"an",
"AFF4",
"URN",
"for",
"a",
"signed",
"binary",
"to",
"a",
"SignedBinaryID",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L32-L45 | [
"def",
"_SignedBinaryIDFromURN",
"(",
"binary_urn",
")",
":",
"if",
"binary_urn",
".",
"RelativeName",
"(",
"GetAFF4PythonHackRoot",
"(",
")",
")",
":",
"return",
"rdf_objects",
".",
"SignedBinaryID",
"(",
"binary_type",
"=",
"rdf_objects",
".",
"SignedBinaryID",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _SignedBinaryURNFromID | Converts a SignedBinaryID to the equivalent AFF4 URN. | grr/server/grr_response_server/signed_binary_utils.py | def _SignedBinaryURNFromID(binary_id
):
"""Converts a SignedBinaryID to the equivalent AFF4 URN."""
binary_type = binary_id.binary_type
if binary_type == rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK:
return GetAFF4PythonHackRoot().Add(binary_id.path)
elif binary_type == rdf_ob... | def _SignedBinaryURNFromID(binary_id
):
"""Converts a SignedBinaryID to the equivalent AFF4 URN."""
binary_type = binary_id.binary_type
if binary_type == rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK:
return GetAFF4PythonHackRoot().Add(binary_id.path)
elif binary_type == rdf_ob... | [
"Converts",
"a",
"SignedBinaryID",
"to",
"the",
"equivalent",
"AFF4",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L48-L57 | [
"def",
"_SignedBinaryURNFromID",
"(",
"binary_id",
")",
":",
"binary_type",
"=",
"binary_id",
".",
"binary_type",
"if",
"binary_type",
"==",
"rdf_objects",
".",
"SignedBinaryID",
".",
"BinaryType",
".",
"PYTHON_HACK",
":",
"return",
"GetAFF4PythonHackRoot",
"(",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WriteSignedBinary | Signs a binary and saves it to the datastore.
If a signed binary with the given URN already exists, its contents will get
overwritten.
Args:
binary_urn: URN that should serve as a unique identifier for the binary.
binary_content: Contents of the binary, as raw bytes.
private_key: Key that should be ... | grr/server/grr_response_server/signed_binary_utils.py | def WriteSignedBinary(binary_urn,
binary_content,
private_key,
public_key,
chunk_size = 1024,
token = None):
"""Signs a binary and saves it to the datastore.
If a signed binary with the given URN already e... | def WriteSignedBinary(binary_urn,
binary_content,
private_key,
public_key,
chunk_size = 1024,
token = None):
"""Signs a binary and saves it to the datastore.
If a signed binary with the given URN already e... | [
"Signs",
"a",
"binary",
"and",
"saves",
"it",
"to",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L68-L110 | [
"def",
"WriteSignedBinary",
"(",
"binary_urn",
",",
"binary_content",
",",
"private_key",
",",
"public_key",
",",
"chunk_size",
"=",
"1024",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"collects",
".",
"GRRSignedBlob",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WriteSignedBinaryBlobs | Saves signed blobs to the datastore.
If a signed binary with the given URN already exists, its contents will get
overwritten.
Args:
binary_urn: RDFURN that should serve as a unique identifier for the binary.
blobs: An Iterable of signed blobs to write to the datastore.
token: ACL token to use with t... | grr/server/grr_response_server/signed_binary_utils.py | def WriteSignedBinaryBlobs(binary_urn,
blobs,
token = None):
"""Saves signed blobs to the datastore.
If a signed binary with the given URN already exists, its contents will get
overwritten.
Args:
binary_urn: RDFURN that should serve as a unique identif... | def WriteSignedBinaryBlobs(binary_urn,
blobs,
token = None):
"""Saves signed blobs to the datastore.
If a signed binary with the given URN already exists, its contents will get
overwritten.
Args:
binary_urn: RDFURN that should serve as a unique identif... | [
"Saves",
"signed",
"blobs",
"to",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L113-L149 | [
"def",
"WriteSignedBinaryBlobs",
"(",
"binary_urn",
",",
"blobs",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"aff4",
".",
"FACTORY",
".",
"Delete",
"(",
"binary_urn",
",",
"token",
"=",
"token",
")",
"with",
"dat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeleteSignedBinary | Deletes the binary with the given urn from the datastore.
Args:
binary_urn: RDFURN that serves as a unique identifier for the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
SignedBinaryNotFoundError: If the signed binary does not exist. | grr/server/grr_response_server/signed_binary_utils.py | def DeleteSignedBinary(binary_urn,
token = None):
"""Deletes the binary with the given urn from the datastore.
Args:
binary_urn: RDFURN that serves as a unique identifier for the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
SignedBinaryNo... | def DeleteSignedBinary(binary_urn,
token = None):
"""Deletes the binary with the given urn from the datastore.
Args:
binary_urn: RDFURN that serves as a unique identifier for the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
SignedBinaryNo... | [
"Deletes",
"the",
"binary",
"with",
"the",
"given",
"urn",
"from",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L152-L183 | [
"def",
"DeleteSignedBinary",
"(",
"binary_urn",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"try",
":",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"binary_urn",
",",
"aff4_type",
"=",
"aff4",
".",
"AFF4Stream",
","... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FetchURNsForAllSignedBinaries | Returns URNs for all signed binaries in the datastore.
Args:
token: ACL token to use with the legacy (non-relational) datastore. | grr/server/grr_response_server/signed_binary_utils.py | def FetchURNsForAllSignedBinaries(token
):
"""Returns URNs for all signed binaries in the datastore.
Args:
token: ACL token to use with the legacy (non-relational) datastore.
"""
if _ShouldUseLegacyDatastore():
urns = []
aff4_roots = [GetAFF4PythonHackRoot(), GetAFF... | def FetchURNsForAllSignedBinaries(token
):
"""Returns URNs for all signed binaries in the datastore.
Args:
token: ACL token to use with the legacy (non-relational) datastore.
"""
if _ShouldUseLegacyDatastore():
urns = []
aff4_roots = [GetAFF4PythonHackRoot(), GetAFF... | [
"Returns",
"URNs",
"for",
"all",
"signed",
"binaries",
"in",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L186-L206 | [
"def",
"FetchURNsForAllSignedBinaries",
"(",
"token",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"urns",
"=",
"[",
"]",
"aff4_roots",
"=",
"[",
"GetAFF4PythonHackRoot",
"(",
")",
",",
"GetAFF4ExecutablesRoot",
"(",
")",
"]",
"for",
"_",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FetchBlobsForSignedBinary | Retrieves blobs for the given binary from the datastore.
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Returns:
A tuple containing an iterator for all the binary's blobs and an
RDFDatetime representing when the bin... | grr/server/grr_response_server/signed_binary_utils.py | def FetchBlobsForSignedBinary(
binary_urn,
token = None
):
"""Retrieves blobs for the given binary from the datastore.
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Returns:
A tuple containing an iterator for... | def FetchBlobsForSignedBinary(
binary_urn,
token = None
):
"""Retrieves blobs for the given binary from the datastore.
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Returns:
A tuple containing an iterator for... | [
"Retrieves",
"blobs",
"for",
"the",
"given",
"binary",
"from",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L209-L246 | [
"def",
"FetchBlobsForSignedBinary",
"(",
"binary_urn",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"try",
":",
"aff4_stream",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"binary_urn",
",",
"aff4_type",
"=",
"coll... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FetchSizeOfSignedBinary | Returns the size of the given binary (in bytes).
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
SignedBinaryNotFoundError: If no signed binary with the given URN exists. | grr/server/grr_response_server/signed_binary_utils.py | def FetchSizeOfSignedBinary(binary_urn,
token = None
):
"""Returns the size of the given binary (in bytes).
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
... | def FetchSizeOfSignedBinary(binary_urn,
token = None
):
"""Returns the size of the given binary (in bytes).
Args:
binary_urn: RDFURN that uniquely identifies the binary.
token: ACL token to use with the legacy (non-relational) datastore.
Raises:
... | [
"Returns",
"the",
"size",
"of",
"the",
"given",
"binary",
"(",
"in",
"bytes",
")",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L249-L275 | [
"def",
"FetchSizeOfSignedBinary",
"(",
"binary_urn",
",",
"token",
"=",
"None",
")",
":",
"if",
"_ShouldUseLegacyDatastore",
"(",
")",
":",
"try",
":",
"aff4_stream",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"binary_urn",
",",
"aff4_type",
"=",
"collec... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | StreamSignedBinaryContents | Yields the contents of the given binary in chunks of the given size.
Args:
blob_iterator: An Iterator over all the binary's blobs.
chunk_size: Size, in bytes, of the chunks to yield. | grr/server/grr_response_server/signed_binary_utils.py | def StreamSignedBinaryContents(blob_iterator,
chunk_size = 1024
):
"""Yields the contents of the given binary in chunks of the given size.
Args:
blob_iterator: An Iterator over all the binary's blobs.
chunk_size: Size, in bytes, of the chunks to ... | def StreamSignedBinaryContents(blob_iterator,
chunk_size = 1024
):
"""Yields the contents of the given binary in chunks of the given size.
Args:
blob_iterator: An Iterator over all the binary's blobs.
chunk_size: Size, in bytes, of the chunks to ... | [
"Yields",
"the",
"contents",
"of",
"the",
"given",
"binary",
"in",
"chunks",
"of",
"the",
"given",
"size",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/signed_binary_utils.py#L278-L303 | [
"def",
"StreamSignedBinaryContents",
"(",
"blob_iterator",
",",
"chunk_size",
"=",
"1024",
")",
":",
"all_blobs_read",
"=",
"False",
"byte_buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"while",
"not",
"all_blobs_read",
"or",
"byte_buffer",
".",
"getvalue",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MemoryStreamBlobStore.WriteBlobs | Creates or overwrites blobs. | grr/server/grr_response_server/blob_stores/memory_stream_bs.py | def WriteBlobs(self, blob_id_data_map):
"""Creates or overwrites blobs."""
urns = {self._BlobUrn(blob_id): blob_id for blob_id in blob_id_data_map}
mutation_pool = data_store.DB.GetMutationPool()
existing = aff4.FACTORY.MultiOpen(
urns, aff4_type=aff4.AFF4MemoryStreamBase, mode="r")
for ... | def WriteBlobs(self, blob_id_data_map):
"""Creates or overwrites blobs."""
urns = {self._BlobUrn(blob_id): blob_id for blob_id in blob_id_data_map}
mutation_pool = data_store.DB.GetMutationPool()
existing = aff4.FACTORY.MultiOpen(
urns, aff4_type=aff4.AFF4MemoryStreamBase, mode="r")
for ... | [
"Creates",
"or",
"overwrites",
"blobs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/blob_stores/memory_stream_bs.py#L24-L50 | [
"def",
"WriteBlobs",
"(",
"self",
",",
"blob_id_data_map",
")",
":",
"urns",
"=",
"{",
"self",
".",
"_BlobUrn",
"(",
"blob_id",
")",
":",
"blob_id",
"for",
"blob_id",
"in",
"blob_id_data_map",
"}",
"mutation_pool",
"=",
"data_store",
".",
"DB",
".",
"GetMu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MemoryStreamBlobStore.CheckBlobsExist | Check if blobs for the given digests already exist. | grr/server/grr_response_server/blob_stores/memory_stream_bs.py | def CheckBlobsExist(self, blob_ids):
"""Check if blobs for the given digests already exist."""
res = {blob_id: False for blob_id in blob_ids}
urns = {self._BlobUrn(blob_id): blob_id for blob_id in blob_ids}
existing = aff4.FACTORY.MultiOpen(
urns, aff4_type=aff4.AFF4MemoryStreamBase, mode="r")... | def CheckBlobsExist(self, blob_ids):
"""Check if blobs for the given digests already exist."""
res = {blob_id: False for blob_id in blob_ids}
urns = {self._BlobUrn(blob_id): blob_id for blob_id in blob_ids}
existing = aff4.FACTORY.MultiOpen(
urns, aff4_type=aff4.AFF4MemoryStreamBase, mode="r")... | [
"Check",
"if",
"blobs",
"for",
"the",
"given",
"digests",
"already",
"exist",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/blob_stores/memory_stream_bs.py#L63-L75 | [
"def",
"CheckBlobsExist",
"(",
"self",
",",
"blob_ids",
")",
":",
"res",
"=",
"{",
"blob_id",
":",
"False",
"for",
"blob_id",
"in",
"blob_ids",
"}",
"urns",
"=",
"{",
"self",
".",
"_BlobUrn",
"(",
"blob_id",
")",
":",
"blob_id",
"for",
"blob_id",
"in",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | NamedPlaceholders | Returns named placeholders from all elements of the given iterable.
Use this function for VALUES of MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> NamedPlaceholders({"password": "foo", "name": "bar"})
u'(%(name)s... | grr/server/grr_response_server/databases/mysql_utils.py | def NamedPlaceholders(iterable):
"""Returns named placeholders from all elements of the given iterable.
Use this function for VALUES of MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> NamedPlaceholders({"password": ... | def NamedPlaceholders(iterable):
"""Returns named placeholders from all elements of the given iterable.
Use this function for VALUES of MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> NamedPlaceholders({"password": ... | [
"Returns",
"named",
"placeholders",
"from",
"all",
"elements",
"of",
"the",
"given",
"iterable",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_utils.py#L66-L85 | [
"def",
"NamedPlaceholders",
"(",
"iterable",
")",
":",
"placeholders",
"=",
"\", \"",
".",
"join",
"(",
"\"%({})s\"",
".",
"format",
"(",
"key",
")",
"for",
"key",
"in",
"sorted",
"(",
"iterable",
")",
")",
"return",
"\"({})\"",
".",
"format",
"(",
"plac... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Columns | Returns a string of column names for MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> Columns({"password": "foo", "name": "bar"})
u'(`name`, `password`)'
Args:
iterable: The iterable of strings to be used as co... | grr/server/grr_response_server/databases/mysql_utils.py | def Columns(iterable):
"""Returns a string of column names for MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> Columns({"password": "foo", "name": "bar"})
u'(`name`, `password`)'
Args:
iterable: The iterable... | def Columns(iterable):
"""Returns a string of column names for MySQL INSERTs.
To account for Iterables with undefined order (dicts before Python 3.6),
this function sorts column names.
Examples:
>>> Columns({"password": "foo", "name": "bar"})
u'(`name`, `password`)'
Args:
iterable: The iterable... | [
"Returns",
"a",
"string",
"of",
"column",
"names",
"for",
"MySQL",
"INSERTs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_utils.py#L88-L103 | [
"def",
"Columns",
"(",
"iterable",
")",
":",
"columns",
"=",
"sorted",
"(",
"iterable",
")",
"return",
"\"({})\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"\"`{}`\"",
".",
"format",
"(",
"col",
")",
"for",
"col",
"in",
"columns",
")",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TimestampToRDFDatetime | Converts MySQL `TIMESTAMP(6)` columns to datetime objects. | grr/server/grr_response_server/databases/mysql_utils.py | def TimestampToRDFDatetime(timestamp):
"""Converts MySQL `TIMESTAMP(6)` columns to datetime objects."""
# TODO(hanuszczak): `timestamp` should be of MySQL type `Decimal`. However,
# it is unclear where this type is actually defined and how to import it in
# order to have a type assertion.
if timestamp is None... | def TimestampToRDFDatetime(timestamp):
"""Converts MySQL `TIMESTAMP(6)` columns to datetime objects."""
# TODO(hanuszczak): `timestamp` should be of MySQL type `Decimal`. However,
# it is unclear where this type is actually defined and how to import it in
# order to have a type assertion.
if timestamp is None... | [
"Converts",
"MySQL",
"TIMESTAMP",
"(",
"6",
")",
"columns",
"to",
"datetime",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_utils.py#L120-L129 | [
"def",
"TimestampToRDFDatetime",
"(",
"timestamp",
")",
":",
"# TODO(hanuszczak): `timestamp` should be of MySQL type `Decimal`. However,",
"# it is unclear where this type is actually defined and how to import it in",
"# order to have a type assertion.",
"if",
"timestamp",
"is",
"None",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ComponentsToPath | Converts a list of path components to a canonical path representation.
Args:
components: A sequence of path components.
Returns:
A canonical MySQL path representation. | grr/server/grr_response_server/databases/mysql_utils.py | def ComponentsToPath(components):
"""Converts a list of path components to a canonical path representation.
Args:
components: A sequence of path components.
Returns:
A canonical MySQL path representation.
"""
precondition.AssertIterableType(components, Text)
for component in components:
if not... | def ComponentsToPath(components):
"""Converts a list of path components to a canonical path representation.
Args:
components: A sequence of path components.
Returns:
A canonical MySQL path representation.
"""
precondition.AssertIterableType(components, Text)
for component in components:
if not... | [
"Converts",
"a",
"list",
"of",
"path",
"components",
"to",
"a",
"canonical",
"path",
"representation",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_utils.py#L141-L161 | [
"def",
"ComponentsToPath",
"(",
"components",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"components",
",",
"Text",
")",
"for",
"component",
"in",
"components",
":",
"if",
"not",
"component",
":",
"raise",
"ValueError",
"(",
"\"Empty path component ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PathToComponents | Converts a canonical path representation to a list of components.
Args:
path: A canonical MySQL path representation.
Returns:
A sequence of path components. | grr/server/grr_response_server/databases/mysql_utils.py | def PathToComponents(path):
"""Converts a canonical path representation to a list of components.
Args:
path: A canonical MySQL path representation.
Returns:
A sequence of path components.
"""
precondition.AssertType(path, Text)
if path and not path.startswith("/"):
raise ValueError("Path '{}' ... | def PathToComponents(path):
"""Converts a canonical path representation to a list of components.
Args:
path: A canonical MySQL path representation.
Returns:
A sequence of path components.
"""
precondition.AssertType(path, Text)
if path and not path.startswith("/"):
raise ValueError("Path '{}' ... | [
"Converts",
"a",
"canonical",
"path",
"representation",
"to",
"a",
"list",
"of",
"components",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_utils.py#L164-L180 | [
"def",
"PathToComponents",
"(",
"path",
")",
":",
"precondition",
".",
"AssertType",
"(",
"path",
",",
"Text",
")",
"if",
"path",
"and",
"not",
"path",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"raise",
"ValueError",
"(",
"\"Path '{}' is not absolute\"",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _LogInvalidRunLevels | Log any invalid run states found. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def _LogInvalidRunLevels(states, valid):
"""Log any invalid run states found."""
invalid = set()
for state in states:
if state not in valid:
invalid.add(state)
if invalid:
logging.warning("Invalid init runlevel(s) encountered: %s",
", ".join(invalid)) | def _LogInvalidRunLevels(states, valid):
"""Log any invalid run states found."""
invalid = set()
for state in states:
if state not in valid:
invalid.add(state)
if invalid:
logging.warning("Invalid init runlevel(s) encountered: %s",
", ".join(invalid)) | [
"Log",
"any",
"invalid",
"run",
"states",
"found",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L77-L85 | [
"def",
"_LogInvalidRunLevels",
"(",
"states",
",",
"valid",
")",
":",
"invalid",
"=",
"set",
"(",
")",
"for",
"state",
"in",
"states",
":",
"if",
"state",
"not",
"in",
"valid",
":",
"invalid",
".",
"add",
"(",
"state",
")",
"if",
"invalid",
":",
"log... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetRunlevelsLSB | Accepts a string and returns a list of strings of numeric LSB runlevels. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def GetRunlevelsLSB(states):
"""Accepts a string and returns a list of strings of numeric LSB runlevels."""
if not states:
return set()
valid = set(["0", "1", "2", "3", "4", "5", "6"])
_LogInvalidRunLevels(states, valid)
return valid.intersection(set(states.split())) | def GetRunlevelsLSB(states):
"""Accepts a string and returns a list of strings of numeric LSB runlevels."""
if not states:
return set()
valid = set(["0", "1", "2", "3", "4", "5", "6"])
_LogInvalidRunLevels(states, valid)
return valid.intersection(set(states.split())) | [
"Accepts",
"a",
"string",
"and",
"returns",
"a",
"list",
"of",
"strings",
"of",
"numeric",
"LSB",
"runlevels",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L88-L94 | [
"def",
"GetRunlevelsLSB",
"(",
"states",
")",
":",
"if",
"not",
"states",
":",
"return",
"set",
"(",
")",
"valid",
"=",
"set",
"(",
"[",
"\"0\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
",",
"\"4\"",
",",
"\"5\"",
",",
"\"6\"",
"]",
")",
"_LogInv... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetRunlevelsNonLSB | Accepts a string and returns a list of strings of numeric LSB runlevels. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def GetRunlevelsNonLSB(states):
"""Accepts a string and returns a list of strings of numeric LSB runlevels."""
if not states:
return set()
convert_table = {
"0": "0",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
# SysV, Gentoo, Solaris, HP-UX all ... | def GetRunlevelsNonLSB(states):
"""Accepts a string and returns a list of strings of numeric LSB runlevels."""
if not states:
return set()
convert_table = {
"0": "0",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
# SysV, Gentoo, Solaris, HP-UX all ... | [
"Accepts",
"a",
"string",
"and",
"returns",
"a",
"list",
"of",
"strings",
"of",
"numeric",
"LSB",
"runlevels",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L97-L115 | [
"def",
"GetRunlevelsNonLSB",
"(",
"states",
")",
":",
"if",
"not",
"states",
":",
"return",
"set",
"(",
")",
"convert_table",
"=",
"{",
"\"0\"",
":",
"\"0\"",
",",
"\"1\"",
":",
"\"1\"",
",",
"\"2\"",
":",
"\"2\"",
",",
"\"3\"",
":",
"\"3\"",
",",
"\... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxLSBInitParser._InsservExpander | Expand insserv variables. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def _InsservExpander(self, facilities, val):
"""Expand insserv variables."""
expanded = []
if val.startswith("$"):
vals = facilities.get(val, [])
for v in vals:
expanded.extend(self._InsservExpander(facilities, v))
elif val.startswith("+"):
expanded.append(val[1:])
else:
... | def _InsservExpander(self, facilities, val):
"""Expand insserv variables."""
expanded = []
if val.startswith("$"):
vals = facilities.get(val, [])
for v in vals:
expanded.extend(self._InsservExpander(facilities, v))
elif val.startswith("+"):
expanded.append(val[1:])
else:
... | [
"Expand",
"insserv",
"variables",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L151-L162 | [
"def",
"_InsservExpander",
"(",
"self",
",",
"facilities",
",",
"val",
")",
":",
"expanded",
"=",
"[",
"]",
"if",
"val",
".",
"startswith",
"(",
"\"$\"",
")",
":",
"vals",
"=",
"facilities",
".",
"get",
"(",
"val",
",",
"[",
"]",
")",
"for",
"v",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxLSBInitParser._ParseInsserv | /etc/insserv.conf* entries define system facilities.
Full format details are in man 8 insserv, but the basic structure is:
$variable facility1 facility2
$second_variable facility3 $variable
Any init script that specifies Required-Start: $second_variable needs to be
expanded to facil... | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def _ParseInsserv(self, data):
"""/etc/insserv.conf* entries define system facilities.
Full format details are in man 8 insserv, but the basic structure is:
$variable facility1 facility2
$second_variable facility3 $variable
Any init script that specifies Required-Start: $second_vari... | def _ParseInsserv(self, data):
"""/etc/insserv.conf* entries define system facilities.
Full format details are in man 8 insserv, but the basic structure is:
$variable facility1 facility2
$second_variable facility3 $variable
Any init script that specifies Required-Start: $second_vari... | [
"/",
"etc",
"/",
"insserv",
".",
"conf",
"*",
"entries",
"define",
"system",
"facilities",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L164-L189 | [
"def",
"_ParseInsserv",
"(",
"self",
",",
"data",
")",
":",
"p",
"=",
"config_file",
".",
"FieldParser",
"(",
")",
"entries",
"=",
"p",
".",
"ParseEntries",
"(",
"data",
")",
"raw",
"=",
"{",
"e",
"[",
"0",
"]",
":",
"e",
"[",
"1",
":",
"]",
"f... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxXinetdParser._ProcessEntries | Extract entries from the xinetd config files. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def _ProcessEntries(self, fd):
"""Extract entries from the xinetd config files."""
p = config_file.KeyValueParser(kv_sep="{", term="}", sep=None)
data = utils.ReadFileBytesAsUnicode(fd)
entries = p.ParseEntries(data)
for entry in entries:
for section, cfg in iteritems(entry):
# The par... | def _ProcessEntries(self, fd):
"""Extract entries from the xinetd config files."""
p = config_file.KeyValueParser(kv_sep="{", term="}", sep=None)
data = utils.ReadFileBytesAsUnicode(fd)
entries = p.ParseEntries(data)
for entry in entries:
for section, cfg in iteritems(entry):
# The par... | [
"Extract",
"entries",
"from",
"the",
"xinetd",
"config",
"files",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L229-L241 | [
"def",
"_ProcessEntries",
"(",
"self",
",",
"fd",
")",
":",
"p",
"=",
"config_file",
".",
"KeyValueParser",
"(",
"kv_sep",
"=",
"\"{\"",
",",
"term",
"=",
"\"}\"",
",",
"sep",
"=",
"None",
")",
"data",
"=",
"utils",
".",
"ReadFileBytesAsUnicode",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxXinetdParser._GenConfig | Interpolate configurations with defaults to generate actual configs. | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def _GenConfig(self, cfg):
"""Interpolate configurations with defaults to generate actual configs."""
# Some setting names may have a + or - suffix. These indicate that the
# settings modify the default values.
merged = self.default.copy()
for setting, vals in iteritems(cfg):
option, operator ... | def _GenConfig(self, cfg):
"""Interpolate configurations with defaults to generate actual configs."""
# Some setting names may have a + or - suffix. These indicate that the
# settings modify the default values.
merged = self.default.copy()
for setting, vals in iteritems(cfg):
option, operator ... | [
"Interpolate",
"configurations",
"with",
"defaults",
"to",
"generate",
"actual",
"configs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L243-L258 | [
"def",
"_GenConfig",
"(",
"self",
",",
"cfg",
")",
":",
"# Some setting names may have a + or - suffix. These indicate that the",
"# settings modify the default values.",
"merged",
"=",
"self",
".",
"default",
".",
"copy",
"(",
")",
"for",
"setting",
",",
"vals",
"in",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSysVInitParser.ParseMultiple | Identify the init scripts and the start/stop scripts at each runlevel.
Evaluate all the stat entries collected from the system.
If the path name matches a runlevel spec, and if the filename matches a
sysv init symlink process the link as a service.
Args:
stats: An iterator of StatEntry rdfs.
... | grr/core/grr_response_core/lib/parsers/linux_service_parser.py | def ParseMultiple(self, stats, unused_file_obj, unused_kb):
"""Identify the init scripts and the start/stop scripts at each runlevel.
Evaluate all the stat entries collected from the system.
If the path name matches a runlevel spec, and if the filename matches a
sysv init symlink process the link as a ... | def ParseMultiple(self, stats, unused_file_obj, unused_kb):
"""Identify the init scripts and the start/stop scripts at each runlevel.
Evaluate all the stat entries collected from the system.
If the path name matches a runlevel spec, and if the filename matches a
sysv init symlink process the link as a ... | [
"Identify",
"the",
"init",
"scripts",
"and",
"the",
"start",
"/",
"stop",
"scripts",
"at",
"each",
"runlevel",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L298-L338 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"stats",
",",
"unused_file_obj",
",",
"unused_kb",
")",
":",
"services",
"=",
"{",
"}",
"for",
"stat_entry",
"in",
"stats",
":",
"path",
"=",
"stat_entry",
".",
"pathspec",
".",
"path",
"runlevel",
"=",
"self",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckClientLabels | Checks a given client against labels/owners whitelists. | grr/server/grr_response_server/gui/api_labels_restricted_call_router.py | def CheckClientLabels(client_id,
labels_whitelist=None,
labels_owners_whitelist=None,
token=None):
"""Checks a given client against labels/owners whitelists."""
labels_whitelist = labels_whitelist or []
labels_owners_whitelist = labels_owners_whit... | def CheckClientLabels(client_id,
labels_whitelist=None,
labels_owners_whitelist=None,
token=None):
"""Checks a given client against labels/owners whitelists."""
labels_whitelist = labels_whitelist or []
labels_owners_whitelist = labels_owners_whit... | [
"Checks",
"a",
"given",
"client",
"against",
"labels",
"/",
"owners",
"whitelists",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_labels_restricted_call_router.py#L29-L52 | [
"def",
"CheckClientLabels",
"(",
"client_id",
",",
"labels_whitelist",
"=",
"None",
",",
"labels_owners_whitelist",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"labels_whitelist",
"=",
"labels_whitelist",
"or",
"[",
"]",
"labels_owners_whitelist",
"=",
"labe... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _IsRetryable | Returns whether error is likely to be retryable. | grr/server/grr_response_server/databases/mysql.py | def _IsRetryable(error):
"""Returns whether error is likely to be retryable."""
if not isinstance(error, MySQLdb.OperationalError):
return False
if not error.args:
return False
code = error.args[0]
return code in _RETRYABLE_ERRORS | def _IsRetryable(error):
"""Returns whether error is likely to be retryable."""
if not isinstance(error, MySQLdb.OperationalError):
return False
if not error.args:
return False
code = error.args[0]
return code in _RETRYABLE_ERRORS | [
"Returns",
"whether",
"error",
"is",
"likely",
"to",
"be",
"retryable",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L67-L74 | [
"def",
"_IsRetryable",
"(",
"error",
")",
":",
"if",
"not",
"isinstance",
"(",
"error",
",",
"MySQLdb",
".",
"OperationalError",
")",
":",
"return",
"False",
"if",
"not",
"error",
".",
"args",
":",
"return",
"False",
"code",
"=",
"error",
".",
"args",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _CheckCollation | Checks MySQL collation and warns if misconfigured. | grr/server/grr_response_server/databases/mysql.py | def _CheckCollation(cursor):
"""Checks MySQL collation and warns if misconfigured."""
# Do not fail for wrong collation, because changing it is harder than changing
# the character set. Some providers only allow changing character set and then
# use the default collation. Also, misconfigured collation is not e... | def _CheckCollation(cursor):
"""Checks MySQL collation and warns if misconfigured."""
# Do not fail for wrong collation, because changing it is harder than changing
# the character set. Some providers only allow changing character set and then
# use the default collation. Also, misconfigured collation is not e... | [
"Checks",
"MySQL",
"collation",
"and",
"warns",
"if",
"misconfigured",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L102-L121 | [
"def",
"_CheckCollation",
"(",
"cursor",
")",
":",
"# Do not fail for wrong collation, because changing it is harder than changing",
"# the character set. Some providers only allow changing character set and then",
"# use the default collation. Also, misconfigured collation is not expected to",
"#... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _CheckConnectionEncoding | Enforces a sane UTF-8 encoding for the database connection. | grr/server/grr_response_server/databases/mysql.py | def _CheckConnectionEncoding(cursor):
"""Enforces a sane UTF-8 encoding for the database connection."""
cur_character_set = _ReadVariable("character_set_connection", cursor)
if cur_character_set != CHARACTER_SET:
raise EncodingEnforcementError(
"Require MySQL character_set_connection of {}, got {}.".f... | def _CheckConnectionEncoding(cursor):
"""Enforces a sane UTF-8 encoding for the database connection."""
cur_character_set = _ReadVariable("character_set_connection", cursor)
if cur_character_set != CHARACTER_SET:
raise EncodingEnforcementError(
"Require MySQL character_set_connection of {}, got {}.".f... | [
"Enforces",
"a",
"sane",
"UTF",
"-",
"8",
"encoding",
"for",
"the",
"database",
"connection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L129-L135 | [
"def",
"_CheckConnectionEncoding",
"(",
"cursor",
")",
":",
"cur_character_set",
"=",
"_ReadVariable",
"(",
"\"character_set_connection\"",
",",
"cursor",
")",
"if",
"cur_character_set",
"!=",
"CHARACTER_SET",
":",
"raise",
"EncodingEnforcementError",
"(",
"\"Require MySQ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _CheckDatabaseEncoding | Enforces a sane UTF-8 encoding for the database. | grr/server/grr_response_server/databases/mysql.py | def _CheckDatabaseEncoding(cursor):
"""Enforces a sane UTF-8 encoding for the database."""
cur_character_set = _ReadVariable("character_set_database", cursor)
if cur_character_set != CHARACTER_SET:
raise EncodingEnforcementError(
"Require MySQL character_set_database of {}, got {}."
" To creat... | def _CheckDatabaseEncoding(cursor):
"""Enforces a sane UTF-8 encoding for the database."""
cur_character_set = _ReadVariable("character_set_database", cursor)
if cur_character_set != CHARACTER_SET:
raise EncodingEnforcementError(
"Require MySQL character_set_database of {}, got {}."
" To creat... | [
"Enforces",
"a",
"sane",
"UTF",
"-",
"8",
"encoding",
"for",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L138-L146 | [
"def",
"_CheckDatabaseEncoding",
"(",
"cursor",
")",
":",
"cur_character_set",
"=",
"_ReadVariable",
"(",
"\"character_set_database\"",
",",
"cursor",
")",
"if",
"cur_character_set",
"!=",
"CHARACTER_SET",
":",
"raise",
"EncodingEnforcementError",
"(",
"\"Require MySQL ch... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _SetPacketSizeForFollowingConnections | Sets max_allowed_packet globally for new connections (not current!). | grr/server/grr_response_server/databases/mysql.py | def _SetPacketSizeForFollowingConnections(cursor):
"""Sets max_allowed_packet globally for new connections (not current!)."""
cur_packet_size = int(_ReadVariable("max_allowed_packet", cursor))
if cur_packet_size < MAX_PACKET_SIZE:
logging.warning(
"MySQL max_allowed_packet of %d is required, got %d. ... | def _SetPacketSizeForFollowingConnections(cursor):
"""Sets max_allowed_packet globally for new connections (not current!)."""
cur_packet_size = int(_ReadVariable("max_allowed_packet", cursor))
if cur_packet_size < MAX_PACKET_SIZE:
logging.warning(
"MySQL max_allowed_packet of %d is required, got %d. ... | [
"Sets",
"max_allowed_packet",
"globally",
"for",
"new",
"connections",
"(",
"not",
"current!",
")",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L149-L157 | [
"def",
"_SetPacketSizeForFollowingConnections",
"(",
"cursor",
")",
":",
"cur_packet_size",
"=",
"int",
"(",
"_ReadVariable",
"(",
"\"max_allowed_packet\"",
",",
"cursor",
")",
")",
"if",
"cur_packet_size",
"<",
"MAX_PACKET_SIZE",
":",
"logging",
".",
"warning",
"("... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _CheckPacketSize | Checks that MySQL packet size is big enough for expected query size. | grr/server/grr_response_server/databases/mysql.py | def _CheckPacketSize(cursor):
"""Checks that MySQL packet size is big enough for expected query size."""
cur_packet_size = int(_ReadVariable("max_allowed_packet", cursor))
if cur_packet_size < MAX_PACKET_SIZE:
raise Error(
"MySQL max_allowed_packet of {0} is required, got {1}. "
"Please set ma... | def _CheckPacketSize(cursor):
"""Checks that MySQL packet size is big enough for expected query size."""
cur_packet_size = int(_ReadVariable("max_allowed_packet", cursor))
if cur_packet_size < MAX_PACKET_SIZE:
raise Error(
"MySQL max_allowed_packet of {0} is required, got {1}. "
"Please set ma... | [
"Checks",
"that",
"MySQL",
"packet",
"size",
"is",
"big",
"enough",
"for",
"expected",
"query",
"size",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L160-L167 | [
"def",
"_CheckPacketSize",
"(",
"cursor",
")",
":",
"cur_packet_size",
"=",
"int",
"(",
"_ReadVariable",
"(",
"\"max_allowed_packet\"",
",",
"cursor",
")",
")",
"if",
"cur_packet_size",
"<",
"MAX_PACKET_SIZE",
":",
"raise",
"Error",
"(",
"\"MySQL max_allowed_packet ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _CheckLogFileSize | Warns if MySQL log file size is not large enough for blob insertions. | grr/server/grr_response_server/databases/mysql.py | def _CheckLogFileSize(cursor):
"""Warns if MySQL log file size is not large enough for blob insertions."""
# Do not fail, because users might not be able to change this for their
# database. Instead, warn the user about the impacts.
innodb_log_file_size = int(_ReadVariable("innodb_log_file_size", cursor))
r... | def _CheckLogFileSize(cursor):
"""Warns if MySQL log file size is not large enough for blob insertions."""
# Do not fail, because users might not be able to change this for their
# database. Instead, warn the user about the impacts.
innodb_log_file_size = int(_ReadVariable("innodb_log_file_size", cursor))
r... | [
"Warns",
"if",
"MySQL",
"log",
"file",
"size",
"is",
"not",
"large",
"enough",
"for",
"blob",
"insertions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L170-L187 | [
"def",
"_CheckLogFileSize",
"(",
"cursor",
")",
":",
"# Do not fail, because users might not be able to change this for their",
"# database. Instead, warn the user about the impacts.",
"innodb_log_file_size",
"=",
"int",
"(",
"_ReadVariable",
"(",
"\"innodb_log_file_size\"",
",",
"cu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _IsMariaDB | Checks if we are running against MariaDB. | grr/server/grr_response_server/databases/mysql.py | def _IsMariaDB(cursor):
"""Checks if we are running against MariaDB."""
for variable in ["version", "version_comment"]:
cursor.execute("SHOW VARIABLES LIKE %s;", (variable,))
version = cursor.fetchone()
if version and "MariaDB" in version[1]:
return True
return False | def _IsMariaDB(cursor):
"""Checks if we are running against MariaDB."""
for variable in ["version", "version_comment"]:
cursor.execute("SHOW VARIABLES LIKE %s;", (variable,))
version = cursor.fetchone()
if version and "MariaDB" in version[1]:
return True
return False | [
"Checks",
"if",
"we",
"are",
"running",
"against",
"MariaDB",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L190-L197 | [
"def",
"_IsMariaDB",
"(",
"cursor",
")",
":",
"for",
"variable",
"in",
"[",
"\"version\"",
",",
"\"version_comment\"",
"]",
":",
"cursor",
".",
"execute",
"(",
"\"SHOW VARIABLES LIKE %s;\"",
",",
"(",
"variable",
",",
")",
")",
"version",
"=",
"cursor",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _SetupDatabase | Connect to the given MySQL host and create a utf8mb4_unicode_ci database.
Args:
host: The hostname to connect to.
port: The port to connect to.
user: The username to connect as.
password: The password to connect with.
database: The database name to create.
client_key_path: The path of the cli... | grr/server/grr_response_server/databases/mysql.py | def _SetupDatabase(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Connect to the given MySQL host and... | def _SetupDatabase(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Connect to the given MySQL host and... | [
"Connect",
"to",
"the",
"given",
"MySQL",
"host",
"and",
"create",
"a",
"utf8mb4_unicode_ci",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L251-L306 | [
"def",
"_SetupDatabase",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"database",
"=",
"None",
",",
"client_key_path",
"=",
"None",
",",
"client_cert_path",
"=",
"None",
",",
"ca_cert_pa... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GetConnectionArgs | Builds connection arguments for MySQLdb.Connect function. | grr/server/grr_response_server/databases/mysql.py | def _GetConnectionArgs(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Bui... | def _GetConnectionArgs(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Bui... | [
"Builds",
"connection",
"arguments",
"for",
"MySQLdb",
".",
"Connect",
"function",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L309-L343 | [
"def",
"_GetConnectionArgs",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"database",
"=",
"None",
",",
"client_key_path",
"=",
"None",
",",
"client_cert_path",
"=",
"None",
",",
"ca_cer... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _Connect | Connect to MySQL and check if server fulfills requirements. | grr/server/grr_response_server/databases/mysql.py | def _Connect(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Connect to MySQL and check if server fulfills requirements."""
connection_args = ... | def _Connect(host=None,
port=None,
user=None,
password=None,
database=None,
client_key_path=None,
client_cert_path=None,
ca_cert_path=None):
"""Connect to MySQL and check if server fulfills requirements."""
connection_args = ... | [
"Connect",
"to",
"MySQL",
"and",
"check",
"if",
"server",
"fulfills",
"requirements",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L346-L376 | [
"def",
"_Connect",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"database",
"=",
"None",
",",
"client_key_path",
"=",
"None",
",",
"client_cert_path",
"=",
"None",
",",
"ca_cert_path",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MysqlDB._RunInTransaction | Runs function within a transaction.
Allocates a connection, begins a transaction on it and passes the connection
to function.
If function finishes without raising, the transaction is committed.
If function raises, the transaction will be rolled back, if a retryable
database error is raised, the o... | grr/server/grr_response_server/databases/mysql.py | def _RunInTransaction(self, function, readonly=False):
"""Runs function within a transaction.
Allocates a connection, begins a transaction on it and passes the connection
to function.
If function finishes without raising, the transaction is committed.
If function raises, the transaction will be r... | def _RunInTransaction(self, function, readonly=False):
"""Runs function within a transaction.
Allocates a connection, begins a transaction on it and passes the connection
to function.
If function finishes without raising, the transaction is committed.
If function raises, the transaction will be r... | [
"Runs",
"function",
"within",
"a",
"transaction",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql.py#L474-L523 | [
"def",
"_RunInTransaction",
"(",
"self",
",",
"function",
",",
"readonly",
"=",
"False",
")",
":",
"start_query",
"=",
"\"START TRANSACTION;\"",
"if",
"readonly",
":",
"start_query",
"=",
"\"START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY;\"",
"for",
"retry_count",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBClientReportsMixin.WriteClientGraphSeries | See db.Database. | grr/server/grr_response_server/databases/mem_client_reports.py | def WriteClientGraphSeries(self, graph_series,
client_label,
timestamp):
"""See db.Database."""
series_key = (client_label, graph_series.report_type, timestamp.Copy())
self.client_graph_series[series_key] = graph_series.Copy() | def WriteClientGraphSeries(self, graph_series,
client_label,
timestamp):
"""See db.Database."""
series_key = (client_label, graph_series.report_type, timestamp.Copy())
self.client_graph_series[series_key] = graph_series.Copy() | [
"See",
"db",
".",
"Database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_client_reports.py#L32-L37 | [
"def",
"WriteClientGraphSeries",
"(",
"self",
",",
"graph_series",
",",
"client_label",
",",
"timestamp",
")",
":",
"series_key",
"=",
"(",
"client_label",
",",
"graph_series",
".",
"report_type",
",",
"timestamp",
".",
"Copy",
"(",
")",
")",
"self",
".",
"c... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.