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
SplitBuffer
Parses the buffer as a prototypes. Args: buff: The buffer to parse. index: The position to start parsing. length: Optional length to parse until. Yields: Splits the buffer into tuples of strings: (encoded_tag, encoded_length, wire_format).
grr/core/grr_response_core/lib/rdfvalues/structs.py
def SplitBuffer(buff, index=0, length=None): """Parses the buffer as a prototypes. Args: buff: The buffer to parse. index: The position to start parsing. length: Optional length to parse until. Yields: Splits the buffer into tuples of strings: (encoded_tag, encoded_length, wire_format). ...
def SplitBuffer(buff, index=0, length=None): """Parses the buffer as a prototypes. Args: buff: The buffer to parse. index: The position to start parsing. length: Optional length to parse until. Yields: Splits the buffer into tuples of strings: (encoded_tag, encoded_length, wire_format). ...
[ "Parses", "the", "buffer", "as", "a", "prototypes", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L183-L225
[ "def", "SplitBuffer", "(", "buff", ",", "index", "=", "0", ",", "length", "=", "None", ")", ":", "buffer_len", "=", "length", "or", "len", "(", "buff", ")", "while", "index", "<", "buffer_len", ":", "# data_index is the index where the data begins (i.e. after th...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_GetOrderedEntries
Gets entries of `RDFProtoStruct` in a well-defined order. Args: data: A raw data dictionary of `RDFProtoStruct`. Yields: Entries of the structured in a well-defined order.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def _GetOrderedEntries(data): """Gets entries of `RDFProtoStruct` in a well-defined order. Args: data: A raw data dictionary of `RDFProtoStruct`. Yields: Entries of the structured in a well-defined order. """ # The raw data dictionary has two kinds of keys: strings (which correspond to # field na...
def _GetOrderedEntries(data): """Gets entries of `RDFProtoStruct` in a well-defined order. Args: data: A raw data dictionary of `RDFProtoStruct`. Yields: Entries of the structured in a well-defined order. """ # The raw data dictionary has two kinds of keys: strings (which correspond to # field na...
[ "Gets", "entries", "of", "RDFProtoStruct", "in", "a", "well", "-", "defined", "order", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L228-L259
[ "def", "_GetOrderedEntries", "(", "data", ")", ":", "# The raw data dictionary has two kinds of keys: strings (which correspond to", "# field name) or integers (if the name is unknown). In Python 3 it is not", "# possible to compare integers and strings to each other, so we first tag each", "# wit...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_SerializeEntries
Serializes given triplets of python and wire values and a descriptor.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def _SerializeEntries(entries): """Serializes given triplets of python and wire values and a descriptor.""" output = [] for python_format, wire_format, type_descriptor in entries: if wire_format is None or (python_format and type_descriptor.IsDirty(python_format)): wire_...
def _SerializeEntries(entries): """Serializes given triplets of python and wire values and a descriptor.""" output = [] for python_format, wire_format, type_descriptor in entries: if wire_format is None or (python_format and type_descriptor.IsDirty(python_format)): wire_...
[ "Serializes", "given", "triplets", "of", "python", "and", "wire", "values", "and", "a", "descriptor", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L262-L275
[ "def", "_SerializeEntries", "(", "entries", ")", ":", "output", "=", "[", "]", "for", "python_format", ",", "wire_format", ",", "type_descriptor", "in", "entries", ":", "if", "wire_format", "is", "None", "or", "(", "python_format", "and", "type_descriptor", "....
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ReadIntoObject
Reads all tags until the next end group and store in the value_obj.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ReadIntoObject(buff, index, value_obj, length=0): """Reads all tags until the next end group and store in the value_obj.""" raw_data = value_obj.GetRawData() count = 0 # Split the buffer into tags and wire_format representations, then collect # these into the raw data cache. for (encoded_tag, encoded_l...
def ReadIntoObject(buff, index, value_obj, length=0): """Reads all tags until the next end group and store in the value_obj.""" raw_data = value_obj.GetRawData() count = 0 # Split the buffer into tags and wire_format representations, then collect # these into the raw data cache. for (encoded_tag, encoded_l...
[ "Reads", "all", "tags", "until", "the", "next", "end", "group", "and", "store", "in", "the", "value_obj", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L278-L320
[ "def", "ReadIntoObject", "(", "buff", ",", "index", ",", "value_obj", ",", "length", "=", "0", ")", ":", "raw_data", "=", "value_obj", ".", "GetRawData", "(", ")", "count", "=", "0", "# Split the buffer into tags and wire_format representations, then collect", "# th...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoString.Validate
Validates a python format representation of the value.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Validate(self, value, **_): """Validates a python format representation of the value.""" if isinstance(value, rdfvalue.RDFString): # TODO(hanuszczak): Use `str` here. return Text(value) if isinstance(value, Text): return value if isinstance(value, bytes): return value.decod...
def Validate(self, value, **_): """Validates a python format representation of the value.""" if isinstance(value, rdfvalue.RDFString): # TODO(hanuszczak): Use `str` here. return Text(value) if isinstance(value, Text): return value if isinstance(value, bytes): return value.decod...
[ "Validates", "a", "python", "format", "representation", "of", "the", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L513-L525
[ "def", "Validate", "(", "self", ",", "value", ",", "*", "*", "_", ")", ":", "if", "isinstance", "(", "value", ",", "rdfvalue", ".", "RDFString", ")", ":", "# TODO(hanuszczak): Use `str` here.", "return", "Text", "(", "value", ")", "if", "isinstance", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoString.ConvertToWireFormat
Internally strings are utf8 encoded.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertToWireFormat(self, value): """Internally strings are utf8 encoded.""" value = value.encode("utf8") return (self.encoded_tag, VarintEncode(len(value)), value)
def ConvertToWireFormat(self, value): """Internally strings are utf8 encoded.""" value = value.encode("utf8") return (self.encoded_tag, VarintEncode(len(value)), value)
[ "Internally", "strings", "are", "utf8", "encoded", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L534-L537
[ "def", "ConvertToWireFormat", "(", "self", ",", "value", ")", ":", "value", "=", "value", ".", "encode", "(", "\"utf8\"", ")", "return", "(", "self", ".", "encoded_tag", ",", "VarintEncode", "(", "len", "(", "value", ")", ")", ",", "value", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEnum.Validate
Check that value is a valid enum.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Validate(self, value, **_): """Check that value is a valid enum.""" # None is a valid value - it means the field is not set. if value is None: return # If the value is a string we need to try to convert it to an integer. checked_value = value if isinstance(value, string_types): ...
def Validate(self, value, **_): """Check that value is a valid enum.""" # None is a valid value - it means the field is not set. if value is None: return # If the value is a string we need to try to convert it to an integer. checked_value = value if isinstance(value, string_types): ...
[ "Check", "that", "value", "is", "a", "valid", "enum", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L820-L839
[ "def", "Validate", "(", "self", ",", "value", ",", "*", "*", "_", ")", ":", "# None is a valid value - it means the field is not set.", "if", "value", "is", "None", ":", "return", "# If the value is a string we need to try to convert it to an integer.", "checked_value", "="...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEnum.Definition
Return a string with the definition of this field.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Definition(self): """Return a string with the definition of this field.""" result = self._FormatDescriptionComment() result += " enum %s {\n" % self.enum_name for k, v in sorted(iteritems(self.reverse_enum)): result += " %s = %s;\n" % (v, k) result += " }\n" result += self._For...
def Definition(self): """Return a string with the definition of this field.""" result = self._FormatDescriptionComment() result += " enum %s {\n" % self.enum_name for k, v in sorted(iteritems(self.reverse_enum)): result += " %s = %s;\n" % (v, k) result += " }\n" result += self._For...
[ "Return", "a", "string", "with", "the", "definition", "of", "this", "field", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L841-L852
[ "def", "Definition", "(", "self", ")", ":", "result", "=", "self", ".", "_FormatDescriptionComment", "(", ")", "result", "+=", "\" enum %s {\\n\"", "%", "self", ".", "enum_name", "for", "k", ",", "v", "in", "sorted", "(", "iteritems", "(", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoBoolean.GetDefault
Return boolean value.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def GetDefault(self, container=None): """Return boolean value.""" return rdfvalue.RDFBool( super(ProtoBoolean, self).GetDefault(container=container))
def GetDefault(self, container=None): """Return boolean value.""" return rdfvalue.RDFBool( super(ProtoBoolean, self).GetDefault(container=container))
[ "Return", "boolean", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L879-L882
[ "def", "GetDefault", "(", "self", ",", "container", "=", "None", ")", ":", "return", "rdfvalue", ".", "RDFBool", "(", "super", "(", "ProtoBoolean", ",", "self", ")", ".", "GetDefault", "(", "container", "=", "container", ")", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoBoolean.Validate
Check that value is a valid enum.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Validate(self, value, **_): """Check that value is a valid enum.""" if value is None: return return rdfvalue.RDFBool(super(ProtoBoolean, self).Validate(value))
def Validate(self, value, **_): """Check that value is a valid enum.""" if value is None: return return rdfvalue.RDFBool(super(ProtoBoolean, self).Validate(value))
[ "Check", "that", "value", "is", "a", "valid", "enum", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L884-L889
[ "def", "Validate", "(", "self", ",", "value", ",", "*", "*", "_", ")", ":", "if", "value", "is", "None", ":", "return", "return", "rdfvalue", ".", "RDFBool", "(", "super", "(", "ProtoBoolean", ",", "self", ")", ".", "Validate", "(", "value", ")", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEmbedded.ConvertFromWireFormat
The wire format is simply a string.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertFromWireFormat(self, value, container=None): """The wire format is simply a string.""" result = self.type() ReadIntoObject(value[2], 0, result) return result
def ConvertFromWireFormat(self, value, container=None): """The wire format is simply a string.""" result = self.type() ReadIntoObject(value[2], 0, result) return result
[ "The", "wire", "format", "is", "simply", "a", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L940-L945
[ "def", "ConvertFromWireFormat", "(", "self", ",", "value", ",", "container", "=", "None", ")", ":", "result", "=", "self", ".", "type", "(", ")", "ReadIntoObject", "(", "value", "[", "2", "]", ",", "0", ",", "result", ")", "return", "result" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEmbedded.ConvertToWireFormat
Encode the nested protobuf into wire format.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" output = _SerializeEntries(_GetOrderedEntries(value.GetRawData())) return (self.encoded_tag, VarintEncode(len(output)), output)
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" output = _SerializeEntries(_GetOrderedEntries(value.GetRawData())) return (self.encoded_tag, VarintEncode(len(output)), output)
[ "Encode", "the", "nested", "protobuf", "into", "wire", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L947-L950
[ "def", "ConvertToWireFormat", "(", "self", ",", "value", ")", ":", "output", "=", "_SerializeEntries", "(", "_GetOrderedEntries", "(", "value", ".", "GetRawData", "(", ")", ")", ")", "return", "(", "self", ".", "encoded_tag", ",", "VarintEncode", "(", "len",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEmbedded.LateBind
Late binding callback. This method is called on this field descriptor when the target RDFValue class is finally defined. It gives the field descriptor an opportunity to initialize after the point of definition. Args: target: The target nested class. Raises: TypeError: If the target cl...
grr/core/grr_response_core/lib/rdfvalues/structs.py
def LateBind(self, target=None): """Late binding callback. This method is called on this field descriptor when the target RDFValue class is finally defined. It gives the field descriptor an opportunity to initialize after the point of definition. Args: target: The target nested class. R...
def LateBind(self, target=None): """Late binding callback. This method is called on this field descriptor when the target RDFValue class is finally defined. It gives the field descriptor an opportunity to initialize after the point of definition. Args: target: The target nested class. R...
[ "Late", "binding", "callback", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L952-L975
[ "def", "LateBind", "(", "self", ",", "target", "=", "None", ")", ":", "if", "not", "issubclass", "(", "target", ",", "RDFProtoStruct", ")", ":", "raise", "TypeError", "(", "\"Field %s expects a protobuf, but target is %s\"", "%", "(", "self", ",", "target", ")...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoEmbedded.IsDirty
Return and clear the dirty state of the python object.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def IsDirty(self, proto): """Return and clear the dirty state of the python object.""" if proto.dirty: return True for python_format, _, type_descriptor in itervalues(proto.GetRawData()): if python_format is not None and type_descriptor.IsDirty(python_format): proto.dirty = True ...
def IsDirty(self, proto): """Return and clear the dirty state of the python object.""" if proto.dirty: return True for python_format, _, type_descriptor in itervalues(proto.GetRawData()): if python_format is not None and type_descriptor.IsDirty(python_format): proto.dirty = True ...
[ "Return", "and", "clear", "the", "dirty", "state", "of", "the", "python", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L977-L987
[ "def", "IsDirty", "(", "self", ",", "proto", ")", ":", "if", "proto", ".", "dirty", ":", "return", "True", "for", "python_format", ",", "_", ",", "type_descriptor", "in", "itervalues", "(", "proto", ".", "GetRawData", "(", ")", ")", ":", "if", "python_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoDynamicEmbedded.ConvertToWireFormat
Encode the nested protobuf into wire format.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" data = value.SerializeToString() return (self.encoded_tag, VarintEncode(len(data)), data)
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" data = value.SerializeToString() return (self.encoded_tag, VarintEncode(len(data)), data)
[ "Encode", "the", "nested", "protobuf", "into", "wire", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1049-L1052
[ "def", "ConvertToWireFormat", "(", "self", ",", "value", ")", ":", "data", "=", "value", ".", "SerializeToString", "(", ")", "return", "(", "self", ".", "encoded_tag", ",", "VarintEncode", "(", "len", "(", "data", ")", ")", ",", "data", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoDynamicAnyValueEmbedded.ConvertFromWireFormat
The wire format is an AnyValue message.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertFromWireFormat(self, value, container=None): """The wire format is an AnyValue message.""" result = AnyValue() ReadIntoObject(value[2], 0, result) if self._type is not None: converted_value = self._type(container) else: converted_value = self._TypeFromAnyValue(result) # I...
def ConvertFromWireFormat(self, value, container=None): """The wire format is an AnyValue message.""" result = AnyValue() ReadIntoObject(value[2], 0, result) if self._type is not None: converted_value = self._type(container) else: converted_value = self._TypeFromAnyValue(result) # I...
[ "The", "wire", "format", "is", "an", "AnyValue", "message", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1102-L1122
[ "def", "ConvertFromWireFormat", "(", "self", ",", "value", ",", "container", "=", "None", ")", ":", "result", "=", "AnyValue", "(", ")", "ReadIntoObject", "(", "value", "[", "2", "]", ",", "0", ",", "result", ")", "if", "self", ".", "_type", "is", "n...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoDynamicAnyValueEmbedded.ConvertToWireFormat
Encode the nested protobuf into wire format.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" # Is it a protobuf-based value? if hasattr(value.__class__, "protobuf"): if value.__class__.protobuf: type_name = ("type.googleapis.com/%s" % value.__class__.protobuf.__name__) e...
def ConvertToWireFormat(self, value): """Encode the nested protobuf into wire format.""" # Is it a protobuf-based value? if hasattr(value.__class__, "protobuf"): if value.__class__.protobuf: type_name = ("type.googleapis.com/%s" % value.__class__.protobuf.__name__) e...
[ "Encode", "the", "nested", "protobuf", "into", "wire", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1135-L1162
[ "def", "ConvertToWireFormat", "(", "self", ",", "value", ")", ":", "# Is it a protobuf-based value?", "if", "hasattr", "(", "value", ".", "__class__", ",", "\"protobuf\"", ")", ":", "if", "value", ".", "__class__", ".", "protobuf", ":", "type_name", "=", "(", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoList.Validate
Check that value is a list of the required type.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Validate(self, value, **_): """Check that value is a list of the required type.""" # Assigning from same kind can allow us to skip verification since all # elements in a RepeatedFieldHelper already are coerced to the delegate # type. In that case we just make a copy. This only works when the value ...
def Validate(self, value, **_): """Check that value is a list of the required type.""" # Assigning from same kind can allow us to skip verification since all # elements in a RepeatedFieldHelper already are coerced to the delegate # type. In that case we just make a copy. This only works when the value ...
[ "Check", "that", "value", "is", "a", "list", "of", "the", "required", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1370-L1386
[ "def", "Validate", "(", "self", ",", "value", ",", "*", "*", "_", ")", ":", "# Assigning from same kind can allow us to skip verification since all", "# elements in a RepeatedFieldHelper already are coerced to the delegate", "# type. In that case we just make a copy. This only works when...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoList.ConvertToWireFormat
Convert to the wire format. Args: value: is of type RepeatedFieldHelper. Returns: A wire format representation of the value.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def ConvertToWireFormat(self, value): """Convert to the wire format. Args: value: is of type RepeatedFieldHelper. Returns: A wire format representation of the value. """ output = _SerializeEntries( (python_format, wire_format, value.type_descriptor) for (python_format, ...
def ConvertToWireFormat(self, value): """Convert to the wire format. Args: value: is of type RepeatedFieldHelper. Returns: A wire format representation of the value. """ output = _SerializeEntries( (python_format, wire_format, value.type_descriptor) for (python_format, ...
[ "Convert", "to", "the", "wire", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1395-L1407
[ "def", "ConvertToWireFormat", "(", "self", ",", "value", ")", ":", "output", "=", "_SerializeEntries", "(", "(", "python_format", ",", "wire_format", ",", "value", ".", "type_descriptor", ")", "for", "(", "python_format", ",", "wire_format", ")", "in", "value"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoList.AddDescriptor
This method will be called by our delegate during late binding.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def AddDescriptor(self, field_desc): """This method will be called by our delegate during late binding.""" # Just relay it up to our owner. self.late_bound = False self.delegate = field_desc self.wire_type = self.delegate.wire_type self.owner.AddDescriptor(self)
def AddDescriptor(self, field_desc): """This method will be called by our delegate during late binding.""" # Just relay it up to our owner. self.late_bound = False self.delegate = field_desc self.wire_type = self.delegate.wire_type self.owner.AddDescriptor(self)
[ "This", "method", "will", "be", "called", "by", "our", "delegate", "during", "late", "binding", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1429-L1435
[ "def", "AddDescriptor", "(", "self", ",", "field_desc", ")", ":", "# Just relay it up to our owner.", "self", ".", "late_bound", "=", "False", "self", ".", "delegate", "=", "field_desc", "self", ".", "wire_type", "=", "self", ".", "delegate", ".", "wire_type", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoRDFValue.LateBind
Bind the field descriptor to the owner once the target is defined.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def LateBind(self, target=None): """Bind the field descriptor to the owner once the target is defined.""" self.type = target self._GetPrimitiveEncoder() # Now re-add the descriptor to the owner protobuf. self.late_bound = False self.owner.AddDescriptor(self)
def LateBind(self, target=None): """Bind the field descriptor to the owner once the target is defined.""" self.type = target self._GetPrimitiveEncoder() # Now re-add the descriptor to the owner protobuf. self.late_bound = False self.owner.AddDescriptor(self)
[ "Bind", "the", "field", "descriptor", "to", "the", "owner", "once", "the", "target", "is", "defined", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1518-L1525
[ "def", "LateBind", "(", "self", ",", "target", "=", "None", ")", ":", "self", ".", "type", "=", "target", "self", ".", "_GetPrimitiveEncoder", "(", ")", "# Now re-add the descriptor to the owner protobuf.", "self", ".", "late_bound", "=", "False", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoRDFValue._GetPrimitiveEncoder
Finds the primitive encoder according to the type's data_store_type.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def _GetPrimitiveEncoder(self): """Finds the primitive encoder according to the type's data_store_type.""" # Decide what should the primitive type be for packing the target rdfvalue # into the protobuf and create a delegate descriptor to control that. primitive_cls = self._PROTO_DATA_STORE_LOOKUP[self.t...
def _GetPrimitiveEncoder(self): """Finds the primitive encoder according to the type's data_store_type.""" # Decide what should the primitive type be for packing the target rdfvalue # into the protobuf and create a delegate descriptor to control that. primitive_cls = self._PROTO_DATA_STORE_LOOKUP[self.t...
[ "Finds", "the", "primitive", "encoder", "according", "to", "the", "type", "s", "data_store_type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1527-L1539
[ "def", "_GetPrimitiveEncoder", "(", "self", ")", ":", "# Decide what should the primitive type be for packing the target rdfvalue", "# into the protobuf and create a delegate descriptor to control that.", "primitive_cls", "=", "self", ".", "_PROTO_DATA_STORE_LOOKUP", "[", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ProtoRDFValue.Copy
Returns descriptor copy, optionally changing field number.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def Copy(self, field_number=None): """Returns descriptor copy, optionally changing field number.""" new_args = self._kwargs.copy() if field_number is not None: new_args["field_number"] = field_number return ProtoRDFValue( rdf_type=self.original_proto_type_name, default=getattr(sel...
def Copy(self, field_number=None): """Returns descriptor copy, optionally changing field number.""" new_args = self._kwargs.copy() if field_number is not None: new_args["field_number"] = field_number return ProtoRDFValue( rdf_type=self.original_proto_type_name, default=getattr(sel...
[ "Returns", "descriptor", "copy", "optionally", "changing", "field", "number", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L1582-L1591
[ "def", "Copy", "(", "self", ",", "field_number", "=", "None", ")", ":", "new_args", "=", "self", ".", "_kwargs", ".", "copy", "(", ")", "if", "field_number", "is", "not", "None", ":", "new_args", "[", "\"field_number\"", "]", "=", "field_number", "return...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFProtoStruct.AsPrimitiveProto
Return an old style protocol buffer object.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def AsPrimitiveProto(self): """Return an old style protocol buffer object.""" if self.protobuf: result = self.protobuf() result.ParseFromString(self.SerializeToString()) return result
def AsPrimitiveProto(self): """Return an old style protocol buffer object.""" if self.protobuf: result = self.protobuf() result.ParseFromString(self.SerializeToString()) return result
[ "Return", "an", "old", "style", "protocol", "buffer", "object", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L2011-L2016
[ "def", "AsPrimitiveProto", "(", "self", ")", ":", "if", "self", ".", "protobuf", ":", "result", "=", "self", ".", "protobuf", "(", ")", "result", ".", "ParseFromString", "(", "self", ".", "SerializeToString", "(", ")", ")", "return", "result" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFProtoStruct.FromDict
Initializes itself from a given dictionary.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def FromDict(self, dictionary): """Initializes itself from a given dictionary.""" dynamic_fields = [] for key, value in iteritems(dictionary): field_type_info = self.type_infos.get(key) if isinstance(field_type_info, ProtoEmbedded): nested_value = field_type_info.GetDefault(container=se...
def FromDict(self, dictionary): """Initializes itself from a given dictionary.""" dynamic_fields = [] for key, value in iteritems(dictionary): field_type_info = self.type_infos.get(key) if isinstance(field_type_info, ProtoEmbedded): nested_value = field_type_info.GetDefault(container=se...
[ "Initializes", "itself", "from", "a", "given", "dictionary", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L2026-L2063
[ "def", "FromDict", "(", "self", ",", "dictionary", ")", ":", "dynamic_fields", "=", "[", "]", "for", "key", ",", "value", "in", "iteritems", "(", "dictionary", ")", ":", "field_type_info", "=", "self", ".", "type_infos", ".", "get", "(", "key", ")", "i...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFProtoStruct.EmitProto
Emits .proto file definitions.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def EmitProto(cls): """Emits .proto file definitions.""" result = "message %s {\n" % cls.__name__ for _, desc in sorted(iteritems(cls.type_infos_by_field_number)): result += desc.Definition() result += "}\n" return result
def EmitProto(cls): """Emits .proto file definitions.""" result = "message %s {\n" % cls.__name__ for _, desc in sorted(iteritems(cls.type_infos_by_field_number)): result += desc.Definition() result += "}\n" return result
[ "Emits", ".", "proto", "file", "definitions", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L2106-L2113
[ "def", "EmitProto", "(", "cls", ")", ":", "result", "=", "\"message %s {\\n\"", "%", "cls", ".", "__name__", "for", "_", ",", "desc", "in", "sorted", "(", "iteritems", "(", "cls", ".", "type_infos_by_field_number", ")", ")", ":", "result", "+=", "desc", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFProtoStruct.FromTextFormat
Parse this object from a text representation.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def FromTextFormat(cls, text): """Parse this object from a text representation.""" tmp = cls.protobuf() # pylint: disable=not-callable text_format.Merge(text, tmp) return cls.FromSerializedString(tmp.SerializeToString())
def FromTextFormat(cls, text): """Parse this object from a text representation.""" tmp = cls.protobuf() # pylint: disable=not-callable text_format.Merge(text, tmp) return cls.FromSerializedString(tmp.SerializeToString())
[ "Parse", "this", "object", "from", "a", "text", "representation", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L2130-L2135
[ "def", "FromTextFormat", "(", "cls", ",", "text", ")", ":", "tmp", "=", "cls", ".", "protobuf", "(", ")", "# pylint: disable=not-callable", "text_format", ".", "Merge", "(", "text", ",", "tmp", ")", "return", "cls", ".", "FromSerializedString", "(", "tmp", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RDFProtoStruct.AddDescriptor
Register this descriptor with the Proto Struct.
grr/core/grr_response_core/lib/rdfvalues/structs.py
def AddDescriptor(cls, field_desc): """Register this descriptor with the Proto Struct.""" if not isinstance(field_desc, ProtoType): raise type_info.TypeValueError( "%s field '%s' should be of type ProtoType" % (cls.__name__, field_desc.name)) # Ensure the field descriptor knows th...
def AddDescriptor(cls, field_desc): """Register this descriptor with the Proto Struct.""" if not isinstance(field_desc, ProtoType): raise type_info.TypeValueError( "%s field '%s' should be of type ProtoType" % (cls.__name__, field_desc.name)) # Ensure the field descriptor knows th...
[ "Register", "this", "descriptor", "with", "the", "Proto", "Struct", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L2138-L2175
[ "def", "AddDescriptor", "(", "cls", ",", "field_desc", ")", ":", "if", "not", "isinstance", "(", "field_desc", ",", "ProtoType", ")", ":", "raise", "type_info", ".", "TypeValueError", "(", "\"%s field '%s' should be of type ProtoType\"", "%", "(", "cls", ".", "_...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RunInstaller
Run all registered installers. Run all the current installers and then exit the process.
grr/client/grr_response_client/installer.py
def RunInstaller(): """Run all registered installers. Run all the current installers and then exit the process. """ try: os.makedirs(os.path.dirname(config.CONFIG["Installer.logfile"])) except OSError: pass # Always log to the installer logfile at debug level. This way if our # installer fails ...
def RunInstaller(): """Run all registered installers. Run all the current installers and then exit the process. """ try: os.makedirs(os.path.dirname(config.CONFIG["Installer.logfile"])) except OSError: pass # Always log to the installer logfile at debug level. This way if our # installer fails ...
[ "Run", "all", "registered", "installers", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/installer.py#L39-L81
[ "def", "RunInstaller", "(", ")", ":", "try", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "config", ".", "CONFIG", "[", "\"Installer.logfile\"", "]", ")", ")", "except", "OSError", ":", "pass", "# Always log to the installer logfi...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MapItemsIterator
Maps ItemsIterator via given function.
api_client/python/grr_api_client/utils.py
def MapItemsIterator(function, items): """Maps ItemsIterator via given function.""" return ItemsIterator( items=map(function, items), total_count=items.total_count)
def MapItemsIterator(function, items): """Maps ItemsIterator via given function.""" return ItemsIterator( items=map(function, items), total_count=items.total_count)
[ "Maps", "ItemsIterator", "via", "given", "function", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L62-L65
[ "def", "MapItemsIterator", "(", "function", ",", "items", ")", ":", "return", "ItemsIterator", "(", "items", "=", "map", "(", "function", ",", "items", ")", ",", "total_count", "=", "items", ".", "total_count", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Poll
Periodically calls generator function until a condition is satisfied.
api_client/python/grr_api_client/utils.py
def Poll(generator=None, condition=None, interval=None, timeout=None): """Periodically calls generator function until a condition is satisfied.""" if not generator: raise ValueError("generator has to be a lambda") if not condition: raise ValueError("condition has to be a lambda") if interval is None:...
def Poll(generator=None, condition=None, interval=None, timeout=None): """Periodically calls generator function until a condition is satisfied.""" if not generator: raise ValueError("generator has to be a lambda") if not condition: raise ValueError("condition has to be a lambda") if interval is None:...
[ "Periodically", "calls", "generator", "function", "until", "a", "condition", "is", "satisfied", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L119-L144
[ "def", "Poll", "(", "generator", "=", "None", ",", "condition", "=", "None", ",", "interval", "=", "None", ",", "timeout", "=", "None", ")", ":", "if", "not", "generator", ":", "raise", "ValueError", "(", "\"generator has to be a lambda\"", ")", "if", "not...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UrnStringToClientId
Converts given URN string to a client id string.
api_client/python/grr_api_client/utils.py
def UrnStringToClientId(urn): """Converts given URN string to a client id string.""" if urn.startswith(AFF4_PREFIX): urn = urn[len(AFF4_PREFIX):] components = urn.split("/") return components[0]
def UrnStringToClientId(urn): """Converts given URN string to a client id string.""" if urn.startswith(AFF4_PREFIX): urn = urn[len(AFF4_PREFIX):] components = urn.split("/") return components[0]
[ "Converts", "given", "URN", "string", "to", "a", "client", "id", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L150-L156
[ "def", "UrnStringToClientId", "(", "urn", ")", ":", "if", "urn", ".", "startswith", "(", "AFF4_PREFIX", ")", ":", "urn", "=", "urn", "[", "len", "(", "AFF4_PREFIX", ")", ":", "]", "components", "=", "urn", ".", "split", "(", "\"/\"", ")", "return", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
UrnStringToHuntId
Converts given URN string to a flow id string.
api_client/python/grr_api_client/utils.py
def UrnStringToHuntId(urn): """Converts given URN string to a flow id string.""" if urn.startswith(AFF4_PREFIX): urn = urn[len(AFF4_PREFIX):] components = urn.split("/") if len(components) != 2 or components[0] != "hunts": raise ValueError("Invalid hunt URN: %s" % urn) return components[-1]
def UrnStringToHuntId(urn): """Converts given URN string to a flow id string.""" if urn.startswith(AFF4_PREFIX): urn = urn[len(AFF4_PREFIX):] components = urn.split("/") if len(components) != 2 or components[0] != "hunts": raise ValueError("Invalid hunt URN: %s" % urn) return components[-1]
[ "Converts", "given", "URN", "string", "to", "a", "flow", "id", "string", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L159-L168
[ "def", "UrnStringToHuntId", "(", "urn", ")", ":", "if", "urn", ".", "startswith", "(", "AFF4_PREFIX", ")", ":", "urn", "=", "urn", "[", "len", "(", "AFF4_PREFIX", ")", ":", "]", "components", "=", "urn", ".", "split", "(", "\"/\"", ")", "if", "len", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
TypeUrlToMessage
Returns a message instance corresponding to a given type URL.
api_client/python/grr_api_client/utils.py
def TypeUrlToMessage(type_url): """Returns a message instance corresponding to a given type URL.""" if not type_url.startswith(TYPE_URL_PREFIX): raise ValueError("Type URL has to start with a prefix %s: %s" % (TYPE_URL_PREFIX, type_url)) full_name = type_url[len(TYPE_URL_PREFIX):] try...
def TypeUrlToMessage(type_url): """Returns a message instance corresponding to a given type URL.""" if not type_url.startswith(TYPE_URL_PREFIX): raise ValueError("Type URL has to start with a prefix %s: %s" % (TYPE_URL_PREFIX, type_url)) full_name = type_url[len(TYPE_URL_PREFIX):] try...
[ "Returns", "a", "message", "instance", "corresponding", "to", "a", "given", "type", "URL", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L180-L191
[ "def", "TypeUrlToMessage", "(", "type_url", ")", ":", "if", "not", "type_url", ".", "startswith", "(", "TYPE_URL_PREFIX", ")", ":", "raise", "ValueError", "(", "\"Type URL has to start with a prefix %s: %s\"", "%", "(", "TYPE_URL_PREFIX", ",", "type_url", ")", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegisterProtoDescriptors
Registers all API-releated descriptors in a given symbol DB.
api_client/python/grr_api_client/utils.py
def RegisterProtoDescriptors(db, *additional_descriptors): """Registers all API-releated descriptors in a given symbol DB.""" db.RegisterFileDescriptor(artifact_pb2.DESCRIPTOR) db.RegisterFileDescriptor(client_pb2.DESCRIPTOR) db.RegisterFileDescriptor(config_pb2.DESCRIPTOR) db.RegisterFileDescriptor(cron_pb2....
def RegisterProtoDescriptors(db, *additional_descriptors): """Registers all API-releated descriptors in a given symbol DB.""" db.RegisterFileDescriptor(artifact_pb2.DESCRIPTOR) db.RegisterFileDescriptor(client_pb2.DESCRIPTOR) db.RegisterFileDescriptor(config_pb2.DESCRIPTOR) db.RegisterFileDescriptor(cron_pb2....
[ "Registers", "all", "API", "-", "releated", "descriptors", "in", "a", "given", "symbol", "DB", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/utils.py#L219-L241
[ "def", "RegisterProtoDescriptors", "(", "db", ",", "*", "additional_descriptors", ")", ":", "db", ".", "RegisterFileDescriptor", "(", "artifact_pb2", ".", "DESCRIPTOR", ")", "db", ".", "RegisterFileDescriptor", "(", "client_pb2", ".", "DESCRIPTOR", ")", "db", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_DateToEpoch
Converts python datetime to epoch microseconds.
grr/core/grr_response_core/lib/parsers/osx_file_parser.py
def _DateToEpoch(date): """Converts python datetime to epoch microseconds.""" tz_zero = datetime.datetime.utcfromtimestamp(0) diff_sec = int((date - tz_zero).total_seconds()) return diff_sec * 1000000
def _DateToEpoch(date): """Converts python datetime to epoch microseconds.""" tz_zero = datetime.datetime.utcfromtimestamp(0) diff_sec = int((date - tz_zero).total_seconds()) return diff_sec * 1000000
[ "Converts", "python", "datetime", "to", "epoch", "microseconds", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_file_parser.py#L220-L224
[ "def", "_DateToEpoch", "(", "date", ")", ":", "tz_zero", "=", "datetime", ".", "datetime", ".", "utcfromtimestamp", "(", "0", ")", "diff_sec", "=", "int", "(", "(", "date", "-", "tz_zero", ")", ".", "total_seconds", "(", ")", ")", "return", "diff_sec", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSXUsersParser.ParseMultiple
Parse the StatEntry objects.
grr/core/grr_response_core/lib/parsers/osx_file_parser.py
def ParseMultiple(self, stat_entries, knowledge_base): """Parse the StatEntry objects.""" _ = knowledge_base for stat_entry in stat_entries: # TODO: `st_mode` has to be an `int`, not `StatMode`. if stat.S_ISDIR(int(stat_entry.st_mode)): homedir = stat_entry.pathspec.path usernam...
def ParseMultiple(self, stat_entries, knowledge_base): """Parse the StatEntry objects.""" _ = knowledge_base for stat_entry in stat_entries: # TODO: `st_mode` has to be an `int`, not `StatMode`. if stat.S_ISDIR(int(stat_entry.st_mode)): homedir = stat_entry.pathspec.path usernam...
[ "Parse", "the", "StatEntry", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_file_parser.py#L29-L39
[ "def", "ParseMultiple", "(", "self", ",", "stat_entries", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "for", "stat_entry", "in", "stat_entries", ":", "# TODO: `st_mode` has to be an `int`, not `StatMode`.", "if", "stat", ".", "S_ISDIR", "(", "int", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSXSPHardwareDataTypeParser.Parse
Parse the system profiler output. We get it in the form of a plist.
grr/core/grr_response_core/lib/parsers/osx_file_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the system profiler output. We get it in the form of a plist.""" _ = stderr, time_taken, args, knowledge_base # Unused self.CheckReturn(cmd, return_val) plist = biplist.readPlist(io.BytesIO(stdout)...
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base): """Parse the system profiler output. We get it in the form of a plist.""" _ = stderr, time_taken, args, knowledge_base # Unused self.CheckReturn(cmd, return_val) plist = biplist.readPlist(io.BytesIO(stdout)...
[ "Parse", "the", "system", "profiler", "output", ".", "We", "get", "it", "in", "the", "form", "of", "a", "plist", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_file_parser.py#L47-L66
[ "def", "Parse", "(", "self", ",", "cmd", ",", "args", ",", "stdout", ",", "stderr", ",", "return_val", ",", "time_taken", ",", "knowledge_base", ")", ":", "_", "=", "stderr", ",", "time_taken", ",", "args", ",", "knowledge_base", "# Unused", "self", ".",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSXLaunchdPlistParser.Parse
Parse the Plist file.
grr/core/grr_response_core/lib/parsers/osx_file_parser.py
def Parse(self, statentry, file_object, knowledge_base): """Parse the Plist file.""" _ = knowledge_base kwargs = {} try: kwargs["aff4path"] = file_object.urn except AttributeError: pass direct_copy_items = [ "Label", "Disabled", "UserName", "GroupName", "Program", "S...
def Parse(self, statentry, file_object, knowledge_base): """Parse the Plist file.""" _ = knowledge_base kwargs = {} try: kwargs["aff4path"] = file_object.urn except AttributeError: pass direct_copy_items = [ "Label", "Disabled", "UserName", "GroupName", "Program", "S...
[ "Parse", "the", "Plist", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_file_parser.py#L77-L187
[ "def", "Parse", "(", "self", ",", "statentry", ",", "file_object", ",", "knowledge_base", ")", ":", "_", "=", "knowledge_base", "kwargs", "=", "{", "}", "try", ":", "kwargs", "[", "\"aff4path\"", "]", "=", "file_object", ".", "urn", "except", "AttributeErr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSXInstallHistoryPlistParser.Parse
Parse the Plist file.
grr/core/grr_response_core/lib/parsers/osx_file_parser.py
def Parse(self, statentry, file_object, knowledge_base): """Parse the Plist file.""" plist = biplist.readPlist(file_object) if not isinstance(plist, list): raise parser.ParseError( "InstallHistory plist is a '%s', expecting a list" % type(plist)) packages = [] for sw in plist: ...
def Parse(self, statentry, file_object, knowledge_base): """Parse the Plist file.""" plist = biplist.readPlist(file_object) if not isinstance(plist, list): raise parser.ParseError( "InstallHistory plist is a '%s', expecting a list" % type(plist)) packages = [] for sw in plist: ...
[ "Parse", "the", "Plist", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/osx_file_parser.py#L196-L217
[ "def", "Parse", "(", "self", ",", "statentry", ",", "file_object", ",", "knowledge_base", ")", ":", "plist", "=", "biplist", ".", "readPlist", "(", "file_object", ")", "if", "not", "isinstance", "(", "plist", ",", "list", ")", ":", "raise", "parser", "."...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
SetPlatformArchContext
Add the running contexts to the config system.
grr/core/grr_response_core/lib/config_lib.py
def SetPlatformArchContext(): """Add the running contexts to the config system.""" # Initialize the running platform context: _CONFIG.AddContext("Platform:%s" % platform.system().title()) machine = platform.uname()[4] if machine in ["x86_64", "AMD64", "i686"]: # 32 bit binaries running on AMD64 will sti...
def SetPlatformArchContext(): """Add the running contexts to the config system.""" # Initialize the running platform context: _CONFIG.AddContext("Platform:%s" % platform.system().title()) machine = platform.uname()[4] if machine in ["x86_64", "AMD64", "i686"]: # 32 bit binaries running on AMD64 will sti...
[ "Add", "the", "running", "contexts", "to", "the", "config", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L118-L136
[ "def", "SetPlatformArchContext", "(", ")", ":", "# Initialize the running platform context:", "_CONFIG", ".", "AddContext", "(", "\"Platform:%s\"", "%", "platform", ".", "system", "(", ")", ".", "title", "(", ")", ")", "machine", "=", "platform", ".", "uname", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
_ParseYamlFromFile
Parses given YAML file.
grr/core/grr_response_core/lib/config_lib.py
def _ParseYamlFromFile(filedesc): """Parses given YAML file.""" content = filedesc.read() return yaml.Parse(content) or collections.OrderedDict()
def _ParseYamlFromFile(filedesc): """Parses given YAML file.""" content = filedesc.read() return yaml.Parse(content) or collections.OrderedDict()
[ "Parses", "given", "YAML", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L548-L551
[ "def", "_ParseYamlFromFile", "(", "filedesc", ")", ":", "content", "=", "filedesc", ".", "read", "(", ")", "return", "yaml", ".", "Parse", "(", "content", ")", "or", "collections", ".", "OrderedDict", "(", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DEFINE_choice
A helper for defining choice string options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_choice(name, default, choices, help): """A helper for defining choice string options.""" _CONFIG.DEFINE_choice(name, default, choices, help)
def DEFINE_choice(name, default, choices, help): """A helper for defining choice string options.""" _CONFIG.DEFINE_choice(name, default, choices, help)
[ "A", "helper", "for", "defining", "choice", "string", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1615-L1617
[ "def", "DEFINE_choice", "(", "name", ",", "default", ",", "choices", ",", "help", ")", ":", "_CONFIG", ".", "DEFINE_choice", "(", "name", ",", "default", ",", "choices", ",", "help", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
DEFINE_multichoice
Choose multiple options from a list.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_multichoice(name, default, choices, help): """Choose multiple options from a list.""" _CONFIG.DEFINE_multichoice(name, default, choices, help)
def DEFINE_multichoice(name, default, choices, help): """Choose multiple options from a list.""" _CONFIG.DEFINE_multichoice(name, default, choices, help)
[ "Choose", "multiple", "options", "from", "a", "list", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1620-L1622
[ "def", "DEFINE_multichoice", "(", "name", ",", "default", ",", "choices", ",", "help", ")", ":", "_CONFIG", ".", "DEFINE_multichoice", "(", "name", ",", "default", ",", "choices", ",", "help", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LoadConfig
Initialize a ConfigManager with the specified options. Args: config_obj: The ConfigManager object to use and update. If None, one will be created. config_file: Filename to read the config from. config_fd: A file-like object to read config data from. secondary_configs: A list of secondary config...
grr/core/grr_response_core/lib/config_lib.py
def LoadConfig(config_obj, config_file=None, config_fd=None, secondary_configs=None, contexts=None, reset=False, parser=ConfigFileParser): """Initialize a ConfigManager with the specified options. Args: config_obj: The Co...
def LoadConfig(config_obj, config_file=None, config_fd=None, secondary_configs=None, contexts=None, reset=False, parser=ConfigFileParser): """Initialize a ConfigManager with the specified options. Args: config_obj: The Co...
[ "Initialize", "a", "ConfigManager", "with", "the", "specified", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1660-L1701
[ "def", "LoadConfig", "(", "config_obj", ",", "config_file", "=", "None", ",", "config_fd", "=", "None", ",", "secondary_configs", "=", "None", ",", "contexts", "=", "None", ",", "reset", "=", "False", ",", "parser", "=", "ConfigFileParser", ")", ":", "if",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ParseConfigCommandLine
Parse all the command line options which control the config system.
grr/core/grr_response_core/lib/config_lib.py
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is n...
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is n...
[ "Parse", "all", "the", "command", "line", "options", "which", "control", "the", "config", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1704-L1740
[ "def", "ParseConfigCommandLine", "(", ")", ":", "# The user may specify the primary config file on the command line.", "if", "flags", ".", "FLAGS", ".", "config", ":", "_CONFIG", ".", "Initialize", "(", "filename", "=", "flags", ".", "FLAGS", ".", "config", ",", "mu...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
Resource.Filter
Use pkg_resources to find the path to the required resource.
grr/core/grr_response_core/lib/config_lib.py
def Filter(self, filename_spec): """Use pkg_resources to find the path to the required resource.""" if "@" in filename_spec: file_path, package_name = filename_spec.split("@") else: file_path, package_name = filename_spec, Resource.default_package resource_path = package.ResourcePath(packag...
def Filter(self, filename_spec): """Use pkg_resources to find the path to the required resource.""" if "@" in filename_spec: file_path, package_name = filename_spec.split("@") else: file_path, package_name = filename_spec, Resource.default_package resource_path = package.ResourcePath(packag...
[ "Use", "pkg_resources", "to", "find", "the", "path", "to", "the", "required", "resource", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L279-L293
[ "def", "Filter", "(", "self", ",", "filename_spec", ")", ":", "if", "\"@\"", "in", "filename_spec", ":", "file_path", ",", "package_name", "=", "filename_spec", ".", "split", "(", "\"@\"", ")", "else", ":", "file_path", ",", "package_name", "=", "filename_sp...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
ConfigFileParser.SaveDataToFD
Merge the raw data with the config file and store it.
grr/core/grr_response_core/lib/config_lib.py
def SaveDataToFD(self, raw_data, fd): """Merge the raw data with the config file and store it.""" for key, value in iteritems(raw_data): # TODO(hanuszczak): Incorrect type specification for `set`. # pytype: disable=wrong-arg-types self.set("", key, value=value) # pytype: enable=wrong-arg...
def SaveDataToFD(self, raw_data, fd): """Merge the raw data with the config file and store it.""" for key, value in iteritems(raw_data): # TODO(hanuszczak): Incorrect type specification for `set`. # pytype: disable=wrong-arg-types self.set("", key, value=value) # pytype: enable=wrong-arg...
[ "Merge", "the", "raw", "data", "with", "the", "config", "file", "and", "store", "it", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L422-L430
[ "def", "SaveDataToFD", "(", "self", ",", "raw_data", ",", "fd", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "raw_data", ")", ":", "# TODO(hanuszczak): Incorrect type specification for `set`.", "# pytype: disable=wrong-arg-types", "self", ".", "set", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
YamlParser.SaveData
Store the raw data as our configuration.
grr/core/grr_response_core/lib/config_lib.py
def SaveData(self, raw_data): """Store the raw data as our configuration.""" if self.filename is None: raise IOError("Unknown filename") logging.info("Writing back configuration to file %s", self.filename) # Ensure intermediate directories exist try: os.makedirs(os.path.dirname(self.fil...
def SaveData(self, raw_data): """Store the raw data as our configuration.""" if self.filename is None: raise IOError("Unknown filename") logging.info("Writing back configuration to file %s", self.filename) # Ensure intermediate directories exist try: os.makedirs(os.path.dirname(self.fil...
[ "Store", "the", "raw", "data", "as", "our", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L485-L506
[ "def", "SaveData", "(", "self", ",", "raw_data", ")", ":", "if", "self", ".", "filename", "is", "None", ":", "raise", "IOError", "(", "\"Unknown filename\"", ")", "logging", ".", "info", "(", "\"Writing back configuration to file %s\"", ",", "self", ".", "file...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
YamlParser.SaveDataToFD
Merge the raw data with the config file and store it.
grr/core/grr_response_core/lib/config_lib.py
def SaveDataToFD(self, raw_data, fd): """Merge the raw data with the config file and store it.""" fd.write(yaml.Dump(raw_data).encode("utf-8"))
def SaveDataToFD(self, raw_data, fd): """Merge the raw data with the config file and store it.""" fd.write(yaml.Dump(raw_data).encode("utf-8"))
[ "Merge", "the", "raw", "data", "with", "the", "config", "file", "and", "store", "it", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L508-L510
[ "def", "SaveDataToFD", "(", "self", ",", "raw_data", ",", "fd", ")", ":", "fd", ".", "write", "(", "yaml", ".", "Dump", "(", "raw_data", ")", ".", "encode", "(", "\"utf-8\"", ")", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
YamlParser._RawData
Convert data to common format. Configuration options are normally grouped by the functional component which define it (e.g. Logging.path is the path parameter for the logging subsystem). However, sometimes it is more intuitive to write the config as a flat string (e.g. Logging.path). In this case we gr...
grr/core/grr_response_core/lib/config_lib.py
def _RawData(self, data): """Convert data to common format. Configuration options are normally grouped by the functional component which define it (e.g. Logging.path is the path parameter for the logging subsystem). However, sometimes it is more intuitive to write the config as a flat string (e.g. ...
def _RawData(self, data): """Convert data to common format. Configuration options are normally grouped by the functional component which define it (e.g. Logging.path is the path parameter for the logging subsystem). However, sometimes it is more intuitive to write the config as a flat string (e.g. ...
[ "Convert", "data", "to", "common", "format", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L512-L536
[ "def", "_RawData", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "data", "result", "=", "collections", ".", "OrderedDict", "(", ")", "for", "k", ",", "v", "in", "iteritems", "(", "data", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StringInterpolator.Escape
Support standard string escaping.
grr/core/grr_response_core/lib/config_lib.py
def Escape(self, string="", **_): """Support standard string escaping.""" # Translate special escapes: self.stack[-1] += self.STRING_ESCAPES.get(string, string)
def Escape(self, string="", **_): """Support standard string escaping.""" # Translate special escapes: self.stack[-1] += self.STRING_ESCAPES.get(string, string)
[ "Support", "standard", "string", "escaping", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L626-L629
[ "def", "Escape", "(", "self", ",", "string", "=", "\"\"", ",", "*", "*", "_", ")", ":", "# Translate special escapes:", "self", ".", "stack", "[", "-", "1", "]", "+=", "self", ".", "STRING_ESCAPES", ".", "get", "(", "string", ",", "string", ")" ]
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StringInterpolator.Filter
Filter the current expression.
grr/core/grr_response_core/lib/config_lib.py
def Filter(self, match=None, **_): """Filter the current expression.""" arg = self.stack.pop(-1) # Filters can be specified as a comma separated list. for filter_name in match.group(1).split(","): filter_object = ConfigFilter.classes_by_name.get(filter_name) if filter_object is None: ...
def Filter(self, match=None, **_): """Filter the current expression.""" arg = self.stack.pop(-1) # Filters can be specified as a comma separated list. for filter_name in match.group(1).split(","): filter_object = ConfigFilter.classes_by_name.get(filter_name) if filter_object is None: ...
[ "Filter", "the", "current", "expression", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L648-L663
[ "def", "Filter", "(", "self", ",", "match", "=", "None", ",", "*", "*", "_", ")", ":", "arg", "=", "self", ".", "stack", ".", "pop", "(", "-", "1", ")", "# Filters can be specified as a comma separated list.", "for", "filter_name", "in", "match", ".", "g...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StringInterpolator.ExpandArg
Expand the args as a section.parameter from the config.
grr/core/grr_response_core/lib/config_lib.py
def ExpandArg(self, **_): """Expand the args as a section.parameter from the config.""" # This function is called when we see close ) and the stack depth has to # exactly match the number of (. if len(self.stack) <= 1: raise lexer.ParseError( "Unbalanced parenthesis: Can not expand '%s'"...
def ExpandArg(self, **_): """Expand the args as a section.parameter from the config.""" # This function is called when we see close ) and the stack depth has to # exactly match the number of (. if len(self.stack) <= 1: raise lexer.ParseError( "Unbalanced parenthesis: Can not expand '%s'"...
[ "Expand", "the", "args", "as", "a", "section", ".", "parameter", "from", "the", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L665-L686
[ "def", "ExpandArg", "(", "self", ",", "*", "*", "_", ")", ":", "# This function is called when we see close ) and the stack depth has to", "# exactly match the number of (.", "if", "len", "(", "self", ".", "stack", ")", "<=", "1", ":", "raise", "lexer", ".", "ParseE...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.MakeNewConfig
Creates a new configuration option based on this one. Note that it is not normally possible to just instantiate the config object because it will have an empty set of type descriptors (i.e. no config options will be defined). Config options are normally defined at import time, and then they get add...
grr/core/grr_response_core/lib/config_lib.py
def MakeNewConfig(self): """Creates a new configuration option based on this one. Note that it is not normally possible to just instantiate the config object because it will have an empty set of type descriptors (i.e. no config options will be defined). Config options are normally defined at import...
def MakeNewConfig(self): """Creates a new configuration option based on this one. Note that it is not normally possible to just instantiate the config object because it will have an empty set of type descriptors (i.e. no config options will be defined). Config options are normally defined at import...
[ "Creates", "a", "new", "configuration", "option", "based", "on", "this", "one", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L750-L775
[ "def", "MakeNewConfig", "(", "self", ")", ":", "result", "=", "self", ".", "__class__", "(", ")", "# We do not need to copy here since these never change.", "result", ".", "type_infos", "=", "self", ".", "type_infos", "result", ".", "defaults", "=", "self", ".", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.CopyConfig
Make a complete new copy of the current config. This includes all options as they currently are. If you want a base config with defaults use MakeNewConfig. Returns: A new config object with the same data as self.
grr/core/grr_response_core/lib/config_lib.py
def CopyConfig(self): """Make a complete new copy of the current config. This includes all options as they currently are. If you want a base config with defaults use MakeNewConfig. Returns: A new config object with the same data as self. """ newconf = self.MakeNewConfig() newconf.raw...
def CopyConfig(self): """Make a complete new copy of the current config. This includes all options as they currently are. If you want a base config with defaults use MakeNewConfig. Returns: A new config object with the same data as self. """ newconf = self.MakeNewConfig() newconf.raw...
[ "Make", "a", "complete", "new", "copy", "of", "the", "current", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L777-L797
[ "def", "CopyConfig", "(", "self", ")", ":", "newconf", "=", "self", ".", "MakeNewConfig", "(", ")", "newconf", ".", "raw_data", "=", "copy", ".", "deepcopy", "(", "self", ".", "raw_data", ")", "newconf", ".", "files", "=", "copy", ".", "deepcopy", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.SetWriteBack
Sets the config file which will receive any modifications. The main config file can be made writable, but directing all Set() operations into a secondary location. This secondary location will receive any updates and will override the options for this file. Args: filename: A filename which will ...
grr/core/grr_response_core/lib/config_lib.py
def SetWriteBack(self, filename): """Sets the config file which will receive any modifications. The main config file can be made writable, but directing all Set() operations into a secondary location. This secondary location will receive any updates and will override the options for this file. Arg...
def SetWriteBack(self, filename): """Sets the config file which will receive any modifications. The main config file can be made writable, but directing all Set() operations into a secondary location. This secondary location will receive any updates and will override the options for this file. Arg...
[ "Sets", "the", "config", "file", "which", "will", "receive", "any", "modifications", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L799-L828
[ "def", "SetWriteBack", "(", "self", ",", "filename", ")", ":", "try", ":", "self", ".", "writeback", "=", "self", ".", "LoadSecondaryConfig", "(", "filename", ")", "self", ".", "MergeData", "(", "self", ".", "writeback", ".", "RawData", "(", ")", ",", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Validate
Validate sections or individual parameters. The GRR configuration file contains several sections, used by different components. Many of these components don't care about other sections. This method allows a component to declare in advance what sections and parameters it cares about, and have these vali...
grr/core/grr_response_core/lib/config_lib.py
def Validate(self, sections=None, parameters=None): """Validate sections or individual parameters. The GRR configuration file contains several sections, used by different components. Many of these components don't care about other sections. This method allows a component to declare in advance what sect...
def Validate(self, sections=None, parameters=None): """Validate sections or individual parameters. The GRR configuration file contains several sections, used by different components. Many of these components don't care about other sections. This method allows a component to declare in advance what sect...
[ "Validate", "sections", "or", "individual", "parameters", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L830-L873
[ "def", "Validate", "(", "self", ",", "sections", "=", "None", ",", "parameters", "=", "None", ")", ":", "if", "isinstance", "(", "sections", ",", "string_types", ")", ":", "sections", "=", "[", "sections", "]", "if", "sections", "is", "None", ":", "sec...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.AddContext
Adds a context string to the global configuration. The context conveys information about the caller of the config system and allows the configuration to have specialized results for different callers. Note that the configuration file may specify conflicting options for different contexts. In this case...
grr/core/grr_response_core/lib/config_lib.py
def AddContext(self, context_string, description=None): """Adds a context string to the global configuration. The context conveys information about the caller of the config system and allows the configuration to have specialized results for different callers. Note that the configuration file may speci...
def AddContext(self, context_string, description=None): """Adds a context string to the global configuration. The context conveys information about the caller of the config system and allows the configuration to have specialized results for different callers. Note that the configuration file may speci...
[ "Adds", "a", "context", "string", "to", "the", "global", "configuration", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L875-L902
[ "def", "AddContext", "(", "self", ",", "context_string", ",", "description", "=", "None", ")", ":", "if", "context_string", "not", "in", "self", ".", "context", ":", "if", "context_string", "not", "in", "self", ".", "valid_contexts", ":", "raise", "InvalidCo...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.SetRaw
Set the raw string without verification or escaping.
grr/core/grr_response_core/lib/config_lib.py
def SetRaw(self, name, value): """Set the raw string without verification or escaping.""" if self.writeback is None: logging.warning("Attempting to modify a read only config object.") if name in self.constants: raise ConstModificationError( "Attempting to modify constant value %s" % na...
def SetRaw(self, name, value): """Set the raw string without verification or escaping.""" if self.writeback is None: logging.warning("Attempting to modify a read only config object.") if name in self.constants: raise ConstModificationError( "Attempting to modify constant value %s" % na...
[ "Set", "the", "raw", "string", "without", "verification", "or", "escaping", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L915-L924
[ "def", "SetRaw", "(", "self", ",", "name", ",", "value", ")", ":", "if", "self", ".", "writeback", "is", "None", ":", "logging", ".", "warning", "(", "\"Attempting to modify a read only config object.\"", ")", "if", "name", "in", "self", ".", "constants", ":...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Set
Update the configuration option with a new value. Note that this forces the value to be set for all contexts. The value is written to the writeback location if Save() is later called. Args: name: The name of the parameter to set. value: The value to set it to. The value will be validated again...
grr/core/grr_response_core/lib/config_lib.py
def Set(self, name, value): """Update the configuration option with a new value. Note that this forces the value to be set for all contexts. The value is written to the writeback location if Save() is later called. Args: name: The name of the parameter to set. value: The value to set it to...
def Set(self, name, value): """Update the configuration option with a new value. Note that this forces the value to be set for all contexts. The value is written to the writeback location if Save() is later called. Args: name: The name of the parameter to set. value: The value to set it to...
[ "Update", "the", "configuration", "option", "with", "a", "new", "value", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L926-L957
[ "def", "Set", "(", "self", ",", "name", ",", "value", ")", ":", "# If the configuration system has a write back location we use it,", "# otherwise we use the primary configuration object.", "if", "self", ".", "writeback", "is", "None", ":", "logging", ".", "warning", "(",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Write
Write out the updated configuration to the fd.
grr/core/grr_response_core/lib/config_lib.py
def Write(self): """Write out the updated configuration to the fd.""" if self.writeback: self.writeback.SaveData(self.writeback_data) else: raise RuntimeError("Attempting to write a configuration without a " "writeback location.")
def Write(self): """Write out the updated configuration to the fd.""" if self.writeback: self.writeback.SaveData(self.writeback_data) else: raise RuntimeError("Attempting to write a configuration without a " "writeback location.")
[ "Write", "out", "the", "updated", "configuration", "to", "the", "fd", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L963-L969
[ "def", "Write", "(", "self", ")", ":", "if", "self", ".", "writeback", ":", "self", ".", "writeback", ".", "SaveData", "(", "self", ".", "writeback_data", ")", "else", ":", "raise", "RuntimeError", "(", "\"Attempting to write a configuration without a \"", "\"wr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.WriteToFD
Write out the updated configuration to the fd.
grr/core/grr_response_core/lib/config_lib.py
def WriteToFD(self, fd): """Write out the updated configuration to the fd.""" if self.writeback: self.writeback.SaveDataToFD(self.writeback_data, fd) else: raise RuntimeError("Attempting to write a configuration without a " "writeback location.")
def WriteToFD(self, fd): """Write out the updated configuration to the fd.""" if self.writeback: self.writeback.SaveDataToFD(self.writeback_data, fd) else: raise RuntimeError("Attempting to write a configuration without a " "writeback location.")
[ "Write", "out", "the", "updated", "configuration", "to", "the", "fd", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L971-L977
[ "def", "WriteToFD", "(", "self", ",", "fd", ")", ":", "if", "self", ".", "writeback", ":", "self", ".", "writeback", ".", "SaveDataToFD", "(", "self", ".", "writeback_data", ",", "fd", ")", "else", ":", "raise", "RuntimeError", "(", "\"Attempting to write ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Persist
Stores <config_option> in the writeback.
grr/core/grr_response_core/lib/config_lib.py
def Persist(self, config_option): """Stores <config_option> in the writeback.""" if not self.writeback: raise RuntimeError("Attempting to write a configuration without a " "writeback location.") writeback_raw_value = dict(self.writeback.RawData()).get(config_option) raw_v...
def Persist(self, config_option): """Stores <config_option> in the writeback.""" if not self.writeback: raise RuntimeError("Attempting to write a configuration without a " "writeback location.") writeback_raw_value = dict(self.writeback.RawData()).get(config_option) raw_v...
[ "Stores", "<config_option", ">", "in", "the", "writeback", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L979-L1005
[ "def", "Persist", "(", "self", ",", "config_option", ")", ":", "if", "not", "self", ".", "writeback", ":", "raise", "RuntimeError", "(", "\"Attempting to write a configuration without a \"", "\"writeback location.\"", ")", "writeback_raw_value", "=", "dict", "(", "sel...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.AddOption
Registers an option with the configuration system. Args: descriptor: A TypeInfoObject instance describing the option. constant: If this is set, the option is treated as a constant - it can be read at any time (before parsing the configuration) and it's an error to try to override it in ...
grr/core/grr_response_core/lib/config_lib.py
def AddOption(self, descriptor, constant=False): """Registers an option with the configuration system. Args: descriptor: A TypeInfoObject instance describing the option. constant: If this is set, the option is treated as a constant - it can be read at any time (before parsing the configurat...
def AddOption(self, descriptor, constant=False): """Registers an option with the configuration system. Args: descriptor: A TypeInfoObject instance describing the option. constant: If this is set, the option is treated as a constant - it can be read at any time (before parsing the configurat...
[ "Registers", "an", "option", "with", "the", "configuration", "system", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1007-L1036
[ "def", "AddOption", "(", "self", ",", "descriptor", ",", "constant", "=", "False", ")", ":", "if", "self", ".", "initialized", ":", "raise", "AlreadyInitializedError", "(", "\"Config was already initialized when defining %s\"", "%", "descriptor", ".", "name", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.MergeData
Merges data read from a config file into the current config.
grr/core/grr_response_core/lib/config_lib.py
def MergeData(self, merge_data, raw_data=None): """Merges data read from a config file into the current config.""" self.FlushCache() if raw_data is None: raw_data = self.raw_data for k, v in iteritems(merge_data): # A context clause. if isinstance(v, dict) and k not in self.type_infos...
def MergeData(self, merge_data, raw_data=None): """Merges data read from a config file into the current config.""" self.FlushCache() if raw_data is None: raw_data = self.raw_data for k, v in iteritems(merge_data): # A context clause. if isinstance(v, dict) and k not in self.type_infos...
[ "Merges", "data", "read", "from", "a", "config", "file", "into", "the", "current", "config", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1056-L1088
[ "def", "MergeData", "(", "self", ",", "merge_data", ",", "raw_data", "=", "None", ")", ":", "self", ".", "FlushCache", "(", ")", "if", "raw_data", "is", "None", ":", "raw_data", "=", "self", ".", "raw_data", "for", "k", ",", "v", "in", "iteritems", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.GetParserFromFilename
Returns the appropriate parser class from the filename.
grr/core/grr_response_core/lib/config_lib.py
def GetParserFromFilename(self, path): """Returns the appropriate parser class from the filename.""" # Find the configuration parser. handler_name = path.split("://")[0] for parser_cls in itervalues(GRRConfigParser.classes): if parser_cls.name == handler_name: return parser_cls # Hand...
def GetParserFromFilename(self, path): """Returns the appropriate parser class from the filename.""" # Find the configuration parser. handler_name = path.split("://")[0] for parser_cls in itervalues(GRRConfigParser.classes): if parser_cls.name == handler_name: return parser_cls # Hand...
[ "Returns", "the", "appropriate", "parser", "class", "from", "the", "filename", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1090-L1103
[ "def", "GetParserFromFilename", "(", "self", ",", "path", ")", ":", "# Find the configuration parser.", "handler_name", "=", "path", ".", "split", "(", "\"://\"", ")", "[", "0", "]", "for", "parser_cls", "in", "itervalues", "(", "GRRConfigParser", ".", "classes"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.LoadSecondaryConfig
Loads an additional configuration file. The configuration system has the concept of a single Primary configuration file, and multiple secondary files. The primary configuration file is the main file that is used by the program. Any writebacks will only be made to the primary configuration file. Seconda...
grr/core/grr_response_core/lib/config_lib.py
def LoadSecondaryConfig(self, filename=None, parser=None): """Loads an additional configuration file. The configuration system has the concept of a single Primary configuration file, and multiple secondary files. The primary configuration file is the main file that is used by the program. Any writeback...
def LoadSecondaryConfig(self, filename=None, parser=None): """Loads an additional configuration file. The configuration system has the concept of a single Primary configuration file, and multiple secondary files. The primary configuration file is the main file that is used by the program. Any writeback...
[ "Loads", "an", "additional", "configuration", "file", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1105-L1167
[ "def", "LoadSecondaryConfig", "(", "self", ",", "filename", "=", "None", ",", "parser", "=", "None", ")", ":", "if", "filename", ":", "# Maintain a stack of config file locations in loaded order.", "self", ".", "files", ".", "append", "(", "filename", ")", "parser...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Initialize
Initializes the config manager. This method is used to add more config options to the manager. The config can be given as one of the parameters as described in the Args section. Args: filename: The name of the configuration file to use. data: The configuration given directly as a long string o...
grr/core/grr_response_core/lib/config_lib.py
def Initialize(self, filename=None, data=None, fd=None, reset=True, must_exist=False, parser=ConfigFileParser): """Initializes the config manager. This method is used to add more config options to the manager....
def Initialize(self, filename=None, data=None, fd=None, reset=True, must_exist=False, parser=ConfigFileParser): """Initializes the config manager. This method is used to add more config options to the manager....
[ "Initializes", "the", "config", "manager", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1171-L1221
[ "def", "Initialize", "(", "self", ",", "filename", "=", "None", ",", "data", "=", "None", ",", "fd", "=", "None", ",", "reset", "=", "True", ",", "must_exist", "=", "False", ",", "parser", "=", "ConfigFileParser", ")", ":", "self", ".", "FlushCache", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.GetRaw
Get the raw value without interpolations.
grr/core/grr_response_core/lib/config_lib.py
def GetRaw(self, name, context=None, default=utils.NotAValue): """Get the raw value without interpolations.""" if context is None: context = self.context # Getting a raw value is pretty cheap so we wont bother with the cache here. _, value = self._GetValue(name, context, default=default) retu...
def GetRaw(self, name, context=None, default=utils.NotAValue): """Get the raw value without interpolations.""" if context is None: context = self.context # Getting a raw value is pretty cheap so we wont bother with the cache here. _, value = self._GetValue(name, context, default=default) retu...
[ "Get", "the", "raw", "value", "without", "interpolations", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1230-L1237
[ "def", "GetRaw", "(", "self", ",", "name", ",", "context", "=", "None", ",", "default", "=", "utils", ".", "NotAValue", ")", ":", "if", "context", "is", "None", ":", "context", "=", "self", ".", "context", "# Getting a raw value is pretty cheap so we wont both...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.Get
Get the value contained by the named parameter. This method applies interpolation/escaping of the named parameter and retrieves the interpolated value. Args: name: The name of the parameter to retrieve. This should be in the format of "Section.name" default: If retrieving the value re...
grr/core/grr_response_core/lib/config_lib.py
def Get(self, name, default=utils.NotAValue, context=None): """Get the value contained by the named parameter. This method applies interpolation/escaping of the named parameter and retrieves the interpolated value. Args: name: The name of the parameter to retrieve. This should be in the format ...
def Get(self, name, default=utils.NotAValue, context=None): """Get the value contained by the named parameter. This method applies interpolation/escaping of the named parameter and retrieves the interpolated value. Args: name: The name of the parameter to retrieve. This should be in the format ...
[ "Get", "the", "value", "contained", "by", "the", "named", "parameter", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1239-L1319
[ "def", "Get", "(", "self", ",", "name", ",", "default", "=", "utils", ".", "NotAValue", ",", "context", "=", "None", ")", ":", "if", "not", "self", ".", "initialized", ":", "if", "name", "not", "in", "self", ".", "constants", ":", "raise", "RuntimeEr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager._ResolveContext
Returns the config options active under this context.
grr/core/grr_response_core/lib/config_lib.py
def _ResolveContext(self, context, name, raw_data, path=None): """Returns the config options active under this context.""" if path is None: path = [] for element in context: if element not in self.valid_contexts: raise InvalidContextError("Invalid context specified: %s" % element) ...
def _ResolveContext(self, context, name, raw_data, path=None): """Returns the config options active under this context.""" if path is None: path = [] for element in context: if element not in self.valid_contexts: raise InvalidContextError("Invalid context specified: %s" % element) ...
[ "Returns", "the", "config", "options", "active", "under", "this", "context", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1321-L1343
[ "def", "_ResolveContext", "(", "self", ",", "context", ",", "name", ",", "raw_data", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "[", "]", "for", "element", "in", "context", ":", "if", "element", "not", "in", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager._GetValue
Search for the value based on the context.
grr/core/grr_response_core/lib/config_lib.py
def _GetValue(self, name, context, default=utils.NotAValue): """Search for the value based on the context.""" container = self.defaults # The caller provided a default value. if default is not utils.NotAValue: value = default # Take the default from the definition. elif name in self.defa...
def _GetValue(self, name, context, default=utils.NotAValue): """Search for the value based on the context.""" container = self.defaults # The caller provided a default value. if default is not utils.NotAValue: value = default # Take the default from the definition. elif name in self.defa...
[ "Search", "for", "the", "value", "based", "on", "the", "context", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1345-L1405
[ "def", "_GetValue", "(", "self", ",", "name", ",", "context", ",", "default", "=", "utils", ".", "NotAValue", ")", ":", "container", "=", "self", ".", "defaults", "# The caller provided a default value.", "if", "default", "is", "not", "utils", ".", "NotAValue"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.FindTypeInfo
Search for a type_info instance which describes this key.
grr/core/grr_response_core/lib/config_lib.py
def FindTypeInfo(self, name): """Search for a type_info instance which describes this key.""" result = self.type_infos.get(name) if result is None: # Not found, assume string. result = type_info.String(name=name, default="") return result
def FindTypeInfo(self, name): """Search for a type_info instance which describes this key.""" result = self.type_infos.get(name) if result is None: # Not found, assume string. result = type_info.String(name=name, default="") return result
[ "Search", "for", "a", "type_info", "instance", "which", "describes", "this", "key", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1407-L1414
[ "def", "FindTypeInfo", "(", "self", ",", "name", ")", ":", "result", "=", "self", ".", "type_infos", ".", "get", "(", "name", ")", "if", "result", "is", "None", ":", "# Not found, assume string.", "result", "=", "type_info", ".", "String", "(", "name", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.InterpolateValue
Interpolate the value and parse it with the appropriate type.
grr/core/grr_response_core/lib/config_lib.py
def InterpolateValue(self, value, type_info_obj=type_info.String(), default_section=None, context=None): """Interpolate the value and parse it with the appropriate type.""" # It is only possible to interpolate strings......
def InterpolateValue(self, value, type_info_obj=type_info.String(), default_section=None, context=None): """Interpolate the value and parse it with the appropriate type.""" # It is only possible to interpolate strings......
[ "Interpolate", "the", "value", "and", "parse", "it", "with", "the", "appropriate", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1416-L1449
[ "def", "InterpolateValue", "(", "self", ",", "value", ",", "type_info_obj", "=", "type_info", ".", "String", "(", ")", ",", "default_section", "=", "None", ",", "context", "=", "None", ")", ":", "# It is only possible to interpolate strings...", "if", "isinstance"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.MatchBuildContext
Return true if target_platforms matches the supplied parameters. Used by buildanddeploy to determine what clients need to be built. Args: target_os: which os we are building for in this run (linux, windows, darwin) target_arch: which arch we are building for in this run (i386, amd64) ...
grr/core/grr_response_core/lib/config_lib.py
def MatchBuildContext(self, target_os, target_arch, target_package, context=None): """Return true if target_platforms matches the supplied parameters. Used by buildanddeploy to determine what clients need to be buil...
def MatchBuildContext(self, target_os, target_arch, target_package, context=None): """Return true if target_platforms matches the supplied parameters. Used by buildanddeploy to determine what clients need to be buil...
[ "Return", "true", "if", "target_platforms", "matches", "the", "supplied", "parameters", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1458-L1482
[ "def", "MatchBuildContext", "(", "self", ",", "target_os", ",", "target_arch", ",", "target_package", ",", "context", "=", "None", ")", ":", "for", "spec", "in", "self", ".", "Get", "(", "\"ClientBuilder.target_platforms\"", ",", "context", "=", "context", ")"...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_bool
A helper for defining boolean options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_bool(self, name, default, help, constant=False): """A helper for defining boolean options.""" self.AddOption( type_info.Bool(name=name, default=default, description=help), constant=constant)
def DEFINE_bool(self, name, default, help, constant=False): """A helper for defining boolean options.""" self.AddOption( type_info.Bool(name=name, default=default, description=help), constant=constant)
[ "A", "helper", "for", "defining", "boolean", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1485-L1489
[ "def", "DEFINE_bool", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "Bool", "(", "name", "=", "name", ",", "default", "=", "default", ",", "description",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_float
A helper for defining float options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_float(self, name, default, help, constant=False): """A helper for defining float options.""" self.AddOption( type_info.Float(name=name, default=default, description=help), constant=constant)
def DEFINE_float(self, name, default, help, constant=False): """A helper for defining float options.""" self.AddOption( type_info.Float(name=name, default=default, description=help), constant=constant)
[ "A", "helper", "for", "defining", "float", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1491-L1495
[ "def", "DEFINE_float", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "Float", "(", "name", "=", "name", ",", "default", "=", "default", ",", "description...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_integer
A helper for defining integer options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_integer(self, name, default, help, constant=False): """A helper for defining integer options.""" self.AddOption( type_info.Integer(name=name, default=default, description=help), constant=constant)
def DEFINE_integer(self, name, default, help, constant=False): """A helper for defining integer options.""" self.AddOption( type_info.Integer(name=name, default=default, description=help), constant=constant)
[ "A", "helper", "for", "defining", "integer", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1497-L1501
[ "def", "DEFINE_integer", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "Integer", "(", "name", "=", "name", ",", "default", "=", "default", ",", "descrip...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_string
A helper for defining string options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_string(self, name, default, help, constant=False): """A helper for defining string options.""" self.AddOption( type_info.String(name=name, default=default or "", description=help), constant=constant)
def DEFINE_string(self, name, default, help, constant=False): """A helper for defining string options.""" self.AddOption( type_info.String(name=name, default=default or "", description=help), constant=constant)
[ "A", "helper", "for", "defining", "string", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1503-L1507
[ "def", "DEFINE_string", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "String", "(", "name", "=", "name", ",", "default", "=", "default", "or", "\"\"", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_choice
A helper for defining choice string options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_choice(self, name, default, choices, help, constant=False): """A helper for defining choice string options.""" self.AddOption( type_info.Choice( name=name, default=default, choices=choices, description=help), constant=constant)
def DEFINE_choice(self, name, default, choices, help, constant=False): """A helper for defining choice string options.""" self.AddOption( type_info.Choice( name=name, default=default, choices=choices, description=help), constant=constant)
[ "A", "helper", "for", "defining", "choice", "string", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1509-L1514
[ "def", "DEFINE_choice", "(", "self", ",", "name", ",", "default", ",", "choices", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "Choice", "(", "name", "=", "name", ",", "default", "=", "default",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_multichoice
Choose multiple options from a list.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_multichoice(self, name, default, choices, help, constant=False): """Choose multiple options from a list.""" self.AddOption( type_info.MultiChoice( name=name, default=default, choices=choices, description=help), constant=constant)
def DEFINE_multichoice(self, name, default, choices, help, constant=False): """Choose multiple options from a list.""" self.AddOption( type_info.MultiChoice( name=name, default=default, choices=choices, description=help), constant=constant)
[ "Choose", "multiple", "options", "from", "a", "list", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1516-L1521
[ "def", "DEFINE_multichoice", "(", "self", ",", "name", ",", "default", ",", "choices", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "MultiChoice", "(", "name", "=", "name", ",", "default", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_integer_list
A helper for defining lists of integer options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_integer_list(self, name, default, help, constant=False): """A helper for defining lists of integer options.""" self.AddOption( type_info.List( name=name, default=default, description=help, validator=type_info.Integer()), constant=constan...
def DEFINE_integer_list(self, name, default, help, constant=False): """A helper for defining lists of integer options.""" self.AddOption( type_info.List( name=name, default=default, description=help, validator=type_info.Integer()), constant=constan...
[ "A", "helper", "for", "defining", "lists", "of", "integer", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1523-L1531
[ "def", "DEFINE_integer_list", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "List", "(", "name", "=", "name", ",", "default", "=", "default", ",", "descr...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_list
A helper for defining lists of strings options.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_list(self, name, default, help, constant=False): """A helper for defining lists of strings options.""" self.AddOption( type_info.List( name=name, default=default, description=help, validator=type_info.String()), constant=constant)
def DEFINE_list(self, name, default, help, constant=False): """A helper for defining lists of strings options.""" self.AddOption( type_info.List( name=name, default=default, description=help, validator=type_info.String()), constant=constant)
[ "A", "helper", "for", "defining", "lists", "of", "strings", "options", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1533-L1541
[ "def", "DEFINE_list", "(", "self", ",", "name", ",", "default", ",", "help", ",", "constant", "=", "False", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "List", "(", "name", "=", "name", ",", "default", "=", "default", ",", "description",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
GrrConfigManager.DEFINE_constant_string
A helper for defining constant strings.
grr/core/grr_response_core/lib/config_lib.py
def DEFINE_constant_string(self, name, default, help): """A helper for defining constant strings.""" self.AddOption( type_info.String(name=name, default=default or "", description=help), constant=True)
def DEFINE_constant_string(self, name, default, help): """A helper for defining constant strings.""" self.AddOption( type_info.String(name=name, default=default or "", description=help), constant=True)
[ "A", "helper", "for", "defining", "constant", "strings", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1543-L1547
[ "def", "DEFINE_constant_string", "(", "self", ",", "name", ",", "default", ",", "help", ")", ":", "self", ".", "AddOption", "(", "type_info", ".", "String", "(", "name", "=", "name", ",", "default", "=", "default", "or", "\"\"", ",", "description", "=", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
RegistryConfigParser.RawData
Yields the valus in each section.
grr/client/grr_response_client/windows/regconfig.py
def RawData(self): """Yields the valus in each section.""" result = collections.OrderedDict() i = 0 while True: try: name, value, value_type = winreg.EnumValue(self._AccessRootKey(), i) # Only support strings here. if value_type == winreg.REG_SZ: precondition.Ass...
def RawData(self): """Yields the valus in each section.""" result = collections.OrderedDict() i = 0 while True: try: name, value, value_type = winreg.EnumValue(self._AccessRootKey(), i) # Only support strings here. if value_type == winreg.REG_SZ: precondition.Ass...
[ "Yields", "the", "valus", "in", "each", "section", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/regconfig.py#L59-L76
[ "def", "RawData", "(", "self", ")", ":", "result", "=", "collections", ".", "OrderedDict", "(", ")", "i", "=", "0", "while", "True", ":", "try", ":", "name", ",", "value", ",", "value_type", "=", "winreg", ".", "EnumValue", "(", "self", ".", "_Access...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBEventMixin.ReadAPIAuditEntries
Returns audit entries stored in the database.
grr/server/grr_response_server/databases/mysql_events.py
def ReadAPIAuditEntries(self, username=None, router_method_names=None, min_timestamp=None, max_timestamp=None, cursor=None): """Returns audit entries stored in the database.""" quer...
def ReadAPIAuditEntries(self, username=None, router_method_names=None, min_timestamp=None, max_timestamp=None, cursor=None): """Returns audit entries stored in the database.""" quer...
[ "Returns", "audit", "entries", "stored", "in", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_events.py#L22-L68
[ "def", "ReadAPIAuditEntries", "(", "self", ",", "username", "=", "None", ",", "router_method_names", "=", "None", ",", "min_timestamp", "=", "None", ",", "max_timestamp", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"SELECT details, t...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBEventMixin.CountAPIAuditEntriesByUserAndDay
Returns audit entry counts grouped by user and calendar day.
grr/server/grr_response_server/databases/mysql_events.py
def CountAPIAuditEntriesByUserAndDay(self, min_timestamp=None, max_timestamp=None, cursor=None): """Returns audit entry counts grouped by user and calendar day.""" query = """ -- Timestam...
def CountAPIAuditEntriesByUserAndDay(self, min_timestamp=None, max_timestamp=None, cursor=None): """Returns audit entry counts grouped by user and calendar day.""" query = """ -- Timestam...
[ "Returns", "audit", "entry", "counts", "grouped", "by", "user", "and", "calendar", "day", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_events.py#L71-L108
[ "def", "CountAPIAuditEntriesByUserAndDay", "(", "self", ",", "min_timestamp", "=", "None", ",", "max_timestamp", "=", "None", ",", "cursor", "=", "None", ")", ":", "query", "=", "\"\"\"\n -- Timestamps are timezone-agnostic whereas dates are not. Hence, we are\n ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
MySQLDBEventMixin.WriteAPIAuditEntry
Writes an audit entry to the database.
grr/server/grr_response_server/databases/mysql_events.py
def WriteAPIAuditEntry(self, entry, cursor=None): """Writes an audit entry to the database.""" args = { "username": entry.username, "router_method_name": entry.router_method_name, "details": entry.SerializeToString(), "timestamp": m...
def WriteAPIAuditEntry(self, entry, cursor=None): """Writes an audit entry to the database.""" args = { "username": entry.username, "router_method_name": entry.router_method_name, "details": entry.SerializeToString(), "timestamp": m...
[ "Writes", "an", "audit", "entry", "to", "the", "database", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_events.py#L111-L129
[ "def", "WriteAPIAuditEntry", "(", "self", ",", "entry", ",", "cursor", "=", "None", ")", ":", "args", "=", "{", "\"username\"", ":", "entry", ".", "username", ",", "\"router_method_name\"", ":", "entry", ".", "router_method_name", ",", "\"details\"", ":", "e...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
LastActiveReportPlugin.GetReportData
Show how the last active breakdown evolved over time.
grr/server/grr_response_server/gui/api_plugins/report_plugins/client_report_plugins.py
def GetReportData(self, get_report_args, token): """Show how the last active breakdown evolved over time.""" report = rdf_report_plugins.ApiReportData( representation_type=rdf_report_plugins.ApiReportData.RepresentationType .LINE_CHART) series_with_timestamps = client_report_utils.FetchAllG...
def GetReportData(self, get_report_args, token): """Show how the last active breakdown evolved over time.""" report = rdf_report_plugins.ApiReportData( representation_type=rdf_report_plugins.ApiReportData.RepresentationType .LINE_CHART) series_with_timestamps = client_report_utils.FetchAllG...
[ "Show", "how", "the", "last", "active", "breakdown", "evolved", "over", "time", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/client_report_plugins.py#L107-L136
[ "def", "GetReportData", "(", "self", ",", "get_report_args", ",", "token", ")", ":", "report", "=", "rdf_report_plugins", ".", "ApiReportData", "(", "representation_type", "=", "rdf_report_plugins", ".", "ApiReportData", ".", "RepresentationType", ".", "LINE_CHART", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
OSBreakdown1ReportPlugin.GetReportData
Extract only the operating system type from the active histogram.
grr/server/grr_response_server/gui/api_plugins/report_plugins/client_report_plugins.py
def GetReportData(self, get_report_args, token): """Extract only the operating system type from the active histogram.""" report = rdf_report_plugins.ApiReportData( representation_type=rdf_report_plugins.ApiReportData.RepresentationType .PIE_CHART) graph_series = client_report_utils.FetchMos...
def GetReportData(self, get_report_args, token): """Extract only the operating system type from the active histogram.""" report = rdf_report_plugins.ApiReportData( representation_type=rdf_report_plugins.ApiReportData.RepresentationType .PIE_CHART) graph_series = client_report_utils.FetchMos...
[ "Extract", "only", "the", "operating", "system", "type", "from", "the", "active", "histogram", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/report_plugins/client_report_plugins.py#L149-L172
[ "def", "GetReportData", "(", "self", ",", "get_report_args", ",", "token", ")", ":", "report", "=", "rdf_report_plugins", ".", "ApiReportData", "(", "representation_type", "=", "rdf_report_plugins", ".", "ApiReportData", ".", "RepresentationType", ".", "PIE_CHART", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StartService
Start a Windows service with the given name. Args: service_name: string The name of the service to be started.
grr/client/grr_response_client/windows/installers.py
def StartService(service_name): """Start a Windows service with the given name. Args: service_name: string The name of the service to be started. """ try: win32serviceutil.StartService(service_name) logging.info("Service '%s' started.", service_name) except pywintypes.error as e: if getattr(e...
def StartService(service_name): """Start a Windows service with the given name. Args: service_name: string The name of the service to be started. """ try: win32serviceutil.StartService(service_name) logging.info("Service '%s' started.", service_name) except pywintypes.error as e: if getattr(e...
[ "Start", "a", "Windows", "service", "with", "the", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L39-L53
[ "def", "StartService", "(", "service_name", ")", ":", "try", ":", "win32serviceutil", ".", "StartService", "(", "service_name", ")", "logging", ".", "info", "(", "\"Service '%s' started.\"", ",", "service_name", ")", "except", "pywintypes", ".", "error", "as", "...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
StopService
Stop a Windows service with the given name. Args: service_name: string The name of the service to be stopped. service_binary_name: string If given, also kill this binary as a best effort fallback solution.
grr/client/grr_response_client/windows/installers.py
def StopService(service_name, service_binary_name=None): """Stop a Windows service with the given name. Args: service_name: string The name of the service to be stopped. service_binary_name: string If given, also kill this binary as a best effort fallback solution. """ # QueryServiceStatus retu...
def StopService(service_name, service_binary_name=None): """Stop a Windows service with the given name. Args: service_name: string The name of the service to be stopped. service_binary_name: string If given, also kill this binary as a best effort fallback solution. """ # QueryServiceStatus retu...
[ "Stop", "a", "Windows", "service", "with", "the", "given", "name", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L56-L104
[ "def", "StopService", "(", "service_name", ",", "service_binary_name", "=", "None", ")", ":", "# QueryServiceStatus returns: scvType, svcState, svcControls, err,", "# svcErr, svcCP, svcWH", "try", ":", "status", "=", "win32serviceutil", ".", "QueryServiceStatus", "(", "servic...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CopyToSystemDir.StopPreviousService
Stops the Windows service hosting the GRR process.
grr/client/grr_response_client/windows/installers.py
def StopPreviousService(self): """Stops the Windows service hosting the GRR process.""" StopService( service_name=config.CONFIG["Nanny.service_name"], service_binary_name=config.CONFIG["Nanny.service_binary_name"]) if not config.CONFIG["Client.fleetspeak_enabled"]: return StopSer...
def StopPreviousService(self): """Stops the Windows service hosting the GRR process.""" StopService( service_name=config.CONFIG["Nanny.service_name"], service_binary_name=config.CONFIG["Nanny.service_binary_name"]) if not config.CONFIG["Client.fleetspeak_enabled"]: return StopSer...
[ "Stops", "the", "Windows", "service", "hosting", "the", "GRR", "process", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L141-L165
[ "def", "StopPreviousService", "(", "self", ")", ":", "StopService", "(", "service_name", "=", "config", ".", "CONFIG", "[", "\"Nanny.service_name\"", "]", ",", "service_binary_name", "=", "config", ".", "CONFIG", "[", "\"Nanny.service_binary_name\"", "]", ")", "if...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CopyToSystemDir.RunOnce
Copy the binaries from the temporary unpack location. We need to first stop the running service or we might not be able to write on the binary. We then copy the entire directory where we are running from into the location indicated by "Client.install_path".
grr/client/grr_response_client/windows/installers.py
def RunOnce(self): """Copy the binaries from the temporary unpack location. We need to first stop the running service or we might not be able to write on the binary. We then copy the entire directory where we are running from into the location indicated by "Client.install_path". """ self.StopPr...
def RunOnce(self): """Copy the binaries from the temporary unpack location. We need to first stop the running service or we might not be able to write on the binary. We then copy the entire directory where we are running from into the location indicated by "Client.install_path". """ self.StopPr...
[ "Copy", "the", "binaries", "from", "the", "temporary", "unpack", "location", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L167-L219
[ "def", "RunOnce", "(", "self", ")", ":", "self", ".", "StopPreviousService", "(", ")", "executable_directory", "=", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", "install_path", "=", "config", ".", "CONFIG", "[", "\"Client.install_pa...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
WindowsInstaller.InstallNanny
Install the nanny program.
grr/client/grr_response_client/windows/installers.py
def InstallNanny(self): """Install the nanny program.""" # We need to copy the nanny sections to the registry to ensure the # service is correctly configured. new_config = config.CONFIG.MakeNewConfig() new_config.SetWriteBack(config.CONFIG["Config.writeback"]) for option in self.nanny_options: ...
def InstallNanny(self): """Install the nanny program.""" # We need to copy the nanny sections to the registry to ensure the # service is correctly configured. new_config = config.CONFIG.MakeNewConfig() new_config.SetWriteBack(config.CONFIG["Config.writeback"]) for option in self.nanny_options: ...
[ "Install", "the", "nanny", "program", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L235-L255
[ "def", "InstallNanny", "(", "self", ")", ":", "# We need to copy the nanny sections to the registry to ensure the", "# service is correctly configured.", "new_config", "=", "config", ".", "CONFIG", ".", "MakeNewConfig", "(", ")", "new_config", ".", "SetWriteBack", "(", "con...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
BuildLegacySubject
Builds a legacy AFF4 urn string for a given subject and approval type.
grr/server/grr_response_server/gui/approval_checks.py
def BuildLegacySubject(subject_id, approval_type): """Builds a legacy AFF4 urn string for a given subject and approval type.""" at = rdf_objects.ApprovalRequest.ApprovalType if approval_type == at.APPROVAL_TYPE_CLIENT: return "aff4:/%s" % subject_id elif approval_type == at.APPROVAL_TYPE_HUNT: return "...
def BuildLegacySubject(subject_id, approval_type): """Builds a legacy AFF4 urn string for a given subject and approval type.""" at = rdf_objects.ApprovalRequest.ApprovalType if approval_type == at.APPROVAL_TYPE_CLIENT: return "aff4:/%s" % subject_id elif approval_type == at.APPROVAL_TYPE_HUNT: return "...
[ "Builds", "a", "legacy", "AFF4", "urn", "string", "for", "a", "given", "subject", "and", "approval", "type", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/approval_checks.py#L15-L26
[ "def", "BuildLegacySubject", "(", "subject_id", ",", "approval_type", ")", ":", "at", "=", "rdf_objects", ".", "ApprovalRequest", ".", "ApprovalType", "if", "approval_type", "==", "at", ".", "APPROVAL_TYPE_CLIENT", ":", "return", "\"aff4:/%s\"", "%", "subject_id", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CheckClientApprovalRequest
Checks if a client approval request is granted.
grr/server/grr_response_server/gui/approval_checks.py
def CheckClientApprovalRequest(approval_request): """Checks if a client approval request is granted.""" _CheckExpired(approval_request) _CheckHasEnoughGrants(approval_request) if not client_approval_auth.CLIENT_APPROVAL_AUTH_MGR.IsActive(): return True token = access_control.ACLToken(username=approval_...
def CheckClientApprovalRequest(approval_request): """Checks if a client approval request is granted.""" _CheckExpired(approval_request) _CheckHasEnoughGrants(approval_request) if not client_approval_auth.CLIENT_APPROVAL_AUTH_MGR.IsActive(): return True token = access_control.ACLToken(username=approval_...
[ "Checks", "if", "a", "client", "approval", "request", "is", "granted", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/approval_checks.py#L64-L84
[ "def", "CheckClientApprovalRequest", "(", "approval_request", ")", ":", "_CheckExpired", "(", "approval_request", ")", "_CheckHasEnoughGrants", "(", "approval_request", ")", "if", "not", "client_approval_auth", ".", "CLIENT_APPROVAL_AUTH_MGR", ".", "IsActive", "(", ")", ...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
CheckApprovalRequest
Checks if an approval request is granted.
grr/server/grr_response_server/gui/approval_checks.py
def CheckApprovalRequest(approval_request): """Checks if an approval request is granted.""" at = rdf_objects.ApprovalRequest.ApprovalType if approval_request.approval_type == at.APPROVAL_TYPE_CLIENT: return CheckClientApprovalRequest(approval_request) elif approval_request.approval_type == at.APPROVAL_TYP...
def CheckApprovalRequest(approval_request): """Checks if an approval request is granted.""" at = rdf_objects.ApprovalRequest.ApprovalType if approval_request.approval_type == at.APPROVAL_TYPE_CLIENT: return CheckClientApprovalRequest(approval_request) elif approval_request.approval_type == at.APPROVAL_TYP...
[ "Checks", "if", "an", "approval", "request", "is", "granted", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/approval_checks.py#L103-L116
[ "def", "CheckApprovalRequest", "(", "approval_request", ")", ":", "at", "=", "rdf_objects", ".", "ApprovalRequest", ".", "ApprovalType", "if", "approval_request", ".", "approval_type", "==", "at", ".", "APPROVAL_TYPE_CLIENT", ":", "return", "CheckClientApprovalRequest",...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74
train
APIAuthorization.ParseYAMLAuthorizationsList
Parses YAML data into a list of APIAuthorization objects.
grr/server/grr_response_server/gui/api_auth_manager.py
def ParseYAMLAuthorizationsList(yaml_data): """Parses YAML data into a list of APIAuthorization objects.""" try: raw_list = yaml.ParseMany(yaml_data) except (ValueError, pyyaml.YAMLError) as e: raise InvalidAPIAuthorization("Invalid YAML: %s" % e) result = [] for auth_src in raw_list: ...
def ParseYAMLAuthorizationsList(yaml_data): """Parses YAML data into a list of APIAuthorization objects.""" try: raw_list = yaml.ParseMany(yaml_data) except (ValueError, pyyaml.YAMLError) as e: raise InvalidAPIAuthorization("Invalid YAML: %s" % e) result = [] for auth_src in raw_list: ...
[ "Parses", "YAML", "data", "into", "a", "list", "of", "APIAuthorization", "objects", "." ]
google/grr
python
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_auth_manager.py#L48-L65
[ "def", "ParseYAMLAuthorizationsList", "(", "yaml_data", ")", ":", "try", ":", "raw_list", "=", "yaml", ".", "ParseMany", "(", "yaml_data", ")", "except", "(", "ValueError", ",", "pyyaml", ".", "YAMLError", ")", "as", "e", ":", "raise", "InvalidAPIAuthorization...
5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74