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 | InMemoryDBClientReportsMixin.ReadAllClientGraphSeries | See db.Database. | grr/server/grr_response_server/databases/mem_client_reports.py | def ReadAllClientGraphSeries(
self,
client_label,
report_type,
time_range = None,
):
"""See db.Database."""
series_with_timestamps = {}
for series_key, series in iteritems(self.client_graph_series):
series_label, series_type, timestamp = series_key
if series_label == cl... | def ReadAllClientGraphSeries(
self,
client_label,
report_type,
time_range = None,
):
"""See db.Database."""
series_with_timestamps = {}
for series_key, series in iteritems(self.client_graph_series):
series_label, series_type, timestamp = series_key
if series_label == cl... | [
"See",
"db",
".",
"Database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_client_reports.py#L40-L54 | [
"def",
"ReadAllClientGraphSeries",
"(",
"self",
",",
"client_label",
",",
"report_type",
",",
"time_range",
"=",
"None",
",",
")",
":",
"series_with_timestamps",
"=",
"{",
"}",
"for",
"series_key",
",",
"series",
"in",
"iteritems",
"(",
"self",
".",
"client_gr... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBClientReportsMixin.ReadMostRecentClientGraphSeries | See db.Database. | grr/server/grr_response_server/databases/mem_client_reports.py | def ReadMostRecentClientGraphSeries(self, client_label,
report_type
):
"""See db.Database."""
series_with_timestamps = self.ReadAllClientGraphSeries(
client_label, report_type)
if not series_with_timestamps:
return None... | def ReadMostRecentClientGraphSeries(self, client_label,
report_type
):
"""See db.Database."""
series_with_timestamps = self.ReadAllClientGraphSeries(
client_label, report_type)
if not series_with_timestamps:
return None... | [
"See",
"db",
".",
"Database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_client_reports.py#L57-L66 | [
"def",
"ReadMostRecentClientGraphSeries",
"(",
"self",
",",
"client_label",
",",
"report_type",
")",
":",
"series_with_timestamps",
"=",
"self",
".",
"ReadAllClientGraphSeries",
"(",
"client_label",
",",
"report_type",
")",
"if",
"not",
"series_with_timestamps",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FakeDataStore.Set | Set the value into the data store. | grr/server/grr_response_server/data_stores/fake_data_store.py | def Set(self,
subject,
attribute,
value,
timestamp=None,
replace=True,
sync=True):
"""Set the value into the data store."""
subject = utils.SmartUnicode(subject)
_ = sync
attribute = utils.SmartUnicode(attribute)
if timestamp is None or t... | def Set(self,
subject,
attribute,
value,
timestamp=None,
replace=True,
sync=True):
"""Set the value into the data store."""
subject = utils.SmartUnicode(subject)
_ = sync
attribute = utils.SmartUnicode(attribute)
if timestamp is None or t... | [
"Set",
"the",
"value",
"into",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/fake_data_store.py#L79-L103 | [
"def",
"Set",
"(",
"self",
",",
"subject",
",",
"attribute",
",",
"value",
",",
"timestamp",
"=",
"None",
",",
"replace",
"=",
"True",
",",
"sync",
"=",
"True",
")",
":",
"subject",
"=",
"utils",
".",
"SmartUnicode",
"(",
"subject",
")",
"_",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FakeDataStore.ResolvePrefix | Resolve all attributes for a subject starting with a prefix. | grr/server/grr_response_server/data_stores/fake_data_store.py | def ResolvePrefix(self, subject, attribute_prefix, timestamp=None,
limit=None):
"""Resolve all attributes for a subject starting with a prefix."""
subject = utils.SmartUnicode(subject)
if timestamp in [None, self.NEWEST_TIMESTAMP, self.ALL_TIMESTAMPS]:
start, end = 0, (2**63) - 1
... | def ResolvePrefix(self, subject, attribute_prefix, timestamp=None,
limit=None):
"""Resolve all attributes for a subject starting with a prefix."""
subject = utils.SmartUnicode(subject)
if timestamp in [None, self.NEWEST_TIMESTAMP, self.ALL_TIMESTAMPS]:
start, end = 0, (2**63) - 1
... | [
"Resolve",
"all",
"attributes",
"for",
"a",
"subject",
"starting",
"with",
"a",
"prefix",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/fake_data_store.py#L296-L358 | [
"def",
"ResolvePrefix",
"(",
"self",
",",
"subject",
",",
"attribute_prefix",
",",
"timestamp",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"subject",
"=",
"utils",
".",
"SmartUnicode",
"(",
"subject",
")",
"if",
"timestamp",
"in",
"[",
"None",
","... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFSServer.Process | Processes a single fleetspeak message. | grr/server/grr_response_server/bin/fleetspeak_frontend.py | def Process(self, fs_msg, context):
"""Processes a single fleetspeak message."""
try:
if fs_msg.message_type == "GrrMessage":
grr_message = rdf_flows.GrrMessage.FromSerializedString(
fs_msg.data.value)
self._ProcessGRRMessages(fs_msg.source.client_id, [grr_message])
elif ... | def Process(self, fs_msg, context):
"""Processes a single fleetspeak message."""
try:
if fs_msg.message_type == "GrrMessage":
grr_message = rdf_flows.GrrMessage.FromSerializedString(
fs_msg.data.value)
self._ProcessGRRMessages(fs_msg.source.client_id, [grr_message])
elif ... | [
"Processes",
"a",
"single",
"fleetspeak",
"message",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fleetspeak_frontend.py#L50-L69 | [
"def",
"Process",
"(",
"self",
",",
"fs_msg",
",",
"context",
")",
":",
"try",
":",
"if",
"fs_msg",
".",
"message_type",
"==",
"\"GrrMessage\"",
":",
"grr_message",
"=",
"rdf_flows",
".",
"GrrMessage",
".",
"FromSerializedString",
"(",
"fs_msg",
".",
"data",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFSServer._ProcessGRRMessages | Handles messages from GRR clients received via Fleetspeak.
This method updates the last-ping timestamp of the client before beginning
processing.
Args:
fs_client_id: The Fleetspeak client-id for the client.
grr_messages: An Iterable of GrrMessages. | grr/server/grr_response_server/bin/fleetspeak_frontend.py | def _ProcessGRRMessages(self, fs_client_id, grr_messages):
"""Handles messages from GRR clients received via Fleetspeak.
This method updates the last-ping timestamp of the client before beginning
processing.
Args:
fs_client_id: The Fleetspeak client-id for the client.
grr_messages: An Iter... | def _ProcessGRRMessages(self, fs_client_id, grr_messages):
"""Handles messages from GRR clients received via Fleetspeak.
This method updates the last-ping timestamp of the client before beginning
processing.
Args:
fs_client_id: The Fleetspeak client-id for the client.
grr_messages: An Iter... | [
"Handles",
"messages",
"from",
"GRR",
"clients",
"received",
"via",
"Fleetspeak",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fleetspeak_frontend.py#L71-L91 | [
"def",
"_ProcessGRRMessages",
"(",
"self",
",",
"fs_client_id",
",",
"grr_messages",
")",
":",
"grr_client_id",
"=",
"fleetspeak_utils",
".",
"FleetspeakIDToGRRID",
"(",
"fs_client_id",
")",
"for",
"grr_message",
"in",
"grr_messages",
":",
"grr_message",
".",
"sourc... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckHost | Perform all checks on a host using acquired artifacts.
Checks are selected based on the artifacts available and the host attributes
(e.g. os_name/cpe/labels) provided as either parameters, or in the
knowledgebase artifact.
A KnowledgeBase artifact should be provided that contains, at a minimum:
- OS
- Hos... | grr/server/grr_response_server/check_lib/checks.py | def CheckHost(host_data,
os_name=None,
cpe=None,
labels=None,
exclude_checks=None,
restrict_checks=None):
"""Perform all checks on a host using acquired artifacts.
Checks are selected based on the artifacts available and the host attributes
(e... | def CheckHost(host_data,
os_name=None,
cpe=None,
labels=None,
exclude_checks=None,
restrict_checks=None):
"""Perform all checks on a host using acquired artifacts.
Checks are selected based on the artifacts available and the host attributes
(e... | [
"Perform",
"all",
"checks",
"on",
"a",
"host",
"using",
"acquired",
"artifacts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L712-L763 | [
"def",
"CheckHost",
"(",
"host_data",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"exclude_checks",
"=",
"None",
",",
"restrict_checks",
"=",
"None",
")",
":",
"# Get knowledgebase, os_name from hostdata",
"kb",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LoadCheckFromFile | Load a single check from a file. | grr/server/grr_response_server/check_lib/checks.py | def LoadCheckFromFile(file_path, check_id, overwrite_if_exists=True):
"""Load a single check from a file."""
configs = LoadConfigsFromFile(file_path)
conf = configs.get(check_id)
check = Check(**conf)
check.Validate()
CheckRegistry.RegisterCheck(
check,
source="file:%s" % file_path,
overwr... | def LoadCheckFromFile(file_path, check_id, overwrite_if_exists=True):
"""Load a single check from a file."""
configs = LoadConfigsFromFile(file_path)
conf = configs.get(check_id)
check = Check(**conf)
check.Validate()
CheckRegistry.RegisterCheck(
check,
source="file:%s" % file_path,
overwr... | [
"Load",
"a",
"single",
"check",
"from",
"a",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L771-L782 | [
"def",
"LoadCheckFromFile",
"(",
"file_path",
",",
"check_id",
",",
"overwrite_if_exists",
"=",
"True",
")",
":",
"configs",
"=",
"LoadConfigsFromFile",
"(",
"file_path",
")",
"conf",
"=",
"configs",
".",
"get",
"(",
"check_id",
")",
"check",
"=",
"Check",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LoadChecksFromFiles | Load the checks defined in the specified files. | grr/server/grr_response_server/check_lib/checks.py | def LoadChecksFromFiles(file_paths, overwrite_if_exists=True):
"""Load the checks defined in the specified files."""
loaded = []
for file_path in file_paths:
configs = LoadConfigsFromFile(file_path)
for conf in itervalues(configs):
check = Check(**conf)
# Validate will raise if the check doesn... | def LoadChecksFromFiles(file_paths, overwrite_if_exists=True):
"""Load the checks defined in the specified files."""
loaded = []
for file_path in file_paths:
configs = LoadConfigsFromFile(file_path)
for conf in itervalues(configs):
check = Check(**conf)
# Validate will raise if the check doesn... | [
"Load",
"the",
"checks",
"defined",
"in",
"the",
"specified",
"files",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L785-L800 | [
"def",
"LoadChecksFromFiles",
"(",
"file_paths",
",",
"overwrite_if_exists",
"=",
"True",
")",
":",
"loaded",
"=",
"[",
"]",
"for",
"file_path",
"in",
"file_paths",
":",
"configs",
"=",
"LoadConfigsFromFile",
"(",
"file_path",
")",
"for",
"conf",
"in",
"iterva... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LoadChecksFromDirs | Load checks from all yaml files in the specified directories. | grr/server/grr_response_server/check_lib/checks.py | def LoadChecksFromDirs(dir_paths, overwrite_if_exists=True):
"""Load checks from all yaml files in the specified directories."""
loaded = []
for dir_path in dir_paths:
cfg_files = glob.glob(os.path.join(dir_path, "*.yaml"))
loaded.extend(LoadChecksFromFiles(cfg_files, overwrite_if_exists))
return loaded | def LoadChecksFromDirs(dir_paths, overwrite_if_exists=True):
"""Load checks from all yaml files in the specified directories."""
loaded = []
for dir_path in dir_paths:
cfg_files = glob.glob(os.path.join(dir_path, "*.yaml"))
loaded.extend(LoadChecksFromFiles(cfg_files, overwrite_if_exists))
return loaded | [
"Load",
"checks",
"from",
"all",
"yaml",
"files",
"in",
"the",
"specified",
"directories",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L803-L809 | [
"def",
"LoadChecksFromDirs",
"(",
"dir_paths",
",",
"overwrite_if_exists",
"=",
"True",
")",
":",
"loaded",
"=",
"[",
"]",
"for",
"dir_path",
"in",
"dir_paths",
":",
"cfg_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dir_pa... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Hint.Render | Processes data according to formatting rules. | grr/server/grr_response_server/check_lib/checks.py | def Render(self, rdf_data):
"""Processes data according to formatting rules."""
report_data = rdf_data[:self.max_results]
results = [self.hinter.Render(rdf) for rdf in report_data]
extra = len(rdf_data) - len(report_data)
if extra > 0:
results.append("...plus another %d issues." % extra)
r... | def Render(self, rdf_data):
"""Processes data according to formatting rules."""
report_data = rdf_data[:self.max_results]
results = [self.hinter.Render(rdf) for rdf in report_data]
extra = len(rdf_data) - len(report_data)
if extra > 0:
results.append("...plus another %d issues." % extra)
r... | [
"Processes",
"data",
"according",
"to",
"formatting",
"rules",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L92-L99 | [
"def",
"Render",
"(",
"self",
",",
"rdf_data",
")",
":",
"report_data",
"=",
"rdf_data",
"[",
":",
"self",
".",
"max_results",
"]",
"results",
"=",
"[",
"self",
".",
"hinter",
".",
"Render",
"(",
"rdf",
")",
"for",
"rdf",
"in",
"report_data",
"]",
"e... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Filter.Parse | Process rdf data through the filter.
Filters sift data according to filter rules. Data that passes the filter
rule is kept, other data is dropped.
If no filter method is provided, the data is returned as a list.
Otherwise, a items that meet filter conditions are returned in a list.
Args:
rd... | grr/server/grr_response_server/check_lib/checks.py | def Parse(self, rdf_data):
"""Process rdf data through the filter.
Filters sift data according to filter rules. Data that passes the filter
rule is kept, other data is dropped.
If no filter method is provided, the data is returned as a list.
Otherwise, a items that meet filter conditions are retur... | def Parse(self, rdf_data):
"""Process rdf data through the filter.
Filters sift data according to filter rules. Data that passes the filter
rule is kept, other data is dropped.
If no filter method is provided, the data is returned as a list.
Otherwise, a items that meet filter conditions are retur... | [
"Process",
"rdf",
"data",
"through",
"the",
"filter",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L138-L155 | [
"def",
"Parse",
"(",
"self",
",",
"rdf_data",
")",
":",
"if",
"self",
".",
"_filter",
":",
"return",
"list",
"(",
"self",
".",
"_filter",
".",
"Parse",
"(",
"rdf_data",
",",
"self",
".",
"expression",
")",
")",
"return",
"rdf_data"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Filter.Validate | The filter exists, and has valid filter and hint expressions. | grr/server/grr_response_server/check_lib/checks.py | def Validate(self):
"""The filter exists, and has valid filter and hint expressions."""
if self.type not in filters.Filter.classes:
raise DefinitionError("Undefined filter type %s" % self.type)
self._filter.Validate(self.expression)
Validate(self.hint, "Filter has invalid hint") | def Validate(self):
"""The filter exists, and has valid filter and hint expressions."""
if self.type not in filters.Filter.classes:
raise DefinitionError("Undefined filter type %s" % self.type)
self._filter.Validate(self.expression)
Validate(self.hint, "Filter has invalid hint") | [
"The",
"filter",
"exists",
"and",
"has",
"valid",
"filter",
"and",
"hint",
"expressions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L157-L162 | [
"def",
"Validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"filters",
".",
"Filter",
".",
"classes",
":",
"raise",
"DefinitionError",
"(",
"\"Undefined filter type %s\"",
"%",
"self",
".",
"type",
")",
"self",
".",
"_filter",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Probe.Parse | Process rdf data through filters. Test if results match expectations.
Processing of rdf data is staged by a filter handler, which manages the
processing of host data. The output of the filters are compared against
expected results.
Args:
rdf_data: An list containing 0 or more rdf values.
Re... | grr/server/grr_response_server/check_lib/checks.py | def Parse(self, rdf_data):
"""Process rdf data through filters. Test if results match expectations.
Processing of rdf data is staged by a filter handler, which manages the
processing of host data. The output of the filters are compared against
expected results.
Args:
rdf_data: An list contai... | def Parse(self, rdf_data):
"""Process rdf data through filters. Test if results match expectations.
Processing of rdf data is staged by a filter handler, which manages the
processing of host data. The output of the filters are compared against
expected results.
Args:
rdf_data: An list contai... | [
"Process",
"rdf",
"data",
"through",
"filters",
".",
"Test",
"if",
"results",
"match",
"expectations",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L192-L217 | [
"def",
"Parse",
"(",
"self",
",",
"rdf_data",
")",
":",
"if",
"not",
"isinstance",
"(",
"rdf_data",
",",
"(",
"list",
",",
"set",
")",
")",
":",
"raise",
"ProcessingError",
"(",
"\"Bad host data format: %s\"",
"%",
"type",
"(",
"rdf_data",
")",
")",
"if"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Probe.Validate | Check the test set is well constructed. | grr/server/grr_response_server/check_lib/checks.py | def Validate(self):
"""Check the test set is well constructed."""
Validate(self.target, "Probe has invalid target")
self.baseliner.Validate()
self.handler.Validate()
self.hint.Validate() | def Validate(self):
"""Check the test set is well constructed."""
Validate(self.target, "Probe has invalid target")
self.baseliner.Validate()
self.handler.Validate()
self.hint.Validate() | [
"Check",
"the",
"test",
"set",
"is",
"well",
"constructed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L219-L224 | [
"def",
"Validate",
"(",
"self",
")",
":",
"Validate",
"(",
"self",
".",
"target",
",",
"\"Probe has invalid target\"",
")",
"self",
".",
"baseliner",
".",
"Validate",
"(",
")",
"self",
".",
"handler",
".",
"Validate",
"(",
")",
"self",
".",
"hint",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Method.Parse | Runs probes that evaluate whether collected data has an issue.
Args:
conditions: The trigger conditions.
host_data: A map of artifacts and rdf data.
Returns:
Anomalies if an issue exists. | grr/server/grr_response_server/check_lib/checks.py | def Parse(self, conditions, host_data):
"""Runs probes that evaluate whether collected data has an issue.
Args:
conditions: The trigger conditions.
host_data: A map of artifacts and rdf data.
Returns:
Anomalies if an issue exists.
"""
processed = []
probes = self.triggers.Cal... | def Parse(self, conditions, host_data):
"""Runs probes that evaluate whether collected data has an issue.
Args:
conditions: The trigger conditions.
host_data: A map of artifacts and rdf data.
Returns:
Anomalies if an issue exists.
"""
processed = []
probes = self.triggers.Cal... | [
"Runs",
"probes",
"that",
"evaluate",
"whether",
"collected",
"data",
"has",
"an",
"issue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L265-L293 | [
"def",
"Parse",
"(",
"self",
",",
"conditions",
",",
"host_data",
")",
":",
"processed",
"=",
"[",
"]",
"probes",
"=",
"self",
".",
"triggers",
".",
"Calls",
"(",
"conditions",
")",
"for",
"p",
"in",
"probes",
":",
"# Get the data required for the probe. A p... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Method.Validate | Check the Method is well constructed. | grr/server/grr_response_server/check_lib/checks.py | def Validate(self):
"""Check the Method is well constructed."""
ValidateMultiple(self.probe, "Method has invalid probes")
Validate(self.target, "Method has invalid target")
Validate(self.hint, "Method has invalid hint") | def Validate(self):
"""Check the Method is well constructed."""
ValidateMultiple(self.probe, "Method has invalid probes")
Validate(self.target, "Method has invalid target")
Validate(self.hint, "Method has invalid hint") | [
"Check",
"the",
"Method",
"is",
"well",
"constructed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L295-L299 | [
"def",
"Validate",
"(",
"self",
")",
":",
"ValidateMultiple",
"(",
"self",
".",
"probe",
",",
"\"Method has invalid probes\"",
")",
"Validate",
"(",
"self",
".",
"target",
",",
"\"Method has invalid target\"",
")",
"Validate",
"(",
"self",
".",
"hint",
",",
"\... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckResult.ExtendAnomalies | Merge anomalies from another CheckResult. | grr/server/grr_response_server/check_lib/checks.py | def ExtendAnomalies(self, other):
"""Merge anomalies from another CheckResult."""
for o in other:
if o is not None:
self.anomaly.Extend(list(o.anomaly)) | def ExtendAnomalies(self, other):
"""Merge anomalies from another CheckResult."""
for o in other:
if o is not None:
self.anomaly.Extend(list(o.anomaly)) | [
"Merge",
"anomalies",
"from",
"another",
"CheckResult",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L312-L316 | [
"def",
"ExtendAnomalies",
"(",
"self",
",",
"other",
")",
":",
"for",
"o",
"in",
"other",
":",
"if",
"o",
"is",
"not",
"None",
":",
"self",
".",
"anomaly",
".",
"Extend",
"(",
"list",
"(",
"o",
".",
"anomaly",
")",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Check.UsesArtifact | Determines if the check uses the specified artifact.
Args:
artifacts: Either a single artifact name, or a list of artifact names
Returns:
True if the check uses a specific artifact. | grr/server/grr_response_server/check_lib/checks.py | def UsesArtifact(self, artifacts):
"""Determines if the check uses the specified artifact.
Args:
artifacts: Either a single artifact name, or a list of artifact names
Returns:
True if the check uses a specific artifact.
"""
# If artifact is a single string, see if it is in the list of ... | def UsesArtifact(self, artifacts):
"""Determines if the check uses the specified artifact.
Args:
artifacts: Either a single artifact name, or a list of artifact names
Returns:
True if the check uses a specific artifact.
"""
# If artifact is a single string, see if it is in the list of ... | [
"Determines",
"if",
"the",
"check",
"uses",
"the",
"specified",
"artifact",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L395-L410 | [
"def",
"UsesArtifact",
"(",
"self",
",",
"artifacts",
")",
":",
"# If artifact is a single string, see if it is in the list of artifacts",
"# as-is. Otherwise, test whether any of the artifacts passed in to this",
"# function exist in the list of artifacts.",
"if",
"isinstance",
"(",
"ar... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Check.Parse | Runs methods that evaluate whether collected host_data has an issue.
Args:
conditions: A list of conditions to determine which Methods to trigger.
host_data: A map of artifacts and rdf data.
Returns:
A CheckResult populated with Anomalies if an issue exists. | grr/server/grr_response_server/check_lib/checks.py | def Parse(self, conditions, host_data):
"""Runs methods that evaluate whether collected host_data has an issue.
Args:
conditions: A list of conditions to determine which Methods to trigger.
host_data: A map of artifacts and rdf data.
Returns:
A CheckResult populated with Anomalies if an ... | def Parse(self, conditions, host_data):
"""Runs methods that evaluate whether collected host_data has an issue.
Args:
conditions: A list of conditions to determine which Methods to trigger.
host_data: A map of artifacts and rdf data.
Returns:
A CheckResult populated with Anomalies if an ... | [
"Runs",
"methods",
"that",
"evaluate",
"whether",
"collected",
"host_data",
"has",
"an",
"issue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L412-L425 | [
"def",
"Parse",
"(",
"self",
",",
"conditions",
",",
"host_data",
")",
":",
"result",
"=",
"CheckResult",
"(",
"check_id",
"=",
"self",
".",
"check_id",
")",
"methods",
"=",
"self",
".",
"SelectChecks",
"(",
"conditions",
")",
"result",
".",
"ExtendAnomali... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Check.Validate | Check the method is well constructed. | grr/server/grr_response_server/check_lib/checks.py | def Validate(self):
"""Check the method is well constructed."""
if not self.check_id:
raise DefinitionError("Check has missing check_id value")
cls_name = self.check_id
if not self.method:
raise DefinitionError("Check %s has no methods" % cls_name)
ValidateMultiple(self.method,
... | def Validate(self):
"""Check the method is well constructed."""
if not self.check_id:
raise DefinitionError("Check has missing check_id value")
cls_name = self.check_id
if not self.method:
raise DefinitionError("Check %s has no methods" % cls_name)
ValidateMultiple(self.method,
... | [
"Check",
"the",
"method",
"is",
"well",
"constructed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L427-L435 | [
"def",
"Validate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"check_id",
":",
"raise",
"DefinitionError",
"(",
"\"Check has missing check_id value\"",
")",
"cls_name",
"=",
"self",
".",
"check_id",
"if",
"not",
"self",
".",
"method",
":",
"raise",
"De... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Matcher.Detect | Run host_data through detectors and return them if a detector triggers.
Args:
baseline: The base set of rdf values used to evaluate whether an issue
exists.
host_data: The rdf values passed back by the filters.
Returns:
A CheckResult message containing anomalies if any detectors iden... | grr/server/grr_response_server/check_lib/checks.py | def Detect(self, baseline, host_data):
"""Run host_data through detectors and return them if a detector triggers.
Args:
baseline: The base set of rdf values used to evaluate whether an issue
exists.
host_data: The rdf values passed back by the filters.
Returns:
A CheckResult mess... | def Detect(self, baseline, host_data):
"""Run host_data through detectors and return them if a detector triggers.
Args:
baseline: The base set of rdf values used to evaluate whether an issue
exists.
host_data: The rdf values passed back by the filters.
Returns:
A CheckResult mess... | [
"Run",
"host_data",
"through",
"detectors",
"and",
"return",
"them",
"if",
"a",
"detector",
"triggers",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L455-L473 | [
"def",
"Detect",
"(",
"self",
",",
"baseline",
",",
"host_data",
")",
":",
"result",
"=",
"CheckResult",
"(",
")",
"for",
"detector",
"in",
"self",
".",
"detectors",
":",
"finding",
"=",
"detector",
"(",
"baseline",
",",
"host_data",
")",
"if",
"finding"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Matcher.Issue | Collect anomalous findings into a CheckResult.
Comparisons with anomalous conditions collect anomalies into a single
CheckResult message. The contents of the result varies depending on whether
the method making the comparison is a Check, Method or Probe.
- Probes evaluate raw host data and generate Ano... | grr/server/grr_response_server/check_lib/checks.py | def Issue(self, state, results):
"""Collect anomalous findings into a CheckResult.
Comparisons with anomalous conditions collect anomalies into a single
CheckResult message. The contents of the result varies depending on whether
the method making the comparison is a Check, Method or Probe.
- Probes... | def Issue(self, state, results):
"""Collect anomalous findings into a CheckResult.
Comparisons with anomalous conditions collect anomalies into a single
CheckResult message. The contents of the result varies depending on whether
the method making the comparison is a Check, Method or Probe.
- Probes... | [
"Collect",
"anomalous",
"findings",
"into",
"a",
"CheckResult",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L475-L511 | [
"def",
"Issue",
"(",
"self",
",",
"state",
",",
"results",
")",
":",
"result",
"=",
"CheckResult",
"(",
")",
"# If there are CheckResults we're aggregating methods or probes.",
"# Merge all current results into one CheckResult.",
"# Otherwise, the results are raw host data.",
"# ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Matcher.GotAll | Anomaly if baseline vs result counts differ, an empty list otherwise. | grr/server/grr_response_server/check_lib/checks.py | def GotAll(self, baseline, results):
"""Anomaly if baseline vs result counts differ, an empty list otherwise."""
num_base = len(baseline)
num_rslt = len(results)
if num_rslt > num_base:
raise ProcessingError("Filter generated more results than base data: "
"%s > %s" % (... | def GotAll(self, baseline, results):
"""Anomaly if baseline vs result counts differ, an empty list otherwise."""
num_base = len(baseline)
num_rslt = len(results)
if num_rslt > num_base:
raise ProcessingError("Filter generated more results than base data: "
"%s > %s" % (... | [
"Anomaly",
"if",
"baseline",
"vs",
"result",
"counts",
"differ",
"an",
"empty",
"list",
"otherwise",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L537-L546 | [
"def",
"GotAll",
"(",
"self",
",",
"baseline",
",",
"results",
")",
":",
"num_base",
"=",
"len",
"(",
"baseline",
")",
"num_rslt",
"=",
"len",
"(",
"results",
")",
"if",
"num_rslt",
">",
"num_base",
":",
"raise",
"ProcessingError",
"(",
"\"Filter generated... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry.RegisterCheck | Adds a check to the registry, refresh the trigger to check map. | grr/server/grr_response_server/check_lib/checks.py | def RegisterCheck(cls, check, source="unknown", overwrite_if_exists=False):
"""Adds a check to the registry, refresh the trigger to check map."""
if not overwrite_if_exists and check.check_id in cls.checks:
raise DefinitionError(
"Check named %s already exists and "
"overwrite_if_exist... | def RegisterCheck(cls, check, source="unknown", overwrite_if_exists=False):
"""Adds a check to the registry, refresh the trigger to check map."""
if not overwrite_if_exists and check.check_id in cls.checks:
raise DefinitionError(
"Check named %s already exists and "
"overwrite_if_exist... | [
"Adds",
"a",
"check",
"to",
"the",
"registry",
"refresh",
"the",
"trigger",
"to",
"check",
"map",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L567-L575 | [
"def",
"RegisterCheck",
"(",
"cls",
",",
"check",
",",
"source",
"=",
"\"unknown\"",
",",
"overwrite_if_exists",
"=",
"False",
")",
":",
"if",
"not",
"overwrite_if_exists",
"and",
"check",
".",
"check_id",
"in",
"cls",
".",
"checks",
":",
"raise",
"Definitio... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry._AsList | Encapsulates an argument in a list, if it's not already iterable. | grr/server/grr_response_server/check_lib/checks.py | def _AsList(arg):
"""Encapsulates an argument in a list, if it's not already iterable."""
if (isinstance(arg, string_types) or
not isinstance(arg, collections.Iterable)):
return [arg]
else:
return list(arg) | def _AsList(arg):
"""Encapsulates an argument in a list, if it's not already iterable."""
if (isinstance(arg, string_types) or
not isinstance(arg, collections.Iterable)):
return [arg]
else:
return list(arg) | [
"Encapsulates",
"an",
"argument",
"in",
"a",
"list",
"if",
"it",
"s",
"not",
"already",
"iterable",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L578-L584 | [
"def",
"_AsList",
"(",
"arg",
")",
":",
"if",
"(",
"isinstance",
"(",
"arg",
",",
"string_types",
")",
"or",
"not",
"isinstance",
"(",
"arg",
",",
"collections",
".",
"Iterable",
")",
")",
":",
"return",
"[",
"arg",
"]",
"else",
":",
"return",
"list"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry.Conditions | Provide a series of condition tuples.
A Target can specify multiple artifact, os_name, cpe or label entries. These
are expanded to all distinct tuples. When an entry is undefined or None, it
is treated as a single definition of None, meaning that the condition does
not apply.
Args:
artifact:... | grr/server/grr_response_server/check_lib/checks.py | def Conditions(cls, artifact=None, os_name=None, cpe=None, labels=None):
"""Provide a series of condition tuples.
A Target can specify multiple artifact, os_name, cpe or label entries. These
are expanded to all distinct tuples. When an entry is undefined or None, it
is treated as a single definition of... | def Conditions(cls, artifact=None, os_name=None, cpe=None, labels=None):
"""Provide a series of condition tuples.
A Target can specify multiple artifact, os_name, cpe or label entries. These
are expanded to all distinct tuples. When an entry is undefined or None, it
is treated as a single definition of... | [
"Provide",
"a",
"series",
"of",
"condition",
"tuples",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L587-L609 | [
"def",
"Conditions",
"(",
"cls",
",",
"artifact",
"=",
"None",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"labels",
"=",
"None",
")",
":",
"artifact",
"=",
"cls",
".",
"_AsList",
"(",
"artifact",
")",
"os_name",
"=",
"cls",
".",
"_A... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry.FindChecks | Takes targeting info, identifies relevant checks.
FindChecks will return results when a host has the conditions necessary for
a check to occur. Conditions with partial results are not returned. For
example, FindChecks will not return checks that if a check targets
os_name=["Linux"], labels=["foo"] and ... | grr/server/grr_response_server/check_lib/checks.py | def FindChecks(cls,
artifact=None,
os_name=None,
cpe=None,
labels=None,
restrict_checks=None):
"""Takes targeting info, identifies relevant checks.
FindChecks will return results when a host has the conditions necessary for
... | def FindChecks(cls,
artifact=None,
os_name=None,
cpe=None,
labels=None,
restrict_checks=None):
"""Takes targeting info, identifies relevant checks.
FindChecks will return results when a host has the conditions necessary for
... | [
"Takes",
"targeting",
"info",
"identifies",
"relevant",
"checks",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L612-L645 | [
"def",
"FindChecks",
"(",
"cls",
",",
"artifact",
"=",
"None",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"restrict_checks",
"=",
"None",
")",
":",
"check_ids",
"=",
"set",
"(",
")",
"conditions",
"=",
"lis... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry.SelectArtifacts | Takes targeting info, identifies artifacts to fetch.
Args:
os_name: 0+ OS names.
cpe: 0+ CPE identifiers.
labels: 0+ GRR labels.
restrict_checks: A list of check ids whose artifacts should be fetched.
Returns:
the artifacts that should be collected. | grr/server/grr_response_server/check_lib/checks.py | def SelectArtifacts(cls,
os_name=None,
cpe=None,
labels=None,
restrict_checks=None):
"""Takes targeting info, identifies artifacts to fetch.
Args:
os_name: 0+ OS names.
cpe: 0+ CPE identifiers.
labels: 0+ ... | def SelectArtifacts(cls,
os_name=None,
cpe=None,
labels=None,
restrict_checks=None):
"""Takes targeting info, identifies artifacts to fetch.
Args:
os_name: 0+ OS names.
cpe: 0+ CPE identifiers.
labels: 0+ ... | [
"Takes",
"targeting",
"info",
"identifies",
"artifacts",
"to",
"fetch",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L648-L671 | [
"def",
"SelectArtifacts",
"(",
"cls",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"restrict_checks",
"=",
"None",
")",
":",
"results",
"=",
"set",
"(",
")",
"for",
"condition",
"in",
"cls",
".",
"Conditions",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CheckRegistry.Process | Runs checks over all host data.
Args:
host_data: The data collected from a host, mapped to artifact name.
os_name: 0+ OS names.
cpe: 0+ CPE identifiers.
labels: 0+ GRR labels.
exclude_checks: A list of check ids not to run. A check id in this list
will not get ru... | grr/server/grr_response_server/check_lib/checks.py | def Process(cls,
host_data,
os_name=None,
cpe=None,
labels=None,
exclude_checks=None,
restrict_checks=None):
"""Runs checks over all host data.
Args:
host_data: The data collected from a host, mapped to artifact name.
... | def Process(cls,
host_data,
os_name=None,
cpe=None,
labels=None,
exclude_checks=None,
restrict_checks=None):
"""Runs checks over all host data.
Args:
host_data: The data collected from a host, mapped to artifact name.
... | [
"Runs",
"checks",
"over",
"all",
"host",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L674-L709 | [
"def",
"Process",
"(",
"cls",
",",
"host_data",
",",
"os_name",
"=",
"None",
",",
"cpe",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"exclude_checks",
"=",
"None",
",",
"restrict_checks",
"=",
"None",
")",
":",
"# All the conditions that apply to this host."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UInt32 | Returns a pseudo-random 32-bit unsigned integer. | grr/core/grr_response_core/lib/util/random.py | def UInt32():
"""Returns a pseudo-random 32-bit unsigned integer."""
with _mutex:
try:
return _random_buffer.pop()
except IndexError:
data = os.urandom(struct.calcsize("=L") * _random_buffer_size)
_random_buffer.extend(
struct.unpack("=" + "L" * _random_buffer_size, data))
... | def UInt32():
"""Returns a pseudo-random 32-bit unsigned integer."""
with _mutex:
try:
return _random_buffer.pop()
except IndexError:
data = os.urandom(struct.calcsize("=L") * _random_buffer_size)
_random_buffer.extend(
struct.unpack("=" + "L" * _random_buffer_size, data))
... | [
"Returns",
"a",
"pseudo",
"-",
"random",
"32",
"-",
"bit",
"unsigned",
"integer",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/random.py#L29-L38 | [
"def",
"UInt32",
"(",
")",
":",
"with",
"_mutex",
":",
"try",
":",
"return",
"_random_buffer",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"data",
"=",
"os",
".",
"urandom",
"(",
"struct",
".",
"calcsize",
"(",
"\"=L\"",
")",
"*",
"_random_buffe... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder.SetupVars | Set up some vars for the directories we use. | appveyor/windows_templates/build_windows_templates.py | def SetupVars(self):
"""Set up some vars for the directories we use."""
# Python paths chosen to match appveyor:
# http://www.appveyor.com/docs/installed-software#python
self.python_dir_64 = args.python64_dir
self.python_dir_32 = args.python32_dir
self.virtualenv_bin64 = os.path.join(self.pyth... | def SetupVars(self):
"""Set up some vars for the directories we use."""
# Python paths chosen to match appveyor:
# http://www.appveyor.com/docs/installed-software#python
self.python_dir_64 = args.python64_dir
self.python_dir_32 = args.python32_dir
self.virtualenv_bin64 = os.path.join(self.pyth... | [
"Set",
"up",
"some",
"vars",
"for",
"the",
"directories",
"we",
"use",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L100-L139 | [
"def",
"SetupVars",
"(",
"self",
")",
":",
"# Python paths chosen to match appveyor:",
"# http://www.appveyor.com/docs/installed-software#python",
"self",
".",
"python_dir_64",
"=",
"args",
".",
"python64_dir",
"self",
".",
"python_dir_32",
"=",
"args",
".",
"python32_dir",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder.Clean | Clean the build environment. | appveyor/windows_templates/build_windows_templates.py | def Clean(self):
"""Clean the build environment."""
# os.unlink doesn't work effectively, use the shell to delete.
if os.path.exists(args.build_dir):
subprocess.call("rd /s /q %s" % args.build_dir, shell=True)
if os.path.exists(args.output_dir):
subprocess.call("rd /s /q %s" % args.output_di... | def Clean(self):
"""Clean the build environment."""
# os.unlink doesn't work effectively, use the shell to delete.
if os.path.exists(args.build_dir):
subprocess.call("rd /s /q %s" % args.build_dir, shell=True)
if os.path.exists(args.output_dir):
subprocess.call("rd /s /q %s" % args.output_di... | [
"Clean",
"the",
"build",
"environment",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L141-L172 | [
"def",
"Clean",
"(",
"self",
")",
":",
"# os.unlink doesn't work effectively, use the shell to delete.",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"args",
".",
"build_dir",
")",
":",
"subprocess",
".",
"call",
"(",
"\"rd /s /q %s\"",
"%",
"args",
".",
"build_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder.InstallGRR | Installs GRR. | appveyor/windows_templates/build_windows_templates.py | def InstallGRR(self, path):
"""Installs GRR."""
cmd64 = [self.pip64, "install"]
cmd32 = [self.pip32, "install"]
if args.wheel_dir:
cmd64 += ["--no-index", r"--find-links=file:///%s" % args.wheel_dir]
cmd32 += ["--no-index", r"--find-links=file:///%s" % args.wheel_dir]
cmd64.append(pat... | def InstallGRR(self, path):
"""Installs GRR."""
cmd64 = [self.pip64, "install"]
cmd32 = [self.pip32, "install"]
if args.wheel_dir:
cmd64 += ["--no-index", r"--find-links=file:///%s" % args.wheel_dir]
cmd32 += ["--no-index", r"--find-links=file:///%s" % args.wheel_dir]
cmd64.append(pat... | [
"Installs",
"GRR",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L216-L231 | [
"def",
"InstallGRR",
"(",
"self",
",",
"path",
")",
":",
"cmd64",
"=",
"[",
"self",
".",
"pip64",
",",
"\"install\"",
"]",
"cmd32",
"=",
"[",
"self",
".",
"pip32",
",",
"\"install\"",
"]",
"if",
"args",
".",
"wheel_dir",
":",
"cmd64",
"+=",
"[",
"\... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder.BuildTemplates | Builds the client templates.
We dont need to run special compilers so just enter the virtualenv and
build. Python will already find its own MSVC for python compilers. | appveyor/windows_templates/build_windows_templates.py | def BuildTemplates(self):
"""Builds the client templates.
We dont need to run special compilers so just enter the virtualenv and
build. Python will already find its own MSVC for python compilers.
"""
if args.config:
build_args = [
"--verbose", "--config", args.config, "build", "--ou... | def BuildTemplates(self):
"""Builds the client templates.
We dont need to run special compilers so just enter the virtualenv and
build. Python will already find its own MSVC for python compilers.
"""
if args.config:
build_args = [
"--verbose", "--config", args.config, "build", "--ou... | [
"Builds",
"the",
"client",
"templates",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L233-L248 | [
"def",
"BuildTemplates",
"(",
"self",
")",
":",
"if",
"args",
".",
"config",
":",
"build_args",
"=",
"[",
"\"--verbose\"",
",",
"\"--config\"",
",",
"args",
".",
"config",
",",
"\"build\"",
",",
"\"--output\"",
",",
"args",
".",
"output_dir",
"]",
"else",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder._RepackTemplates | Repack templates with a dummy config. | appveyor/windows_templates/build_windows_templates.py | def _RepackTemplates(self):
"""Repack templates with a dummy config."""
dummy_config = os.path.join(
args.grr_src, "grr/test/grr_response_test/test_data/dummyconfig.yaml")
if args.build_32:
template_i386 = glob.glob(os.path.join(args.output_dir,
"*_... | def _RepackTemplates(self):
"""Repack templates with a dummy config."""
dummy_config = os.path.join(
args.grr_src, "grr/test/grr_response_test/test_data/dummyconfig.yaml")
if args.build_32:
template_i386 = glob.glob(os.path.join(args.output_dir,
"*_... | [
"Repack",
"templates",
"with",
"a",
"dummy",
"config",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L250-L282 | [
"def",
"_RepackTemplates",
"(",
"self",
")",
":",
"dummy_config",
"=",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"grr_src",
",",
"\"grr/test/grr_response_test/test_data/dummyconfig.yaml\"",
")",
"if",
"args",
".",
"build_32",
":",
"template_i386",
"=",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder._CleanupInstall | Cleanup from any previous installer enough for _CheckInstallSuccess. | appveyor/windows_templates/build_windows_templates.py | def _CleanupInstall(self):
"""Cleanup from any previous installer enough for _CheckInstallSuccess."""
if os.path.exists(self.install_path):
shutil.rmtree(self.install_path)
if os.path.exists(self.install_path):
raise RuntimeError("Install path still exists: %s" % self.install_path)
# De... | def _CleanupInstall(self):
"""Cleanup from any previous installer enough for _CheckInstallSuccess."""
if os.path.exists(self.install_path):
shutil.rmtree(self.install_path)
if os.path.exists(self.install_path):
raise RuntimeError("Install path still exists: %s" % self.install_path)
# De... | [
"Cleanup",
"from",
"any",
"previous",
"installer",
"enough",
"for",
"_CheckInstallSuccess",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L284-L292 | [
"def",
"_CleanupInstall",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"install_path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"install_path",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder._CheckInstallSuccess | Checks if the installer installed correctly. | appveyor/windows_templates/build_windows_templates.py | def _CheckInstallSuccess(self):
"""Checks if the installer installed correctly."""
if not os.path.exists(self.install_path):
raise RuntimeError("Install failed, no files at: %s" % self.install_path)
try:
output = subprocess.check_output(["sc", "query", self.service_name])
service_running ... | def _CheckInstallSuccess(self):
"""Checks if the installer installed correctly."""
if not os.path.exists(self.install_path):
raise RuntimeError("Install failed, no files at: %s" % self.install_path)
try:
output = subprocess.check_output(["sc", "query", self.service_name])
service_running ... | [
"Checks",
"if",
"the",
"installer",
"installed",
"correctly",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L294-L319 | [
"def",
"_CheckInstallSuccess",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"install_path",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Install failed, no files at: %s\"",
"%",
"self",
".",
"install_path",
")",
"try",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder._InstallInstallers | Install the installer built by RepackTemplates. | appveyor/windows_templates/build_windows_templates.py | def _InstallInstallers(self):
"""Install the installer built by RepackTemplates."""
# 32 bit binary will refuse to install on a 64bit system so we only install
# the 64 bit version
installer_amd64 = glob.glob(
os.path.join(args.output_dir, "dbg_*_amd64.exe")).pop()
self._CleanupInstall()
... | def _InstallInstallers(self):
"""Install the installer built by RepackTemplates."""
# 32 bit binary will refuse to install on a 64bit system so we only install
# the 64 bit version
installer_amd64 = glob.glob(
os.path.join(args.output_dir, "dbg_*_amd64.exe")).pop()
self._CleanupInstall()
... | [
"Install",
"the",
"installer",
"built",
"by",
"RepackTemplates",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L321-L330 | [
"def",
"_InstallInstallers",
"(",
"self",
")",
":",
"# 32 bit binary will refuse to install on a 64bit system so we only install",
"# the 64 bit version",
"installer_amd64",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
".",
"output_dir",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | WindowsTemplateBuilder.Build | Build templates. | appveyor/windows_templates/build_windows_templates.py | def Build(self):
"""Build templates."""
self.SetupVars()
self.Clean()
if not os.path.exists(args.grr_src):
self.GitCheckoutGRR()
proto_sdist = self.MakeProtoSdist()
core_sdist = self.MakeCoreSdist()
client_sdist = self.MakeClientSdist()
client_builder_sdist = self.MakeClientBuilde... | def Build(self):
"""Build templates."""
self.SetupVars()
self.Clean()
if not os.path.exists(args.grr_src):
self.GitCheckoutGRR()
proto_sdist = self.MakeProtoSdist()
core_sdist = self.MakeCoreSdist()
client_sdist = self.MakeClientSdist()
client_builder_sdist = self.MakeClientBuilde... | [
"Build",
"templates",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L332-L351 | [
"def",
"Build",
"(",
"self",
")",
":",
"self",
".",
"SetupVars",
"(",
")",
"self",
".",
"Clean",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"args",
".",
"grr_src",
")",
":",
"self",
".",
"GitCheckoutGRR",
"(",
")",
"proto_sdist",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AssertType | Ensures that given value has certain type.
Args:
value: A value to assert the type for.
expected_type: An expected type for the given value.
Raises:
TypeError: If given value does not have the expected type. | grr/core/grr_response_core/lib/util/precondition.py | def AssertType(value, expected_type):
"""Ensures that given value has certain type.
Args:
value: A value to assert the type for.
expected_type: An expected type for the given value.
Raises:
TypeError: If given value does not have the expected type.
"""
if not isinstance(value, expected_type):
... | def AssertType(value, expected_type):
"""Ensures that given value has certain type.
Args:
value: A value to assert the type for.
expected_type: An expected type for the given value.
Raises:
TypeError: If given value does not have the expected type.
"""
if not isinstance(value, expected_type):
... | [
"Ensures",
"that",
"given",
"value",
"has",
"certain",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/precondition.py#L12-L25 | [
"def",
"AssertType",
"(",
"value",
",",
"expected_type",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"expected_type",
")",
":",
"message",
"=",
"\"Expected type `%r`, but got value `%r` of type `%s`\"",
"message",
"%=",
"(",
"expected_type",
",",
"value"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AssertIterableType | Ensures that given iterable container has certain type.
Args:
iterable: An iterable container to assert the type for.
expected_item_type: An expected type of the container items.
Raises:
TypeError: If given container does is not an iterable or its items do not
have the expected type. | grr/core/grr_response_core/lib/util/precondition.py | def AssertIterableType(iterable, expected_item_type):
"""Ensures that given iterable container has certain type.
Args:
iterable: An iterable container to assert the type for.
expected_item_type: An expected type of the container items.
Raises:
TypeError: If given container does is not an iterable or... | def AssertIterableType(iterable, expected_item_type):
"""Ensures that given iterable container has certain type.
Args:
iterable: An iterable container to assert the type for.
expected_item_type: An expected type of the container items.
Raises:
TypeError: If given container does is not an iterable or... | [
"Ensures",
"that",
"given",
"iterable",
"container",
"has",
"certain",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/precondition.py#L42-L66 | [
"def",
"AssertIterableType",
"(",
"iterable",
",",
"expected_item_type",
")",
":",
"# We do not consider iterators to be iterables even though Python does. An",
"# \"iterable\" should be a type that can be iterated (that is: an iterator can",
"# be constructed for them). Iterators should not be ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | AssertDictType | Ensures that given dictionary is actually a dictionary of specified type.
Args:
dct: A dictionary to assert the type for.
expected_key_type: An expected type for dictionary keys.
expected_value_type: An expected type for dictionary values.
Raises:
TypeError: If given dictionary is not really a dic... | grr/core/grr_response_core/lib/util/precondition.py | def AssertDictType(dct, expected_key_type, expected_value_type):
"""Ensures that given dictionary is actually a dictionary of specified type.
Args:
dct: A dictionary to assert the type for.
expected_key_type: An expected type for dictionary keys.
expected_value_type: An expected type for dictionary val... | def AssertDictType(dct, expected_key_type, expected_value_type):
"""Ensures that given dictionary is actually a dictionary of specified type.
Args:
dct: A dictionary to assert the type for.
expected_key_type: An expected type for dictionary keys.
expected_value_type: An expected type for dictionary val... | [
"Ensures",
"that",
"given",
"dictionary",
"is",
"actually",
"a",
"dictionary",
"of",
"specified",
"type",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/precondition.py#L69-L84 | [
"def",
"AssertDictType",
"(",
"dct",
",",
"expected_key_type",
",",
"expected_value_type",
")",
":",
"AssertType",
"(",
"dct",
",",
"dict",
")",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"dct",
")",
":",
"AssertType",
"(",
"key",
",",
"expected_k... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HookRegistry._RunSingleHook | Run the single hook specified by resolving all its prerequisites. | grr/core/grr_response_core/lib/registry.py | def _RunSingleHook(self, hook_cls, executed_set, required=None):
"""Run the single hook specified by resolving all its prerequisites."""
# If we already ran do nothing.
if hook_cls in executed_set:
return
# Ensure all the pre execution hooks are run.
for pre_hook in hook_cls.pre:
self._... | def _RunSingleHook(self, hook_cls, executed_set, required=None):
"""Run the single hook specified by resolving all its prerequisites."""
# If we already ran do nothing.
if hook_cls in executed_set:
return
# Ensure all the pre execution hooks are run.
for pre_hook in hook_cls.pre:
self._... | [
"Run",
"the",
"single",
"hook",
"specified",
"by",
"resolving",
"all",
"its",
"prerequisites",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/registry.py#L225-L250 | [
"def",
"_RunSingleHook",
"(",
"self",
",",
"hook_cls",
",",
"executed_set",
",",
"required",
"=",
"None",
")",
":",
"# If we already ran do nothing.",
"if",
"hook_cls",
"in",
"executed_set",
":",
"return",
"# Ensure all the pre execution hooks are run.",
"for",
"pre_hoo... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiHunt.InitFromHuntObject | Initialize API hunt object from a database hunt object.
Args:
hunt_obj: rdf_hunt_objects.Hunt to read the data from.
hunt_counters: Optional db.HuntCounters object with counters information.
with_full_summary: if True, hunt_runner_args, completion counts and a few
other fields will be fil... | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromHuntObject(self,
hunt_obj,
hunt_counters=None,
with_full_summary=False):
"""Initialize API hunt object from a database hunt object.
Args:
hunt_obj: rdf_hunt_objects.Hunt to read the data from.
hunt_counters: Opti... | def InitFromHuntObject(self,
hunt_obj,
hunt_counters=None,
with_full_summary=False):
"""Initialize API hunt object from a database hunt object.
Args:
hunt_obj: rdf_hunt_objects.Hunt to read the data from.
hunt_counters: Opti... | [
"Initialize",
"API",
"hunt",
"object",
"from",
"a",
"database",
"hunt",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L222-L331 | [
"def",
"InitFromHuntObject",
"(",
"self",
",",
"hunt_obj",
",",
"hunt_counters",
"=",
"None",
",",
"with_full_summary",
"=",
"False",
")",
":",
"self",
".",
"urn",
"=",
"rdfvalue",
".",
"RDFURN",
"(",
"\"hunts\"",
")",
".",
"Add",
"(",
"str",
"(",
"hunt_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiHuntResult.InitFromGrrMessage | Init from GrrMessage rdfvalue. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromGrrMessage(self, message):
"""Init from GrrMessage rdfvalue."""
if message.source:
self.client_id = message.source.Basename()
self.payload_type = compatibility.GetName(message.payload.__class__)
self.payload = message.payload
self.timestamp = message.age
return self | def InitFromGrrMessage(self, message):
"""Init from GrrMessage rdfvalue."""
if message.source:
self.client_id = message.source.Basename()
self.payload_type = compatibility.GetName(message.payload.__class__)
self.payload = message.payload
self.timestamp = message.age
return self | [
"Init",
"from",
"GrrMessage",
"rdfvalue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L351-L360 | [
"def",
"InitFromGrrMessage",
"(",
"self",
",",
"message",
")",
":",
"if",
"message",
".",
"source",
":",
"self",
".",
"client_id",
"=",
"message",
".",
"source",
".",
"Basename",
"(",
")",
"self",
".",
"payload_type",
"=",
"compatibility",
".",
"GetName",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiHuntResult.InitFromFlowResult | Init from rdf_flow_objects.FlowResult. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromFlowResult(self, flow_result):
"""Init from rdf_flow_objects.FlowResult."""
self.payload_type = compatibility.GetName(flow_result.payload.__class__)
self.payload = flow_result.payload
self.client_id = flow_result.client_id
self.timestamp = flow_result.timestamp
return self | def InitFromFlowResult(self, flow_result):
"""Init from rdf_flow_objects.FlowResult."""
self.payload_type = compatibility.GetName(flow_result.payload.__class__)
self.payload = flow_result.payload
self.client_id = flow_result.client_id
self.timestamp = flow_result.timestamp
return self | [
"Init",
"from",
"rdf_flow_objects",
".",
"FlowResult",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L362-L370 | [
"def",
"InitFromFlowResult",
"(",
"self",
",",
"flow_result",
")",
":",
"self",
".",
"payload_type",
"=",
"compatibility",
".",
"GetName",
"(",
"flow_result",
".",
"payload",
".",
"__class__",
")",
"self",
".",
"payload",
"=",
"flow_result",
".",
"payload",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiHuntLog.InitFromFlowLogEntry | Init from FlowLogEntry rdfvalue. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromFlowLogEntry(self, fle):
"""Init from FlowLogEntry rdfvalue."""
# TODO(user): putting this stub value for backwards compatibility.
# Remove as soon as AFF4 is gone.
self.flow_name = "GenericHunt"
self.client_id = fle.client_id
self.flow_id = fle.flow_id
self.timestamp = fle.tim... | def InitFromFlowLogEntry(self, fle):
"""Init from FlowLogEntry rdfvalue."""
# TODO(user): putting this stub value for backwards compatibility.
# Remove as soon as AFF4 is gone.
self.flow_name = "GenericHunt"
self.client_id = fle.client_id
self.flow_id = fle.flow_id
self.timestamp = fle.tim... | [
"Init",
"from",
"FlowLogEntry",
"rdfvalue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L401-L413 | [
"def",
"InitFromFlowLogEntry",
"(",
"self",
",",
"fle",
")",
":",
"# TODO(user): putting this stub value for backwards compatibility.",
"# Remove as soon as AFF4 is gone.",
"self",
".",
"flow_name",
"=",
"\"GenericHunt\"",
"self",
".",
"client_id",
"=",
"fle",
".",
"client_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiHuntError.InitFromFlowObject | Initialize from rdf_flow_objects.Flow corresponding to a failed flow. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromFlowObject(self, fo):
"""Initialize from rdf_flow_objects.Flow corresponding to a failed flow."""
self.client_id = fo.client_id
if fo.HasField("backtrace"):
self.backtrace = fo.backtrace
self.log_message = fo.error_message
self.timestamp = fo.last_update_time
return self | def InitFromFlowObject(self, fo):
"""Initialize from rdf_flow_objects.Flow corresponding to a failed flow."""
self.client_id = fo.client_id
if fo.HasField("backtrace"):
self.backtrace = fo.backtrace
self.log_message = fo.error_message
self.timestamp = fo.last_update_time
return self | [
"Initialize",
"from",
"rdf_flow_objects",
".",
"Flow",
"corresponding",
"to",
"a",
"failed",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L435-L444 | [
"def",
"InitFromFlowObject",
"(",
"self",
",",
"fo",
")",
":",
"self",
".",
"client_id",
"=",
"fo",
".",
"client_id",
"if",
"fo",
".",
"HasField",
"(",
"\"backtrace\"",
")",
":",
"self",
".",
"backtrace",
"=",
"fo",
".",
"backtrace",
"self",
".",
"log_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiGetHuntClientCompletionStatsResult.InitFromDataPoints | Check that this approval applies to the given token.
Args:
start_stats: A list of lists, each containing two values (a timestamp and
the number of clients started at this time).
complete_stats: A list of lists, each containing two values (a timestamp
and the number of clients completed ... | grr/server/grr_response_server/gui/api_plugins/hunt.py | def InitFromDataPoints(self, start_stats, complete_stats):
"""Check that this approval applies to the given token.
Args:
start_stats: A list of lists, each containing two values (a timestamp and
the number of clients started at this time).
complete_stats: A list of lists, each containing tw... | def InitFromDataPoints(self, start_stats, complete_stats):
"""Check that this approval applies to the given token.
Args:
start_stats: A list of lists, each containing two values (a timestamp and
the number of clients started at this time).
complete_stats: A list of lists, each containing tw... | [
"Check",
"that",
"this",
"approval",
"applies",
"to",
"the",
"given",
"token",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1184-L1198 | [
"def",
"InitFromDataPoints",
"(",
"self",
",",
"start_stats",
",",
"complete_stats",
")",
":",
"self",
".",
"start_points",
"=",
"self",
".",
"_ConvertToResultList",
"(",
"start_stats",
")",
"self",
".",
"complete_points",
"=",
"self",
".",
"_ConvertToResultList",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiGetHuntClientCompletionStatsHandler._Resample | Resamples the stats to have a specific number of data points. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def _Resample(self, stats, target_size):
"""Resamples the stats to have a specific number of data points."""
t_first = stats[0][0]
t_last = stats[-1][0]
interval = (t_last - t_first) / target_size
result = []
current_t = t_first
current_v = 0
i = 0
while i < len(stats):
stat_... | def _Resample(self, stats, target_size):
"""Resamples the stats to have a specific number of data points."""
t_first = stats[0][0]
t_last = stats[-1][0]
interval = (t_last - t_first) / target_size
result = []
current_t = t_first
current_v = 0
i = 0
while i < len(stats):
stat_... | [
"Resamples",
"the",
"stats",
"to",
"have",
"a",
"specific",
"number",
"of",
"data",
"points",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1320-L1343 | [
"def",
"_Resample",
"(",
"self",
",",
"stats",
",",
"target_size",
")",
":",
"t_first",
"=",
"stats",
"[",
"0",
"]",
"[",
"0",
"]",
"t_last",
"=",
"stats",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
"interval",
"=",
"(",
"t_last",
"-",
"t_first",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiGetHuntStatsHandler._HandleLegacy | Retrieves the stats for a hunt. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def _HandleLegacy(self, args, token=None):
"""Retrieves the stats for a hunt."""
hunt_obj = aff4.FACTORY.Open(
args.hunt_id.ToURN(), aff4_type=implementation.GRRHunt, token=token)
stats = hunt_obj.GetRunner().context.usage_stats
return ApiGetHuntStatsResult(stats=stats) | def _HandleLegacy(self, args, token=None):
"""Retrieves the stats for a hunt."""
hunt_obj = aff4.FACTORY.Open(
args.hunt_id.ToURN(), aff4_type=implementation.GRRHunt, token=token)
stats = hunt_obj.GetRunner().context.usage_stats
return ApiGetHuntStatsResult(stats=stats) | [
"Retrieves",
"the",
"stats",
"for",
"a",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1628-L1635 | [
"def",
"_HandleLegacy",
"(",
"self",
",",
"args",
",",
"token",
"=",
"None",
")",
":",
"hunt_obj",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"args",
".",
"hunt_id",
".",
"ToURN",
"(",
")",
",",
"aff4_type",
"=",
"implementation",
".",
"GRRHunt",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiListHuntClientsHandler._HandleLegacy | Retrieves the clients for a hunt. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def _HandleLegacy(self, args, token=None):
"""Retrieves the clients for a hunt."""
hunt_urn = args.hunt_id.ToURN()
hunt_obj = aff4.FACTORY.Open(
hunt_urn, aff4_type=implementation.GRRHunt, token=token)
clients_by_status = hunt_obj.GetClientsByStatus()
hunt_clients = clients_by_status[args.c... | def _HandleLegacy(self, args, token=None):
"""Retrieves the clients for a hunt."""
hunt_urn = args.hunt_id.ToURN()
hunt_obj = aff4.FACTORY.Open(
hunt_urn, aff4_type=implementation.GRRHunt, token=token)
clients_by_status = hunt_obj.GetClientsByStatus()
hunt_clients = clients_by_status[args.c... | [
"Retrieves",
"the",
"clients",
"for",
"a",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1669-L1689 | [
"def",
"_HandleLegacy",
"(",
"self",
",",
"args",
",",
"token",
"=",
"None",
")",
":",
"hunt_urn",
"=",
"args",
".",
"hunt_id",
".",
"ToURN",
"(",
")",
"hunt_obj",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"hunt_urn",
",",
"aff4_type",
"=",
"imp... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiGetHuntContextHandler._HandleLegacy | Retrieves the context for a hunt. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def _HandleLegacy(self, args, token=None):
"""Retrieves the context for a hunt."""
hunt_obj = aff4.FACTORY.Open(
args.hunt_id.ToURN(), aff4_type=implementation.GRRHunt, token=token)
if isinstance(hunt_obj.context, rdf_hunts.HuntContext): # New style hunt.
# TODO(amoser): Hunt state will go ... | def _HandleLegacy(self, args, token=None):
"""Retrieves the context for a hunt."""
hunt_obj = aff4.FACTORY.Open(
args.hunt_id.ToURN(), aff4_type=implementation.GRRHunt, token=token)
if isinstance(hunt_obj.context, rdf_hunts.HuntContext): # New style hunt.
# TODO(amoser): Hunt state will go ... | [
"Retrieves",
"the",
"context",
"for",
"a",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1775-L1797 | [
"def",
"_HandleLegacy",
"(",
"self",
",",
"args",
",",
"token",
"=",
"None",
")",
":",
"hunt_obj",
"=",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"args",
".",
"hunt_id",
".",
"ToURN",
"(",
")",
",",
"aff4_type",
"=",
"implementation",
".",
"GRRHunt",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ApiCreateHuntHandler._HandleLegacy | Creates a new hunt. | grr/server/grr_response_server/gui/api_plugins/hunt.py | def _HandleLegacy(self, args, token=None):
"""Creates a new hunt."""
# We only create generic hunts with /hunts/create requests.
generic_hunt_args = rdf_hunts.GenericHuntArgs()
generic_hunt_args.flow_runner_args.flow_name = args.flow_name
generic_hunt_args.flow_args = args.flow_args
# Clear al... | def _HandleLegacy(self, args, token=None):
"""Creates a new hunt."""
# We only create generic hunts with /hunts/create requests.
generic_hunt_args = rdf_hunts.GenericHuntArgs()
generic_hunt_args.flow_runner_args.flow_name = args.flow_name
generic_hunt_args.flow_args = args.flow_args
# Clear al... | [
"Creates",
"a",
"new",
"hunt",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/hunt.py#L1829-L1872 | [
"def",
"_HandleLegacy",
"(",
"self",
",",
"args",
",",
"token",
"=",
"None",
")",
":",
"# We only create generic hunts with /hunts/create requests.",
"generic_hunt_args",
"=",
"rdf_hunts",
".",
"GenericHuntArgs",
"(",
")",
"generic_hunt_args",
".",
"flow_runner_args",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Register | Registers a new constructor in the factory.
Args:
name: A name associated with given constructor.
constructor: A constructor function that creates instances.
Raises:
ValueError: If there already is a constructor associated with given name. | grr/core/grr_response_core/lib/factory.py | def Register(self, name, constructor):
"""Registers a new constructor in the factory.
Args:
name: A name associated with given constructor.
constructor: A constructor function that creates instances.
Raises:
ValueError: If there already is a constructor associated with given name.
""... | def Register(self, name, constructor):
"""Registers a new constructor in the factory.
Args:
name: A name associated with given constructor.
constructor: A constructor function that creates instances.
Raises:
ValueError: If there already is a constructor associated with given name.
""... | [
"Registers",
"a",
"new",
"constructor",
"in",
"the",
"factory",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/factory.py#L44-L61 | [
"def",
"Register",
"(",
"self",
",",
"name",
",",
"constructor",
")",
":",
"precondition",
".",
"AssertType",
"(",
"name",
",",
"Text",
")",
"if",
"name",
"in",
"self",
".",
"_constructors",
":",
"message",
"=",
"\"Duplicated constructors %r and %r for name '%s'... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Unregister | Unregisters a constructor.
Args:
name: A name of the constructor to unregister.
Raises:
ValueError: If constructor with specified name has never been registered. | grr/core/grr_response_core/lib/factory.py | def Unregister(self, name):
"""Unregisters a constructor.
Args:
name: A name of the constructor to unregister.
Raises:
ValueError: If constructor with specified name has never been registered.
"""
precondition.AssertType(name, Text)
try:
del self._constructors[name]
exce... | def Unregister(self, name):
"""Unregisters a constructor.
Args:
name: A name of the constructor to unregister.
Raises:
ValueError: If constructor with specified name has never been registered.
"""
precondition.AssertType(name, Text)
try:
del self._constructors[name]
exce... | [
"Unregisters",
"a",
"constructor",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/factory.py#L63-L77 | [
"def",
"Unregister",
"(",
"self",
",",
"name",
")",
":",
"precondition",
".",
"AssertType",
"(",
"name",
",",
"Text",
")",
"try",
":",
"del",
"self",
".",
"_constructors",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"Constr... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Factory.Create | Creates a new instance.
Args:
name: A name identifying the constructor to use for instantiation.
Returns:
An instance of the type that the factory supports. | grr/core/grr_response_core/lib/factory.py | def Create(self, name):
"""Creates a new instance.
Args:
name: A name identifying the constructor to use for instantiation.
Returns:
An instance of the type that the factory supports.
"""
precondition.AssertType(name, Text)
try:
constructor = self._constructors[name]
exc... | def Create(self, name):
"""Creates a new instance.
Args:
name: A name identifying the constructor to use for instantiation.
Returns:
An instance of the type that the factory supports.
"""
precondition.AssertType(name, Text)
try:
constructor = self._constructors[name]
exc... | [
"Creates",
"a",
"new",
"instance",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/factory.py#L79-L104 | [
"def",
"Create",
"(",
"self",
",",
"name",
")",
":",
"precondition",
".",
"AssertType",
"(",
"name",
",",
"Text",
")",
"try",
":",
"constructor",
"=",
"self",
".",
"_constructors",
"[",
"name",
"]",
"except",
"KeyError",
":",
"message",
"=",
"\"No constr... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord.AddStatEntry | Registers stat entry at a given timestamp. | grr/server/grr_response_server/databases/mem_paths.py | def AddStatEntry(self, stat_entry, timestamp):
"""Registers stat entry at a given timestamp."""
if timestamp in self._stat_entries:
message = ("Duplicated stat entry write for path '%s' of type '%s' at "
"timestamp '%s'. Old: %s. New: %s.")
message %= ("/".join(self._components), s... | def AddStatEntry(self, stat_entry, timestamp):
"""Registers stat entry at a given timestamp."""
if timestamp in self._stat_entries:
message = ("Duplicated stat entry write for path '%s' of type '%s' at "
"timestamp '%s'. Old: %s. New: %s.")
message %= ("/".join(self._components), s... | [
"Registers",
"stat",
"entry",
"at",
"a",
"given",
"timestamp",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L50-L68 | [
"def",
"AddStatEntry",
"(",
"self",
",",
"stat_entry",
",",
"timestamp",
")",
":",
"if",
"timestamp",
"in",
"self",
".",
"_stat_entries",
":",
"message",
"=",
"(",
"\"Duplicated stat entry write for path '%s' of type '%s' at \"",
"\"timestamp '%s'. Old: %s. New: %s.\"",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord.AddHashEntry | Registers hash entry at a given timestamp. | grr/server/grr_response_server/databases/mem_paths.py | def AddHashEntry(self, hash_entry, timestamp):
"""Registers hash entry at a given timestamp."""
if timestamp in self._hash_entries:
message = ("Duplicated hash entry write for path '%s' of type '%s' at "
"timestamp '%s'. Old: %s. New: %s.")
message %= ("/".join(self._components), s... | def AddHashEntry(self, hash_entry, timestamp):
"""Registers hash entry at a given timestamp."""
if timestamp in self._hash_entries:
message = ("Duplicated hash entry write for path '%s' of type '%s' at "
"timestamp '%s'. Old: %s. New: %s.")
message %= ("/".join(self._components), s... | [
"Registers",
"hash",
"entry",
"at",
"a",
"given",
"timestamp",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L73-L91 | [
"def",
"AddHashEntry",
"(",
"self",
",",
"hash_entry",
",",
"timestamp",
")",
":",
"if",
"timestamp",
"in",
"self",
".",
"_hash_entries",
":",
"message",
"=",
"(",
"\"Duplicated hash entry write for path '%s' of type '%s' at \"",
"\"timestamp '%s'. Old: %s. New: %s.\"",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord.AddPathInfo | Updates existing path information of the path record. | grr/server/grr_response_server/databases/mem_paths.py | def AddPathInfo(self, path_info):
"""Updates existing path information of the path record."""
if self._path_type != path_info.path_type:
message = "Incompatible path types: `%s` and `%s`"
raise ValueError(message % (self._path_type, path_info.path_type))
if self._components != path_info.compone... | def AddPathInfo(self, path_info):
"""Updates existing path information of the path record."""
if self._path_type != path_info.path_type:
message = "Incompatible path types: `%s` and `%s`"
raise ValueError(message % (self._path_type, path_info.path_type))
if self._components != path_info.compone... | [
"Updates",
"existing",
"path",
"information",
"of",
"the",
"path",
"record",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L99-L116 | [
"def",
"AddPathInfo",
"(",
"self",
",",
"path_info",
")",
":",
"if",
"self",
".",
"_path_type",
"!=",
"path_info",
".",
"path_type",
":",
"message",
"=",
"\"Incompatible path types: `%s` and `%s`\"",
"raise",
"ValueError",
"(",
"message",
"%",
"(",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord.AddChild | Makes the path aware of some child. | grr/server/grr_response_server/databases/mem_paths.py | def AddChild(self, path_info):
"""Makes the path aware of some child."""
if self._path_type != path_info.path_type:
message = "Incompatible path types: `%s` and `%s`"
raise ValueError(message % (self._path_type, path_info.path_type))
if self._components != path_info.components[:-1]:
messa... | def AddChild(self, path_info):
"""Makes the path aware of some child."""
if self._path_type != path_info.path_type:
message = "Incompatible path types: `%s` and `%s`"
raise ValueError(message % (self._path_type, path_info.path_type))
if self._components != path_info.components[:-1]:
messa... | [
"Makes",
"the",
"path",
"aware",
"of",
"some",
"child",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L118-L128 | [
"def",
"AddChild",
"(",
"self",
",",
"path_info",
")",
":",
"if",
"self",
".",
"_path_type",
"!=",
"path_info",
".",
"path_type",
":",
"message",
"=",
"\"Incompatible path types: `%s` and `%s`\"",
"raise",
"ValueError",
"(",
"message",
"%",
"(",
"self",
".",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord.GetPathInfo | Generates a summary about the path record.
Args:
timestamp: A point in time from which the data should be retrieved.
Returns:
A `rdf_objects.PathInfo` instance. | grr/server/grr_response_server/databases/mem_paths.py | def GetPathInfo(self, timestamp=None):
"""Generates a summary about the path record.
Args:
timestamp: A point in time from which the data should be retrieved.
Returns:
A `rdf_objects.PathInfo` instance.
"""
path_info_timestamp = self._LastEntryTimestamp(self._path_infos, timestamp)
... | def GetPathInfo(self, timestamp=None):
"""Generates a summary about the path record.
Args:
timestamp: A point in time from which the data should be retrieved.
Returns:
A `rdf_objects.PathInfo` instance.
"""
path_info_timestamp = self._LastEntryTimestamp(self._path_infos, timestamp)
... | [
"Generates",
"a",
"summary",
"about",
"the",
"path",
"record",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L130-L156 | [
"def",
"GetPathInfo",
"(",
"self",
",",
"timestamp",
"=",
"None",
")",
":",
"path_info_timestamp",
"=",
"self",
".",
"_LastEntryTimestamp",
"(",
"self",
".",
"_path_infos",
",",
"timestamp",
")",
"try",
":",
"result",
"=",
"self",
".",
"_path_infos",
"[",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _PathRecord._LastEntryTimestamp | Searches for greatest timestamp lower than the specified one.
Args:
dct: A dictionary from timestamps to some items.
upper_bound_timestamp: An upper bound for timestamp to be returned.
Returns:
Greatest timestamp that is lower than the specified one. If no such value
exists, `None` is ... | grr/server/grr_response_server/databases/mem_paths.py | def _LastEntryTimestamp(dct, upper_bound_timestamp):
"""Searches for greatest timestamp lower than the specified one.
Args:
dct: A dictionary from timestamps to some items.
upper_bound_timestamp: An upper bound for timestamp to be returned.
Returns:
Greatest timestamp that is lower than ... | def _LastEntryTimestamp(dct, upper_bound_timestamp):
"""Searches for greatest timestamp lower than the specified one.
Args:
dct: A dictionary from timestamps to some items.
upper_bound_timestamp: An upper bound for timestamp to be returned.
Returns:
Greatest timestamp that is lower than ... | [
"Searches",
"for",
"greatest",
"timestamp",
"lower",
"than",
"the",
"specified",
"one",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L162-L181 | [
"def",
"_LastEntryTimestamp",
"(",
"dct",
",",
"upper_bound_timestamp",
")",
":",
"if",
"upper_bound_timestamp",
"is",
"None",
":",
"upper_bound",
"=",
"lambda",
"_",
":",
"True",
"else",
":",
"upper_bound",
"=",
"lambda",
"key",
":",
"key",
"<=",
"upper_bound... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.ReadPathInfo | Retrieves a path info record for a given path. | grr/server/grr_response_server/databases/mem_paths.py | def ReadPathInfo(self, client_id, path_type, components, timestamp=None):
"""Retrieves a path info record for a given path."""
try:
path_record = self.path_records[(client_id, path_type, components)]
return path_record.GetPathInfo(timestamp=timestamp)
except KeyError:
raise db.UnknownPathE... | def ReadPathInfo(self, client_id, path_type, components, timestamp=None):
"""Retrieves a path info record for a given path."""
try:
path_record = self.path_records[(client_id, path_type, components)]
return path_record.GetPathInfo(timestamp=timestamp)
except KeyError:
raise db.UnknownPathE... | [
"Retrieves",
"a",
"path",
"info",
"record",
"for",
"a",
"given",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L188-L195 | [
"def",
"ReadPathInfo",
"(",
"self",
",",
"client_id",
",",
"path_type",
",",
"components",
",",
"timestamp",
"=",
"None",
")",
":",
"try",
":",
"path_record",
"=",
"self",
".",
"path_records",
"[",
"(",
"client_id",
",",
"path_type",
",",
"components",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.ReadPathInfos | Retrieves path info records for given paths. | grr/server/grr_response_server/databases/mem_paths.py | def ReadPathInfos(self, client_id, path_type, components_list):
"""Retrieves path info records for given paths."""
result = {}
for components in components_list:
try:
path_record = self.path_records[(client_id, path_type, components)]
result[components] = path_record.GetPathInfo()
... | def ReadPathInfos(self, client_id, path_type, components_list):
"""Retrieves path info records for given paths."""
result = {}
for components in components_list:
try:
path_record = self.path_records[(client_id, path_type, components)]
result[components] = path_record.GetPathInfo()
... | [
"Retrieves",
"path",
"info",
"records",
"for",
"given",
"paths",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L198-L209 | [
"def",
"ReadPathInfos",
"(",
"self",
",",
"client_id",
",",
"path_type",
",",
"components_list",
")",
":",
"result",
"=",
"{",
"}",
"for",
"components",
"in",
"components_list",
":",
"try",
":",
"path_record",
"=",
"self",
".",
"path_records",
"[",
"(",
"c... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.ListDescendentPathInfos | Lists path info records that correspond to children of given path. | grr/server/grr_response_server/databases/mem_paths.py | def ListDescendentPathInfos(self,
client_id,
path_type,
components,
timestamp=None,
max_depth=None):
"""Lists path info records that correspond to children of given p... | def ListDescendentPathInfos(self,
client_id,
path_type,
components,
timestamp=None,
max_depth=None):
"""Lists path info records that correspond to children of given p... | [
"Lists",
"path",
"info",
"records",
"that",
"correspond",
"to",
"children",
"of",
"given",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L212-L277 | [
"def",
"ListDescendentPathInfos",
"(",
"self",
",",
"client_id",
",",
"path_type",
",",
"components",
",",
"timestamp",
"=",
"None",
",",
"max_depth",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"for",
"path_idx",
",",
"path_record",
"in",
"iteritems",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin._WritePathInfo | Writes a single path info record for given client. | grr/server/grr_response_server/databases/mem_paths.py | def _WritePathInfo(self, client_id, path_info):
"""Writes a single path info record for given client."""
if client_id not in self.metadatas:
raise db.UnknownClientError(client_id)
path_record = self._GetPathRecord(client_id, path_info)
path_record.AddPathInfo(path_info)
parent_path_info = pa... | def _WritePathInfo(self, client_id, path_info):
"""Writes a single path info record for given client."""
if client_id not in self.metadatas:
raise db.UnknownClientError(client_id)
path_record = self._GetPathRecord(client_id, path_info)
path_record.AddPathInfo(path_info)
parent_path_info = pa... | [
"Writes",
"a",
"single",
"path",
"info",
"record",
"for",
"given",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L290-L301 | [
"def",
"_WritePathInfo",
"(",
"self",
",",
"client_id",
",",
"path_info",
")",
":",
"if",
"client_id",
"not",
"in",
"self",
".",
"metadatas",
":",
"raise",
"db",
".",
"UnknownClientError",
"(",
"client_id",
")",
"path_record",
"=",
"self",
".",
"_GetPathReco... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.MultiClearPathHistory | Clears path history for specified paths of given clients. | grr/server/grr_response_server/databases/mem_paths.py | def MultiClearPathHistory(self, path_infos):
"""Clears path history for specified paths of given clients."""
for client_id, client_path_infos in iteritems(path_infos):
self.ClearPathHistory(client_id, client_path_infos) | def MultiClearPathHistory(self, path_infos):
"""Clears path history for specified paths of given clients."""
for client_id, client_path_infos in iteritems(path_infos):
self.ClearPathHistory(client_id, client_path_infos) | [
"Clears",
"path",
"history",
"for",
"specified",
"paths",
"of",
"given",
"clients",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L316-L319 | [
"def",
"MultiClearPathHistory",
"(",
"self",
",",
"path_infos",
")",
":",
"for",
"client_id",
",",
"client_path_infos",
"in",
"iteritems",
"(",
"path_infos",
")",
":",
"self",
".",
"ClearPathHistory",
"(",
"client_id",
",",
"client_path_infos",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.ClearPathHistory | Clears path history for specified paths of given client. | grr/server/grr_response_server/databases/mem_paths.py | def ClearPathHistory(self, client_id, path_infos):
"""Clears path history for specified paths of given client."""
for path_info in path_infos:
path_record = self._GetPathRecord(client_id, path_info)
path_record.ClearHistory() | def ClearPathHistory(self, client_id, path_infos):
"""Clears path history for specified paths of given client."""
for path_info in path_infos:
path_record = self._GetPathRecord(client_id, path_info)
path_record.ClearHistory() | [
"Clears",
"path",
"history",
"for",
"specified",
"paths",
"of",
"given",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L322-L326 | [
"def",
"ClearPathHistory",
"(",
"self",
",",
"client_id",
",",
"path_infos",
")",
":",
"for",
"path_info",
"in",
"path_infos",
":",
"path_record",
"=",
"self",
".",
"_GetPathRecord",
"(",
"client_id",
",",
"path_info",
")",
"path_record",
".",
"ClearHistory",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.MultiWritePathHistory | Writes a collection of hash and stat entries observed for given paths. | grr/server/grr_response_server/databases/mem_paths.py | def MultiWritePathHistory(self, client_path_histories):
"""Writes a collection of hash and stat entries observed for given paths."""
for client_path, client_path_history in iteritems(client_path_histories):
if client_path.client_id not in self.metadatas:
raise db.UnknownClientError(client_path.cli... | def MultiWritePathHistory(self, client_path_histories):
"""Writes a collection of hash and stat entries observed for given paths."""
for client_path, client_path_history in iteritems(client_path_histories):
if client_path.client_id not in self.metadatas:
raise db.UnknownClientError(client_path.cli... | [
"Writes",
"a",
"collection",
"of",
"hash",
"and",
"stat",
"entries",
"observed",
"for",
"given",
"paths",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L329-L354 | [
"def",
"MultiWritePathHistory",
"(",
"self",
",",
"client_path_histories",
")",
":",
"for",
"client_path",
",",
"client_path_history",
"in",
"iteritems",
"(",
"client_path_histories",
")",
":",
"if",
"client_path",
".",
"client_id",
"not",
"in",
"self",
".",
"meta... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBPathMixin.ReadPathInfosHistories | Reads a collection of hash and stat entries for given paths. | grr/server/grr_response_server/databases/mem_paths.py | def ReadPathInfosHistories(self, client_id, path_type, components_list):
"""Reads a collection of hash and stat entries for given paths."""
results = {}
for components in components_list:
try:
path_record = self.path_records[(client_id, path_type, components)]
except KeyError:
r... | def ReadPathInfosHistories(self, client_id, path_type, components_list):
"""Reads a collection of hash and stat entries for given paths."""
results = {}
for components in components_list:
try:
path_record = self.path_records[(client_id, path_type, components)]
except KeyError:
r... | [
"Reads",
"a",
"collection",
"of",
"hash",
"and",
"stat",
"entries",
"for",
"given",
"paths",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L357-L391 | [
"def",
"ReadPathInfosHistories",
"(",
"self",
",",
"client_id",
",",
"path_type",
",",
"components_list",
")",
":",
"results",
"=",
"{",
"}",
"for",
"components",
"in",
"components_list",
":",
"try",
":",
"path_record",
"=",
"self",
".",
"path_records",
"[",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConvertSupportedOSToConditions | Turn supported_os into a condition. | grr/server/grr_response_server/flows/general/collectors.py | def ConvertSupportedOSToConditions(src_object):
"""Turn supported_os into a condition."""
if src_object.supported_os:
conditions = " OR ".join("os == '%s'" % o for o in src_object.supported_os)
return conditions | def ConvertSupportedOSToConditions(src_object):
"""Turn supported_os into a condition."""
if src_object.supported_os:
conditions = " OR ".join("os == '%s'" % o for o in src_object.supported_os)
return conditions | [
"Turn",
"supported_os",
"into",
"a",
"condition",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L941-L945 | [
"def",
"ConvertSupportedOSToConditions",
"(",
"src_object",
")",
":",
"if",
"src_object",
".",
"supported_os",
":",
"conditions",
"=",
"\" OR \"",
".",
"join",
"(",
"\"os == '%s'\"",
"%",
"o",
"for",
"o",
"in",
"src_object",
".",
"supported_os",
")",
"return",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactCollectorArgs | Prepare bundle of artifacts and their dependencies for the client.
Args:
flow_args: An `ArtifactCollectorFlowArgs` instance.
knowledge_base: contains information about the client
Returns:
rdf value object containing a list of extended artifacts and the
knowledge base | grr/server/grr_response_server/flows/general/collectors.py | def GetArtifactCollectorArgs(flow_args, knowledge_base):
"""Prepare bundle of artifacts and their dependencies for the client.
Args:
flow_args: An `ArtifactCollectorFlowArgs` instance.
knowledge_base: contains information about the client
Returns:
rdf value object containing a list of extended artif... | def GetArtifactCollectorArgs(flow_args, knowledge_base):
"""Prepare bundle of artifacts and their dependencies for the client.
Args:
flow_args: An `ArtifactCollectorFlowArgs` instance.
knowledge_base: contains information about the client
Returns:
rdf value object containing a list of extended artif... | [
"Prepare",
"bundle",
"of",
"artifacts",
"and",
"their",
"dependencies",
"for",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L948-L984 | [
"def",
"GetArtifactCollectorArgs",
"(",
"flow_args",
",",
"knowledge_base",
")",
":",
"args",
"=",
"rdf_artifacts",
".",
"ClientArtifactCollectorArgs",
"(",
")",
"args",
".",
"knowledge_base",
"=",
"knowledge_base",
"args",
".",
"apply_parsers",
"=",
"flow_args",
".... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MeetsConditions | Check conditions on the source. | grr/server/grr_response_server/flows/general/collectors.py | def MeetsConditions(knowledge_base, source):
"""Check conditions on the source."""
source_conditions_met = True
os_conditions = ConvertSupportedOSToConditions(source)
if os_conditions:
source.conditions.append(os_conditions)
for condition in source.conditions:
source_conditions_met &= artifact_utils.C... | def MeetsConditions(knowledge_base, source):
"""Check conditions on the source."""
source_conditions_met = True
os_conditions = ConvertSupportedOSToConditions(source)
if os_conditions:
source.conditions.append(os_conditions)
for condition in source.conditions:
source_conditions_met &= artifact_utils.C... | [
"Check",
"conditions",
"on",
"the",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L987-L997 | [
"def",
"MeetsConditions",
"(",
"knowledge_base",
",",
"source",
")",
":",
"source_conditions_met",
"=",
"True",
"os_conditions",
"=",
"ConvertSupportedOSToConditions",
"(",
"source",
")",
"if",
"os_conditions",
":",
"source",
".",
"conditions",
".",
"append",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactsForCollection | Wrapper for the ArtifactArranger.
Extend the artifact list by dependencies and sort the artifacts to resolve the
dependencies.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names.
Returns:
A list of artifacts such that if they are collected in the given o... | grr/server/grr_response_server/flows/general/collectors.py | def GetArtifactsForCollection(os_name, artifact_list):
"""Wrapper for the ArtifactArranger.
Extend the artifact list by dependencies and sort the artifacts to resolve the
dependencies.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names.
Returns:
A list... | def GetArtifactsForCollection(os_name, artifact_list):
"""Wrapper for the ArtifactArranger.
Extend the artifact list by dependencies and sort the artifacts to resolve the
dependencies.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names.
Returns:
A list... | [
"Wrapper",
"for",
"the",
"ArtifactArranger",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1098-L1114 | [
"def",
"GetArtifactsForCollection",
"(",
"os_name",
",",
"artifact_list",
")",
":",
"artifact_arranger",
"=",
"ArtifactArranger",
"(",
"os_name",
",",
"artifact_list",
")",
"artifact_names",
"=",
"artifact_arranger",
".",
"GetArtifactsInProperOrder",
"(",
")",
"return",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactExpander.Expand | Expand artifact by extending its sources.
This method takes as input an rdf artifact object and returns a rdf expanded
artifact. It iterates through the list of sources processing them by type.
Each source of the original artifact can lead to one or more (in case of
artifact groups and files where the ... | grr/server/grr_response_server/flows/general/collectors.py | def Expand(self, rdf_artifact, requested):
"""Expand artifact by extending its sources.
This method takes as input an rdf artifact object and returns a rdf expanded
artifact. It iterates through the list of sources processing them by type.
Each source of the original artifact can lead to one or more (i... | def Expand(self, rdf_artifact, requested):
"""Expand artifact by extending its sources.
This method takes as input an rdf artifact object and returns a rdf expanded
artifact. It iterates through the list of sources processing them by type.
Each source of the original artifact can lead to one or more (i... | [
"Expand",
"artifact",
"by",
"extending",
"its",
"sources",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1009-L1059 | [
"def",
"Expand",
"(",
"self",
",",
"rdf_artifact",
",",
"requested",
")",
":",
"source_type",
"=",
"rdf_artifacts",
".",
"ArtifactSource",
".",
"SourceType",
"expanded_artifact",
"=",
"rdf_artifacts",
".",
"ExpandedArtifact",
"(",
"name",
"=",
"rdf_artifact",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactExpander._ExpandArtifactGroupSource | Recursively expands an artifact group source. | grr/server/grr_response_server/flows/general/collectors.py | def _ExpandArtifactGroupSource(self, source, requested):
"""Recursively expands an artifact group source."""
artifact_list = []
if "names" in source.attributes:
artifact_list = source.attributes["names"]
for artifact_name in artifact_list:
if artifact_name in self.processed_artifacts:
... | def _ExpandArtifactGroupSource(self, source, requested):
"""Recursively expands an artifact group source."""
artifact_list = []
if "names" in source.attributes:
artifact_list = source.attributes["names"]
for artifact_name in artifact_list:
if artifact_name in self.processed_artifacts:
... | [
"Recursively",
"expands",
"an",
"artifact",
"group",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1068-L1078 | [
"def",
"_ExpandArtifactGroupSource",
"(",
"self",
",",
"source",
",",
"requested",
")",
":",
"artifact_list",
"=",
"[",
"]",
"if",
"\"names\"",
"in",
"source",
".",
"attributes",
":",
"artifact_list",
"=",
"source",
".",
"attributes",
"[",
"\"names\"",
"]",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactExpander._ExpandArtifactFilesSource | Recursively expands an artifact files source. | grr/server/grr_response_server/flows/general/collectors.py | def _ExpandArtifactFilesSource(self, source, requested):
"""Recursively expands an artifact files source."""
expanded_source = rdf_artifacts.ExpandedSource(base_source=source)
sub_sources = []
artifact_list = []
if "artifact_list" in source.attributes:
artifact_list = source.attributes["artifa... | def _ExpandArtifactFilesSource(self, source, requested):
"""Recursively expands an artifact files source."""
expanded_source = rdf_artifacts.ExpandedSource(base_source=source)
sub_sources = []
artifact_list = []
if "artifact_list" in source.attributes:
artifact_list = source.attributes["artifa... | [
"Recursively",
"expands",
"an",
"artifact",
"files",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1080-L1095 | [
"def",
"_ExpandArtifactFilesSource",
"(",
"self",
",",
"source",
",",
"requested",
")",
":",
"expanded_source",
"=",
"rdf_artifacts",
".",
"ExpandedSource",
"(",
"base_source",
"=",
"source",
")",
"sub_sources",
"=",
"[",
"]",
"artifact_list",
"=",
"[",
"]",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._InitializeGraph | Creates the nodes and directed edges of the dependency graph.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names. | grr/server/grr_response_server/flows/general/collectors.py | def _InitializeGraph(self, os_name, artifact_list):
"""Creates the nodes and directed edges of the dependency graph.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names.
"""
dependencies = artifact_registry.REGISTRY.SearchDependencies(
os_na... | def _InitializeGraph(self, os_name, artifact_list):
"""Creates the nodes and directed edges of the dependency graph.
Args:
os_name: String specifying the OS name.
artifact_list: List of requested artifact names.
"""
dependencies = artifact_registry.REGISTRY.SearchDependencies(
os_na... | [
"Creates",
"the",
"nodes",
"and",
"directed",
"edges",
"of",
"the",
"dependency",
"graph",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1133-L1145 | [
"def",
"_InitializeGraph",
"(",
"self",
",",
"os_name",
",",
"artifact_list",
")",
":",
"dependencies",
"=",
"artifact_registry",
".",
"REGISTRY",
".",
"SearchDependencies",
"(",
"os_name",
",",
"artifact_list",
")",
"artifact_names",
",",
"attribute_names",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._AddAttributeNodes | Add the attribute nodes to the graph.
For every attribute that is required for the collection of requested
artifacts, add a node to the dependency graph. An attribute node will have
incoming edges from the artifacts that provide this attribute and outgoing
edges to the artifacts that depend on it.
... | grr/server/grr_response_server/flows/general/collectors.py | def _AddAttributeNodes(self, attribute_names):
"""Add the attribute nodes to the graph.
For every attribute that is required for the collection of requested
artifacts, add a node to the dependency graph. An attribute node will have
incoming edges from the artifacts that provide this attribute and outgo... | def _AddAttributeNodes(self, attribute_names):
"""Add the attribute nodes to the graph.
For every attribute that is required for the collection of requested
artifacts, add a node to the dependency graph. An attribute node will have
incoming edges from the artifacts that provide this attribute and outgo... | [
"Add",
"the",
"attribute",
"nodes",
"to",
"the",
"graph",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1147-L1162 | [
"def",
"_AddAttributeNodes",
"(",
"self",
",",
"attribute_names",
")",
":",
"for",
"attribute_name",
"in",
"attribute_names",
":",
"self",
".",
"graph",
"[",
"attribute_name",
"]",
"=",
"self",
".",
"Node",
"(",
"is_artifact",
"=",
"False",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._AddArtifactNodesAndEdges | Add the artifact nodes to the graph.
For every artifact that has to be collected, add a node to the dependency
graph.
The edges represent the dependencies. An artifact has outgoing edges to the
attributes it provides and incoming edges from attributes it depends on.
Initially, only artifacts witho... | grr/server/grr_response_server/flows/general/collectors.py | def _AddArtifactNodesAndEdges(self, artifact_names):
"""Add the artifact nodes to the graph.
For every artifact that has to be collected, add a node to the dependency
graph.
The edges represent the dependencies. An artifact has outgoing edges to the
attributes it provides and incoming edges from a... | def _AddArtifactNodesAndEdges(self, artifact_names):
"""Add the artifact nodes to the graph.
For every artifact that has to be collected, add a node to the dependency
graph.
The edges represent the dependencies. An artifact has outgoing edges to the
attributes it provides and incoming edges from a... | [
"Add",
"the",
"artifact",
"nodes",
"to",
"the",
"graph",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1164-L1182 | [
"def",
"_AddArtifactNodesAndEdges",
"(",
"self",
",",
"artifact_names",
")",
":",
"for",
"artifact_name",
"in",
"artifact_names",
":",
"self",
".",
"graph",
"[",
"artifact_name",
"]",
"=",
"self",
".",
"Node",
"(",
"is_artifact",
"=",
"True",
")",
"rdf_artifac... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._AddDependencyEdges | Add an edge for every dependency of the given artifact.
This method gets the attribute names for a given artifact and for every
attribute it adds a directed edge from the attribute node to the artifact
node. If an artifact does not have any dependencies it is added to the set
of reachable nodes.
A... | grr/server/grr_response_server/flows/general/collectors.py | def _AddDependencyEdges(self, rdf_artifact):
"""Add an edge for every dependency of the given artifact.
This method gets the attribute names for a given artifact and for every
attribute it adds a directed edge from the attribute node to the artifact
node. If an artifact does not have any dependencies i... | def _AddDependencyEdges(self, rdf_artifact):
"""Add an edge for every dependency of the given artifact.
This method gets the attribute names for a given artifact and for every
attribute it adds a directed edge from the attribute node to the artifact
node. If an artifact does not have any dependencies i... | [
"Add",
"an",
"edge",
"for",
"every",
"dependency",
"of",
"the",
"given",
"artifact",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1184-L1202 | [
"def",
"_AddDependencyEdges",
"(",
"self",
",",
"rdf_artifact",
")",
":",
"artifact_dependencies",
"=",
"artifact_registry",
".",
"GetArtifactPathDependencies",
"(",
"rdf_artifact",
")",
"if",
"artifact_dependencies",
":",
"for",
"attribute",
"in",
"artifact_dependencies"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._AddProvidesEdges | Add an edge for every attribute the given artifact provides.
This method adds a directed edge from the artifact node to every attribute
this artifact provides.
Args:
rdf_artifact: The artifact object. | grr/server/grr_response_server/flows/general/collectors.py | def _AddProvidesEdges(self, rdf_artifact):
"""Add an edge for every attribute the given artifact provides.
This method adds a directed edge from the artifact node to every attribute
this artifact provides.
Args:
rdf_artifact: The artifact object.
"""
for attribute in rdf_artifact.provide... | def _AddProvidesEdges(self, rdf_artifact):
"""Add an edge for every attribute the given artifact provides.
This method adds a directed edge from the artifact node to every attribute
this artifact provides.
Args:
rdf_artifact: The artifact object.
"""
for attribute in rdf_artifact.provide... | [
"Add",
"an",
"edge",
"for",
"every",
"attribute",
"the",
"given",
"artifact",
"provides",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1204-L1214 | [
"def",
"_AddProvidesEdges",
"(",
"self",
",",
"rdf_artifact",
")",
":",
"for",
"attribute",
"in",
"rdf_artifact",
".",
"provides",
":",
"self",
".",
"_AddEdge",
"(",
"rdf_artifact",
".",
"name",
",",
"attribute",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger._AddEdge | Add a directed edge to the graph.
Add the end to the list of outgoing nodes of the start and the start to the
list of incoming nodes of the end node.
Args:
start_node: name of the start node
end_node: name of the end node | grr/server/grr_response_server/flows/general/collectors.py | def _AddEdge(self, start_node, end_node):
"""Add a directed edge to the graph.
Add the end to the list of outgoing nodes of the start and the start to the
list of incoming nodes of the end node.
Args:
start_node: name of the start node
end_node: name of the end node
"""
self.graph... | def _AddEdge(self, start_node, end_node):
"""Add a directed edge to the graph.
Add the end to the list of outgoing nodes of the start and the start to the
list of incoming nodes of the end node.
Args:
start_node: name of the start node
end_node: name of the end node
"""
self.graph... | [
"Add",
"a",
"directed",
"edge",
"to",
"the",
"graph",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1216-L1233 | [
"def",
"_AddEdge",
"(",
"self",
",",
"start_node",
",",
"end_node",
")",
":",
"self",
".",
"graph",
"[",
"start_node",
"]",
".",
"outgoing",
".",
"append",
"(",
"end_node",
")",
"# This check is necessary because an artifact can provide attributes that",
"# are not co... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactArranger.GetArtifactsInProperOrder | Bring the artifacts in a linear order that resolves dependencies.
This method obtains a linear ordering of the nodes and then returns the list
of artifact names.
Returns:
A list of `ArtifactName` instances such that if they are collected in the
given order their dependencies are resolved. | grr/server/grr_response_server/flows/general/collectors.py | def GetArtifactsInProperOrder(self):
"""Bring the artifacts in a linear order that resolves dependencies.
This method obtains a linear ordering of the nodes and then returns the list
of artifact names.
Returns:
A list of `ArtifactName` instances such that if they are collected in the
given... | def GetArtifactsInProperOrder(self):
"""Bring the artifacts in a linear order that resolves dependencies.
This method obtains a linear ordering of the nodes and then returns the list
of artifact names.
Returns:
A list of `ArtifactName` instances such that if they are collected in the
given... | [
"Bring",
"the",
"artifacts",
"in",
"a",
"linear",
"order",
"that",
"resolves",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/collectors.py#L1235-L1261 | [
"def",
"GetArtifactsInProperOrder",
"(",
"self",
")",
":",
"artifact_list",
"=",
"[",
"]",
"while",
"self",
".",
"reachable_nodes",
":",
"node_name",
"=",
"self",
".",
"reachable_nodes",
".",
"pop",
"(",
")",
"node",
"=",
"self",
".",
"graph",
"[",
"node_n... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Finger.ConsumeRange | Consumes an entire range, or part thereof.
If the finger has no ranges left, or the curent range start is higher
than the end of the consumed block, nothing happens. Otherwise,
the current range is adjusted for the consumed block, or removed,
if the entire block is consumed. For things to work, the con... | grr/core/grr_response_core/lib/fingerprint.py | def ConsumeRange(self, start, end):
"""Consumes an entire range, or part thereof.
If the finger has no ranges left, or the curent range start is higher
than the end of the consumed block, nothing happens. Otherwise,
the current range is adjusted for the consumed block, or removed,
if the entire blo... | def ConsumeRange(self, start, end):
"""Consumes an entire range, or part thereof.
If the finger has no ranges left, or the curent range start is higher
than the end of the consumed block, nothing happens. Otherwise,
the current range is adjusted for the consumed block, or removed,
if the entire blo... | [
"Consumes",
"an",
"entire",
"range",
"or",
"part",
"thereof",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L65-L98 | [
"def",
"ConsumeRange",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"old",
"=",
"self",
".",
"CurrentRange",
"(",
")",
"if",
"old",
"is",
"None",
":",
"return",
"if",
"old",
".",
"start",
">",
"start",
":",
"if",
"old",
".",
"start",
"<",
"en... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter._GetNextInterval | Returns the next Range of the file that is to be hashed.
For all fingers, inspect their next expected range, and return the
lowest uninterrupted range of interest. If the range is larger than
BLOCK_SIZE, truncate it.
Returns:
Next range of interest in a Range namedtuple. | grr/core/grr_response_core/lib/fingerprint.py | def _GetNextInterval(self):
"""Returns the next Range of the file that is to be hashed.
For all fingers, inspect their next expected range, and return the
lowest uninterrupted range of interest. If the range is larger than
BLOCK_SIZE, truncate it.
Returns:
Next range of interest in a Range n... | def _GetNextInterval(self):
"""Returns the next Range of the file that is to be hashed.
For all fingers, inspect their next expected range, and return the
lowest uninterrupted range of interest. If the range is larger than
BLOCK_SIZE, truncate it.
Returns:
Next range of interest in a Range n... | [
"Returns",
"the",
"next",
"Range",
"of",
"the",
"file",
"that",
"is",
"to",
"be",
"hashed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L135-L156 | [
"def",
"_GetNextInterval",
"(",
"self",
")",
":",
"ranges",
"=",
"[",
"x",
".",
"CurrentRange",
"(",
")",
"for",
"x",
"in",
"self",
".",
"fingers",
"]",
"starts",
"=",
"set",
"(",
"[",
"r",
".",
"start",
"for",
"r",
"in",
"ranges",
"if",
"r",
"]"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter._HashBlock | _HashBlock feeds data blocks into the hashers of fingers.
This function must be called before adjusting fingers for next
interval, otherwise the lack of remaining ranges will cause the
block not to be hashed for a specific finger.
Start and end are used to validate the expected ranges, to catch
un... | grr/core/grr_response_core/lib/fingerprint.py | def _HashBlock(self, block, start, end):
"""_HashBlock feeds data blocks into the hashers of fingers.
This function must be called before adjusting fingers for next
interval, otherwise the lack of remaining ranges will cause the
block not to be hashed for a specific finger.
Start and end are used ... | def _HashBlock(self, block, start, end):
"""_HashBlock feeds data blocks into the hashers of fingers.
This function must be called before adjusting fingers for next
interval, otherwise the lack of remaining ranges will cause the
block not to be hashed for a specific finger.
Start and end are used ... | [
"_HashBlock",
"feeds",
"data",
"blocks",
"into",
"the",
"hashers",
"of",
"fingers",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L162-L189 | [
"def",
"_HashBlock",
"(",
"self",
",",
"block",
",",
"start",
",",
"end",
")",
":",
"for",
"finger",
"in",
"self",
".",
"fingers",
":",
"expected_range",
"=",
"finger",
".",
"CurrentRange",
"(",
")",
"if",
"expected_range",
"is",
"None",
":",
"continue",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter.HashIt | Finalizing function for the Fingerprint class.
This method applies all the different hash functions over the
previously specified different ranges of the input file, and
computes the resulting hashes.
After calling HashIt, the state of the object is reset to its
initial state, with no fingers defi... | grr/core/grr_response_core/lib/fingerprint.py | def HashIt(self):
"""Finalizing function for the Fingerprint class.
This method applies all the different hash functions over the
previously specified different ranges of the input file, and
computes the resulting hashes.
After calling HashIt, the state of the object is reset to its
initial st... | def HashIt(self):
"""Finalizing function for the Fingerprint class.
This method applies all the different hash functions over the
previously specified different ranges of the input file, and
computes the resulting hashes.
After calling HashIt, the state of the object is reset to its
initial st... | [
"Finalizing",
"function",
"for",
"the",
"Fingerprint",
"class",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L191-L239 | [
"def",
"HashIt",
"(",
"self",
")",
":",
"while",
"True",
":",
"interval",
"=",
"self",
".",
"_GetNextInterval",
"(",
")",
"if",
"interval",
"is",
"None",
":",
"break",
"self",
".",
"file",
".",
"seek",
"(",
"interval",
".",
"start",
",",
"os",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter.EvalGeneric | Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be in... | grr/core/grr_response_core/lib/fingerprint.py | def EvalGeneric(self, hashers=None):
"""Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out... | def EvalGeneric(self, hashers=None):
"""Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out... | [
"Causes",
"the",
"entire",
"file",
"to",
"be",
"hashed",
"by",
"the",
"given",
"hash",
"functions",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L241-L261 | [
"def",
"EvalGeneric",
"(",
"self",
",",
"hashers",
"=",
"None",
")",
":",
"if",
"hashers",
"is",
"None",
":",
"hashers",
"=",
"Fingerprinter",
".",
"GENERIC_HASH_CLASSES",
"hashfuncs",
"=",
"[",
"x",
"(",
")",
"for",
"x",
"in",
"hashers",
"]",
"finger",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter._PecoffHeaderParser | Parses PECOFF headers.
Reads header magic and some data structures in a file to determine if
it is a valid PECOFF header, and figure out the offsets at which
relevant data is stored.
While this code contains multiple seeks and small reads, that is
compensated by the underlying libc buffering mechan... | grr/core/grr_response_core/lib/fingerprint.py | def _PecoffHeaderParser(self):
"""Parses PECOFF headers.
Reads header magic and some data structures in a file to determine if
it is a valid PECOFF header, and figure out the offsets at which
relevant data is stored.
While this code contains multiple seeks and small reads, that is
compensated b... | def _PecoffHeaderParser(self):
"""Parses PECOFF headers.
Reads header magic and some data structures in a file to determine if
it is a valid PECOFF header, and figure out the offsets at which
relevant data is stored.
While this code contains multiple seeks and small reads, that is
compensated b... | [
"Parses",
"PECOFF",
"headers",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L263-L335 | [
"def",
"_PecoffHeaderParser",
"(",
"self",
")",
":",
"extents",
"=",
"{",
"}",
"self",
".",
"file",
".",
"seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"buf",
"=",
"self",
".",
"file",
".",
"read",
"(",
"2",
")",
"if",
"buf",
"!=",
"b'MZ'",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter._CollectSignedData | Extracts signedData blob from PECOFF binary and parses first layer. | grr/core/grr_response_core/lib/fingerprint.py | def _CollectSignedData(self, extent):
"""Extracts signedData blob from PECOFF binary and parses first layer."""
start, length = extent
self.file.seek(start, os.SEEK_SET)
buf = self.file.read(length)
signed_data = []
# This loop ignores trailing cruft, or too-short signedData chunks.
while l... | def _CollectSignedData(self, extent):
"""Extracts signedData blob from PECOFF binary and parses first layer."""
start, length = extent
self.file.seek(start, os.SEEK_SET)
buf = self.file.read(length)
signed_data = []
# This loop ignores trailing cruft, or too-short signedData chunks.
while l... | [
"Extracts",
"signedData",
"blob",
"from",
"PECOFF",
"binary",
"and",
"parses",
"first",
"layer",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L337-L353 | [
"def",
"_CollectSignedData",
"(",
"self",
",",
"extent",
")",
":",
"start",
",",
"length",
"=",
"extent",
"self",
".",
"file",
".",
"seek",
"(",
"start",
",",
"os",
".",
"SEEK_SET",
")",
"buf",
"=",
"self",
".",
"file",
".",
"read",
"(",
"length",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Fingerprinter.EvalPecoff | If the file is a PE/COFF file, computes authenticode hashes on it.
This checks if the input file is a valid PE/COFF image file (e.g. a
Windows binary, driver, or DLL) and if yes, sets up a 'finger' for
fingerprinting in Authenticode style.
If available, the 'SignedData' section of the image file is ret... | grr/core/grr_response_core/lib/fingerprint.py | def EvalPecoff(self, hashers=None):
"""If the file is a PE/COFF file, computes authenticode hashes on it.
This checks if the input file is a valid PE/COFF image file (e.g. a
Windows binary, driver, or DLL) and if yes, sets up a 'finger' for
fingerprinting in Authenticode style.
If available, the 'S... | def EvalPecoff(self, hashers=None):
"""If the file is a PE/COFF file, computes authenticode hashes on it.
This checks if the input file is a valid PE/COFF image file (e.g. a
Windows binary, driver, or DLL) and if yes, sets up a 'finger' for
fingerprinting in Authenticode style.
If available, the 'S... | [
"If",
"the",
"file",
"is",
"a",
"PE",
"/",
"COFF",
"file",
"computes",
"authenticode",
"hashes",
"on",
"it",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L355-L413 | [
"def",
"EvalPecoff",
"(",
"self",
",",
"hashers",
"=",
"None",
")",
":",
"try",
":",
"extents",
"=",
"self",
".",
"_PecoffHeaderParser",
"(",
")",
"except",
"struct",
".",
"error",
":",
"# Parsing the header failed. Just ignore this, and claim",
"# that the file is ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FirefoxHistoryParser.Parse | Parse the History file. | grr/core/grr_response_core/lib/parsers/firefox3_history.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the History file."""
_, _ = stat, knowledge_base
# TODO(user): Convert this to use the far more intelligent plaso parser.
ff = Firefox3History(file_object)
for timestamp, unused_entry_type, url, title in ff.Parse():
yield rdf_webhist... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the History file."""
_, _ = stat, knowledge_base
# TODO(user): Convert this to use the far more intelligent plaso parser.
ff = Firefox3History(file_object)
for timestamp, unused_entry_type, url, title in ff.Parse():
yield rdf_webhist... | [
"Parse",
"the",
"History",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/firefox3_history.py#L23-L35 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
",",
"_",
"=",
"stat",
",",
"knowledge_base",
"# TODO(user): Convert this to use the far more intelligent plaso parser.",
"ff",
"=",
"Firefox3History",
"(",
"file_objec... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Firefox3History.Parse | Iterator returning dict for each entry in history. | grr/core/grr_response_core/lib/parsers/firefox3_history.py | def Parse(self):
"""Iterator returning dict for each entry in history."""
for timestamp, url, title in self.Query(self.VISITS_QUERY):
if not isinstance(timestamp, (long, int)):
timestamp = 0
yield [timestamp, "FIREFOX3_VISIT", url, title] | def Parse(self):
"""Iterator returning dict for each entry in history."""
for timestamp, url, title in self.Query(self.VISITS_QUERY):
if not isinstance(timestamp, (long, int)):
timestamp = 0
yield [timestamp, "FIREFOX3_VISIT", url, title] | [
"Iterator",
"returning",
"dict",
"for",
"each",
"entry",
"in",
"history",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/firefox3_history.py#L54-L60 | [
"def",
"Parse",
"(",
"self",
")",
":",
"for",
"timestamp",
",",
"url",
",",
"title",
"in",
"self",
".",
"Query",
"(",
"self",
".",
"VISITS_QUERY",
")",
":",
"if",
"not",
"isinstance",
"(",
"timestamp",
",",
"(",
"long",
",",
"int",
")",
")",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ReadTag | Read a tag from the buffer, and return a (tag_bytes, new_pos) tuple. | grr/core/grr_response_core/lib/rdfvalues/structs.py | def ReadTag(buf, pos):
"""Read a tag from the buffer, and return a (tag_bytes, new_pos) tuple."""
try:
start = pos
while ORD_MAP_AND_0X80[buf[pos]]:
pos += 1
pos += 1
return (buf[start:pos], pos)
except IndexError:
raise ValueError("Invalid tag") | def ReadTag(buf, pos):
"""Read a tag from the buffer, and return a (tag_bytes, new_pos) tuple."""
try:
start = pos
while ORD_MAP_AND_0X80[buf[pos]]:
pos += 1
pos += 1
return (buf[start:pos], pos)
except IndexError:
raise ValueError("Invalid tag") | [
"Read",
"a",
"tag",
"from",
"the",
"buffer",
"and",
"return",
"a",
"(",
"tag_bytes",
"new_pos",
")",
"tuple",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L98-L107 | [
"def",
"ReadTag",
"(",
"buf",
",",
"pos",
")",
":",
"try",
":",
"start",
"=",
"pos",
"while",
"ORD_MAP_AND_0X80",
"[",
"buf",
"[",
"pos",
"]",
"]",
":",
"pos",
"+=",
"1",
"pos",
"+=",
"1",
"return",
"(",
"buf",
"[",
"start",
":",
"pos",
"]",
",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VarintEncode | Convert an integer to a varint and write it using the write function. | grr/core/grr_response_core/lib/rdfvalues/structs.py | def VarintEncode(value):
"""Convert an integer to a varint and write it using the write function."""
result = b""
if value < 0:
raise ValueError("Varint can not encode a negative number.")
bits = value & 0x7f
value >>= 7
while value:
result += HIGH_CHR_MAP[bits]
bits = value & 0x7f
value >... | def VarintEncode(value):
"""Convert an integer to a varint and write it using the write function."""
result = b""
if value < 0:
raise ValueError("Varint can not encode a negative number.")
bits = value & 0x7f
value >>= 7
while value:
result += HIGH_CHR_MAP[bits]
bits = value & 0x7f
value >... | [
"Convert",
"an",
"integer",
"to",
"a",
"varint",
"and",
"write",
"it",
"using",
"the",
"write",
"function",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L111-L127 | [
"def",
"VarintEncode",
"(",
"value",
")",
":",
"result",
"=",
"b\"\"",
"if",
"value",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"Varint can not encode a negative number.\"",
")",
"bits",
"=",
"value",
"&",
"0x7f",
"value",
">>=",
"7",
"while",
"value",
":... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SignedVarintEncode | Encode a signed integer as a zigzag encoded signed integer. | grr/core/grr_response_core/lib/rdfvalues/structs.py | def SignedVarintEncode(value):
"""Encode a signed integer as a zigzag encoded signed integer."""
result = b""
if value < 0:
value += (1 << 64)
bits = value & 0x7f
value >>= 7
while value:
result += HIGH_CHR_MAP[bits]
bits = value & 0x7f
value >>= 7
result += CHR_MAP[bits]
return result | def SignedVarintEncode(value):
"""Encode a signed integer as a zigzag encoded signed integer."""
result = b""
if value < 0:
value += (1 << 64)
bits = value & 0x7f
value >>= 7
while value:
result += HIGH_CHR_MAP[bits]
bits = value & 0x7f
value >>= 7
result += CHR_MAP[bits]
return result | [
"Encode",
"a",
"signed",
"integer",
"as",
"a",
"zigzag",
"encoded",
"signed",
"integer",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L130-L144 | [
"def",
"SignedVarintEncode",
"(",
"value",
")",
":",
"result",
"=",
"b\"\"",
"if",
"value",
"<",
"0",
":",
"value",
"+=",
"(",
"1",
"<<",
"64",
")",
"bits",
"=",
"value",
"&",
"0x7f",
"value",
">>=",
"7",
"while",
"value",
":",
"result",
"+=",
"HIG... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VarintReader | A 64 bit decoder from google.protobuf.internal.decoder. | grr/core/grr_response_core/lib/rdfvalues/structs.py | def VarintReader(buf, pos=0):
"""A 64 bit decoder from google.protobuf.internal.decoder."""
result = 0
shift = 0
while 1:
b = buf[pos]
result |= (ORD_MAP_AND_0X7F[b] << shift)
pos += 1
if not ORD_MAP_AND_0X80[b]:
return (result, pos)
shift += 7
if shift >= 64:
raise rdfvalue... | def VarintReader(buf, pos=0):
"""A 64 bit decoder from google.protobuf.internal.decoder."""
result = 0
shift = 0
while 1:
b = buf[pos]
result |= (ORD_MAP_AND_0X7F[b] << shift)
pos += 1
if not ORD_MAP_AND_0X80[b]:
return (result, pos)
shift += 7
if shift >= 64:
raise rdfvalue... | [
"A",
"64",
"bit",
"decoder",
"from",
"google",
".",
"protobuf",
".",
"internal",
".",
"decoder",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/structs.py#L148-L161 | [
"def",
"VarintReader",
"(",
"buf",
",",
"pos",
"=",
"0",
")",
":",
"result",
"=",
"0",
"shift",
"=",
"0",
"while",
"1",
":",
"b",
"=",
"buf",
"[",
"pos",
"]",
"result",
"|=",
"(",
"ORD_MAP_AND_0X7F",
"[",
"b",
"]",
"<<",
"shift",
")",
"pos",
"+... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.