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 | APIAuthorizationManager._CreateRouter | Creates a router with a given name and params. | grr/server/grr_response_server/gui/api_auth_manager.py | def _CreateRouter(self, router_cls, params=None):
"""Creates a router with a given name and params."""
if not router_cls.params_type and params:
raise ApiCallRouterDoesNotExpectParameters(
"%s is not configurable" % router_cls)
rdf_params = None
if router_cls.params_type:
rdf_para... | def _CreateRouter(self, router_cls, params=None):
"""Creates a router with a given name and params."""
if not router_cls.params_type and params:
raise ApiCallRouterDoesNotExpectParameters(
"%s is not configurable" % router_cls)
rdf_params = None
if router_cls.params_type:
rdf_para... | [
"Creates",
"a",
"router",
"with",
"a",
"given",
"name",
"and",
"params",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_auth_manager.py#L71-L83 | [
"def",
"_CreateRouter",
"(",
"self",
",",
"router_cls",
",",
"params",
"=",
"None",
")",
":",
"if",
"not",
"router_cls",
".",
"params_type",
"and",
"params",
":",
"raise",
"ApiCallRouterDoesNotExpectParameters",
"(",
"\"%s is not configurable\"",
"%",
"router_cls",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | APIAuthorizationManager.GetRouterForUser | Returns a router corresponding to a given username. | grr/server/grr_response_server/gui/api_auth_manager.py | def GetRouterForUser(self, username):
"""Returns a router corresponding to a given username."""
for index, router in enumerate(self.routers):
router_id = str(index)
if self.auth_manager.CheckPermissions(username, router_id):
logging.debug("Matched router %s to user %s", router.__class__.__... | def GetRouterForUser(self, username):
"""Returns a router corresponding to a given username."""
for index, router in enumerate(self.routers):
router_id = str(index)
if self.auth_manager.CheckPermissions(username, router_id):
logging.debug("Matched router %s to user %s", router.__class__.__... | [
"Returns",
"a",
"router",
"corresponding",
"to",
"a",
"given",
"username",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_auth_manager.py#L117-L130 | [
"def",
"GetRouterForUser",
"(",
"self",
",",
"username",
")",
":",
"for",
"index",
",",
"router",
"in",
"enumerate",
"(",
"self",
".",
"routers",
")",
":",
"router_id",
"=",
"str",
"(",
"index",
")",
"if",
"self",
".",
"auth_manager",
".",
"CheckPermissi... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetBigQueryClient | Create a BigQueryClient. | grr/server/grr_response_server/bigquery.py | def GetBigQueryClient(service_account_json=None,
project_id=None,
dataset_id=None):
"""Create a BigQueryClient."""
service_account_data = (
service_account_json or config.CONFIG["BigQuery.service_acct_json"])
project_id = project_id or config.CONFIG["BigQuery.proj... | def GetBigQueryClient(service_account_json=None,
project_id=None,
dataset_id=None):
"""Create a BigQueryClient."""
service_account_data = (
service_account_json or config.CONFIG["BigQuery.service_acct_json"])
project_id = project_id or config.CONFIG["BigQuery.proj... | [
"Create",
"a",
"BigQueryClient",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bigquery.py#L38-L58 | [
"def",
"GetBigQueryClient",
"(",
"service_account_json",
"=",
"None",
",",
"project_id",
"=",
"None",
",",
"dataset_id",
"=",
"None",
")",
":",
"service_account_data",
"=",
"(",
"service_account_json",
"or",
"config",
".",
"CONFIG",
"[",
"\"BigQuery.service_acct_jso... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BigQueryClient.CreateDataset | Create a dataset. | grr/server/grr_response_server/bigquery.py | def CreateDataset(self):
"""Create a dataset."""
body = {
"datasetReference": {
"datasetId": self.dataset_id,
"description": "Data exported from GRR",
"friendlyName": "GRRExportData",
"projectId": self.project_id
}
}
result = self.service.d... | def CreateDataset(self):
"""Create a dataset."""
body = {
"datasetReference": {
"datasetId": self.dataset_id,
"description": "Data exported from GRR",
"friendlyName": "GRRExportData",
"projectId": self.project_id
}
}
result = self.service.d... | [
"Create",
"a",
"dataset",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bigquery.py#L83-L96 | [
"def",
"CreateDataset",
"(",
"self",
")",
":",
"body",
"=",
"{",
"\"datasetReference\"",
":",
"{",
"\"datasetId\"",
":",
"self",
".",
"dataset_id",
",",
"\"description\"",
":",
"\"Data exported from GRR\"",
",",
"\"friendlyName\"",
":",
"\"GRRExportData\"",
",",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BigQueryClient.RetryUpload | Retry the BigQuery upload job.
Using the same job id protects us from duplicating data on the server. If we
fail all of our retries we raise.
Args:
job: BigQuery job object
job_id: ID string for this upload job
error: errors.HttpError object from the first error
Returns:
API r... | grr/server/grr_response_server/bigquery.py | def RetryUpload(self, job, job_id, error):
"""Retry the BigQuery upload job.
Using the same job id protects us from duplicating data on the server. If we
fail all of our retries we raise.
Args:
job: BigQuery job object
job_id: ID string for this upload job
error: errors.HttpError obj... | def RetryUpload(self, job, job_id, error):
"""Retry the BigQuery upload job.
Using the same job id protects us from duplicating data on the server. If we
fail all of our retries we raise.
Args:
job: BigQuery job object
job_id: ID string for this upload job
error: errors.HttpError obj... | [
"Retry",
"the",
"BigQuery",
"upload",
"job",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bigquery.py#L122-L165 | [
"def",
"RetryUpload",
"(",
"self",
",",
"job",
",",
"job_id",
",",
"error",
")",
":",
"if",
"self",
".",
"IsErrorRetryable",
"(",
"error",
")",
":",
"retry_count",
"=",
"0",
"sleep_interval",
"=",
"config",
".",
"CONFIG",
"[",
"\"BigQuery.retry_interval\"",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BigQueryClient.InsertData | Insert data into a bigquery table.
If the table specified doesn't exist, it will be created with the specified
schema.
Args:
table_id: string table id
fd: open file descriptor containing the newline separated JSON
schema: BigQuery schema dict
job_id: string job id
Returns:
... | grr/server/grr_response_server/bigquery.py | def InsertData(self, table_id, fd, schema, job_id):
"""Insert data into a bigquery table.
If the table specified doesn't exist, it will be created with the specified
schema.
Args:
table_id: string table id
fd: open file descriptor containing the newline separated JSON
schema: BigQuer... | def InsertData(self, table_id, fd, schema, job_id):
"""Insert data into a bigquery table.
If the table specified doesn't exist, it will be created with the specified
schema.
Args:
table_id: string table id
fd: open file descriptor containing the newline separated JSON
schema: BigQuer... | [
"Insert",
"data",
"into",
"a",
"bigquery",
"table",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bigquery.py#L167-L220 | [
"def",
"InsertData",
"(",
"self",
",",
"table_id",
",",
"fd",
",",
"schema",
",",
"job_id",
")",
":",
"configuration",
"=",
"{",
"\"schema\"",
":",
"{",
"\"fields\"",
":",
"schema",
"}",
",",
"\"destinationTable\"",
":",
"{",
"\"projectId\"",
":",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Types.CreateFlowArgs | Creates flow arguments object for a flow with a given name. | api_client/python/grr_api_client/types.py | def CreateFlowArgs(self, flow_name=None):
"""Creates flow arguments object for a flow with a given name."""
if not self._flow_descriptors:
self._flow_descriptors = {}
result = self._context.SendRequest("ListFlowDescriptors", None)
for item in result.items:
self._flow_descriptors[item.... | def CreateFlowArgs(self, flow_name=None):
"""Creates flow arguments object for a flow with a given name."""
if not self._flow_descriptors:
self._flow_descriptors = {}
result = self._context.SendRequest("ListFlowDescriptors", None)
for item in result.items:
self._flow_descriptors[item.... | [
"Creates",
"flow",
"arguments",
"object",
"for",
"a",
"flow",
"with",
"a",
"given",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/types.py#L37-L51 | [
"def",
"CreateFlowArgs",
"(",
"self",
",",
"flow_name",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_flow_descriptors",
":",
"self",
".",
"_flow_descriptors",
"=",
"{",
"}",
"result",
"=",
"self",
".",
"_context",
".",
"SendRequest",
"(",
"\"ListFlow... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TSKFile.MakeStatResponse | Given a TSK info object make a StatEntry.
Note that tsk uses two things to uniquely identify a data stream - the inode
object given in tsk_file and the attribute object which may correspond to an
ADS of this file for filesystems which support ADS. We store both of these
in the stat response.
Args:... | grr/client/grr_response_client/vfs_handlers/sleuthkit.py | def MakeStatResponse(self, tsk_file, tsk_attribute=None, append_name=None):
"""Given a TSK info object make a StatEntry.
Note that tsk uses two things to uniquely identify a data stream - the inode
object given in tsk_file and the attribute object which may correspond to an
ADS of this file for filesys... | def MakeStatResponse(self, tsk_file, tsk_attribute=None, append_name=None):
"""Given a TSK info object make a StatEntry.
Note that tsk uses two things to uniquely identify a data stream - the inode
object given in tsk_file and the attribute object which may correspond to an
ADS of this file for filesys... | [
"Given",
"a",
"TSK",
"info",
"object",
"make",
"a",
"StatEntry",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/sleuthkit.py#L226-L304 | [
"def",
"MakeStatResponse",
"(",
"self",
",",
"tsk_file",
",",
"tsk_attribute",
"=",
"None",
",",
"append_name",
"=",
"None",
")",
":",
"precondition",
".",
"AssertOptionalType",
"(",
"append_name",
",",
"Text",
")",
"info",
"=",
"tsk_file",
".",
"info",
"res... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TSKFile.Read | Read from the file. | grr/client/grr_response_client/vfs_handlers/sleuthkit.py | def Read(self, length):
"""Read from the file."""
if not self.IsFile():
raise IOError("%s is not a file." % self.pathspec.last.path)
available = min(self.size - self.offset, length)
if available > 0:
# This raises a RuntimeError in some situations.
try:
data = self.fd.read_ran... | def Read(self, length):
"""Read from the file."""
if not self.IsFile():
raise IOError("%s is not a file." % self.pathspec.last.path)
available = min(self.size - self.offset, length)
if available > 0:
# This raises a RuntimeError in some situations.
try:
data = self.fd.read_ran... | [
"Read",
"from",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/sleuthkit.py#L306-L324 | [
"def",
"Read",
"(",
"self",
",",
"length",
")",
":",
"if",
"not",
"self",
".",
"IsFile",
"(",
")",
":",
"raise",
"IOError",
"(",
"\"%s is not a file.\"",
"%",
"self",
".",
"pathspec",
".",
"last",
".",
"path",
")",
"available",
"=",
"min",
"(",
"self... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TSKFile.Stat | Return a stat of the file. | grr/client/grr_response_client/vfs_handlers/sleuthkit.py | def Stat(self, ext_attrs=None):
"""Return a stat of the file."""
del ext_attrs # Unused.
return self.MakeStatResponse(self.fd, tsk_attribute=self.tsk_attribute) | def Stat(self, ext_attrs=None):
"""Return a stat of the file."""
del ext_attrs # Unused.
return self.MakeStatResponse(self.fd, tsk_attribute=self.tsk_attribute) | [
"Return",
"a",
"stat",
"of",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/sleuthkit.py#L326-L329 | [
"def",
"Stat",
"(",
"self",
",",
"ext_attrs",
"=",
"None",
")",
":",
"del",
"ext_attrs",
"# Unused.",
"return",
"self",
".",
"MakeStatResponse",
"(",
"self",
".",
"fd",
",",
"tsk_attribute",
"=",
"self",
".",
"tsk_attribute",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | TSKFile.ListFiles | List all the files in the directory. | grr/client/grr_response_client/vfs_handlers/sleuthkit.py | def ListFiles(self, ext_attrs=None):
"""List all the files in the directory."""
del ext_attrs # Unused.
if not self.IsDirectory():
raise IOError("%s is not a directory" % self.pathspec.CollapsePath())
for f in self.fd.as_directory():
try:
name = _DecodeUTF8WithWarning(f.info.name.... | def ListFiles(self, ext_attrs=None):
"""List all the files in the directory."""
del ext_attrs # Unused.
if not self.IsDirectory():
raise IOError("%s is not a directory" % self.pathspec.CollapsePath())
for f in self.fd.as_directory():
try:
name = _DecodeUTF8WithWarning(f.info.name.... | [
"List",
"all",
"the",
"files",
"in",
"the",
"directory",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/sleuthkit.py#L331-L357 | [
"def",
"ListFiles",
"(",
"self",
",",
"ext_attrs",
"=",
"None",
")",
":",
"del",
"ext_attrs",
"# Unused.",
"if",
"not",
"self",
".",
"IsDirectory",
"(",
")",
":",
"raise",
"IOError",
"(",
"\"%s is not a directory\"",
"%",
"self",
".",
"pathspec",
".",
"Col... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | main | Main. | grr/server/grr_response_server/bin/config_updater.py | def main(args):
"""Main."""
if args.subparser_name == "version":
version = config_server.VERSION["packageversion"]
print("GRR configuration updater {}".format(version))
return
token = config_updater_util.GetToken()
grr_config.CONFIG.AddContext(contexts.COMMAND_LINE_CONTEXT)
grr_config.CONFIG.Add... | def main(args):
"""Main."""
if args.subparser_name == "version":
version = config_server.VERSION["packageversion"]
print("GRR configuration updater {}".format(version))
return
token = config_updater_util.GetToken()
grr_config.CONFIG.AddContext(contexts.COMMAND_LINE_CONTEXT)
grr_config.CONFIG.Add... | [
"Main",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater.py#L267-L405 | [
"def",
"main",
"(",
"args",
")",
":",
"if",
"args",
".",
"subparser_name",
"==",
"\"version\"",
":",
"version",
"=",
"config_server",
".",
"VERSION",
"[",
"\"packageversion\"",
"]",
"print",
"(",
"\"GRR configuration updater {}\"",
".",
"format",
"(",
"version",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | EmailOutputPlugin.ProcessResponse | Sends an email for each response. | grr/server/grr_response_server/output_plugins/email_plugin.py | def ProcessResponse(self, state, response):
"""Sends an email for each response."""
emails_left = self.args.emails_limit - self.IncrementCounter()
if emails_left < 0:
return
if data_store.RelationalDBEnabled():
client_id = response.source.Basename()
client = data_store.REL_DB.ReadClie... | def ProcessResponse(self, state, response):
"""Sends an email for each response."""
emails_left = self.args.emails_limit - self.IncrementCounter()
if emails_left < 0:
return
if data_store.RelationalDBEnabled():
client_id = response.source.Basename()
client = data_store.REL_DB.ReadClie... | [
"Sends",
"an",
"email",
"for",
"each",
"response",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/output_plugins/email_plugin.py#L70-L109 | [
"def",
"ProcessResponse",
"(",
"self",
",",
"state",
",",
"response",
")",
":",
"emails_left",
"=",
"self",
".",
"args",
".",
"emails_limit",
"-",
"self",
".",
"IncrementCounter",
"(",
")",
"if",
"emails_left",
"<",
"0",
":",
"return",
"if",
"data_store",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBArtifactsMixin.WriteArtifact | Writes new artifact to the database. | grr/server/grr_response_server/databases/mem_artifacts.py | def WriteArtifact(self, artifact):
"""Writes new artifact to the database."""
name = str(artifact.name)
if name in self.artifacts:
raise db.DuplicatedArtifactError(name)
self.artifacts[name] = artifact.Copy() | def WriteArtifact(self, artifact):
"""Writes new artifact to the database."""
name = str(artifact.name)
if name in self.artifacts:
raise db.DuplicatedArtifactError(name)
self.artifacts[name] = artifact.Copy() | [
"Writes",
"new",
"artifact",
"to",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L16-L23 | [
"def",
"WriteArtifact",
"(",
"self",
",",
"artifact",
")",
":",
"name",
"=",
"str",
"(",
"artifact",
".",
"name",
")",
"if",
"name",
"in",
"self",
".",
"artifacts",
":",
"raise",
"db",
".",
"DuplicatedArtifactError",
"(",
"name",
")",
"self",
".",
"art... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBArtifactsMixin.ReadArtifact | Looks up an artifact with given name from the database. | grr/server/grr_response_server/databases/mem_artifacts.py | def ReadArtifact(self, name):
"""Looks up an artifact with given name from the database."""
try:
artifact = self.artifacts[name]
except KeyError:
raise db.UnknownArtifactError(name)
return artifact.Copy() | def ReadArtifact(self, name):
"""Looks up an artifact with given name from the database."""
try:
artifact = self.artifacts[name]
except KeyError:
raise db.UnknownArtifactError(name)
return artifact.Copy() | [
"Looks",
"up",
"an",
"artifact",
"with",
"given",
"name",
"from",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L25-L32 | [
"def",
"ReadArtifact",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"artifact",
"=",
"self",
".",
"artifacts",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"db",
".",
"UnknownArtifactError",
"(",
"name",
")",
"return",
"artifact",
".",
"Copy"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBArtifactsMixin.ReadAllArtifacts | Lists all artifacts that are stored in the database. | grr/server/grr_response_server/databases/mem_artifacts.py | def ReadAllArtifacts(self):
"""Lists all artifacts that are stored in the database."""
artifacts = []
for artifact in itervalues(self.artifacts):
artifacts.append(artifact.Copy())
return artifacts | def ReadAllArtifacts(self):
"""Lists all artifacts that are stored in the database."""
artifacts = []
for artifact in itervalues(self.artifacts):
artifacts.append(artifact.Copy())
return artifacts | [
"Lists",
"all",
"artifacts",
"that",
"are",
"stored",
"in",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L34-L41 | [
"def",
"ReadAllArtifacts",
"(",
"self",
")",
":",
"artifacts",
"=",
"[",
"]",
"for",
"artifact",
"in",
"itervalues",
"(",
"self",
".",
"artifacts",
")",
":",
"artifacts",
".",
"append",
"(",
"artifact",
".",
"Copy",
"(",
")",
")",
"return",
"artifacts"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | InMemoryDBArtifactsMixin.DeleteArtifact | Deletes an artifact with given name from the database. | grr/server/grr_response_server/databases/mem_artifacts.py | def DeleteArtifact(self, name):
"""Deletes an artifact with given name from the database."""
try:
del self.artifacts[name]
except KeyError:
raise db.UnknownArtifactError(name) | def DeleteArtifact(self, name):
"""Deletes an artifact with given name from the database."""
try:
del self.artifacts[name]
except KeyError:
raise db.UnknownArtifactError(name) | [
"Deletes",
"an",
"artifact",
"with",
"given",
"name",
"from",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_artifacts.py#L43-L48 | [
"def",
"DeleteArtifact",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"del",
"self",
".",
"artifacts",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"db",
".",
"UnknownArtifactError",
"(",
"name",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.StaticAdd | Adds an rdf value the queue.
Adds an rdf value to a queue. Does not require that the queue be locked, or
even open. NOTE: The caller is responsible for ensuring that the queue
exists and is of the correct type.
Args:
queue_urn: The urn of the queue to add to.
rdf_value: The rdf value to a... | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def StaticAdd(cls, queue_urn, rdf_value, mutation_pool=None):
"""Adds an rdf value the queue.
Adds an rdf value to a queue. Does not require that the queue be locked, or
even open. NOTE: The caller is responsible for ensuring that the queue
exists and is of the correct type.
Args:
queue_urn:... | def StaticAdd(cls, queue_urn, rdf_value, mutation_pool=None):
"""Adds an rdf value the queue.
Adds an rdf value to a queue. Does not require that the queue be locked, or
even open. NOTE: The caller is responsible for ensuring that the queue
exists and is of the correct type.
Args:
queue_urn:... | [
"Adds",
"an",
"rdf",
"value",
"the",
"queue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L20-L49 | [
"def",
"StaticAdd",
"(",
"cls",
",",
"queue_urn",
",",
"rdf_value",
",",
"mutation_pool",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"rdf_value",
",",
"cls",
".",
"rdf_type",
")",
":",
"raise",
"ValueError",
"(",
"\"This collection only accepts val... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.Add | Adds an rdf value to the queue.
Adds an rdf value to the queue. Does not require that the queue be locked.
Args:
rdf_value: The rdf value to add to the queue.
mutation_pool: A MutationPool object to write to.
Raises:
ValueError: rdf_value has unexpected type. | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def Add(self, rdf_value, mutation_pool=None):
"""Adds an rdf value to the queue.
Adds an rdf value to the queue. Does not require that the queue be locked.
Args:
rdf_value: The rdf value to add to the queue.
mutation_pool: A MutationPool object to write to.
Raises:
ValueError: rdf_... | def Add(self, rdf_value, mutation_pool=None):
"""Adds an rdf value to the queue.
Adds an rdf value to the queue. Does not require that the queue be locked.
Args:
rdf_value: The rdf value to add to the queue.
mutation_pool: A MutationPool object to write to.
Raises:
ValueError: rdf_... | [
"Adds",
"an",
"rdf",
"value",
"to",
"the",
"queue",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L51-L65 | [
"def",
"Add",
"(",
"self",
",",
"rdf_value",
",",
"mutation_pool",
"=",
"None",
")",
":",
"self",
".",
"StaticAdd",
"(",
"self",
".",
"urn",
",",
"rdf_value",
",",
"mutation_pool",
"=",
"mutation_pool",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.ClaimRecords | Returns and claims up to limit unclaimed records for timeout seconds.
Returns a list of records which are now "claimed", a claimed record will
generally be unavailable to be claimed until the claim times out. Note
however that in case of an unexpected timeout or other error a record might
be claimed tw... | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def ClaimRecords(self,
limit=10000,
timeout="30m",
start_time=None,
record_filter=lambda x: False,
max_filtered=1000):
"""Returns and claims up to limit unclaimed records for timeout seconds.
Returns a list of record... | def ClaimRecords(self,
limit=10000,
timeout="30m",
start_time=None,
record_filter=lambda x: False,
max_filtered=1000):
"""Returns and claims up to limit unclaimed records for timeout seconds.
Returns a list of record... | [
"Returns",
"and",
"claims",
"up",
"to",
"limit",
"unclaimed",
"records",
"for",
"timeout",
"seconds",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L67-L117 | [
"def",
"ClaimRecords",
"(",
"self",
",",
"limit",
"=",
"10000",
",",
"timeout",
"=",
"\"30m\"",
",",
"start_time",
"=",
"None",
",",
"record_filter",
"=",
"lambda",
"x",
":",
"False",
",",
"max_filtered",
"=",
"1000",
")",
":",
"if",
"not",
"self",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.RefreshClaims | Refreshes claims on records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords
timeout: The new timeout for these claims.
Raises:
LockError: If the queue is not locked. | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def RefreshClaims(self, ids, timeout="30m"):
"""Refreshes claims on records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords
timeout: The new timeout for these claims.
Raises:
LockError: If the queue is not locked.
"""
with data_store.DB.GetMutationPool() as... | def RefreshClaims(self, ids, timeout="30m"):
"""Refreshes claims on records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords
timeout: The new timeout for these claims.
Raises:
LockError: If the queue is not locked.
"""
with data_store.DB.GetMutationPool() as... | [
"Refreshes",
"claims",
"on",
"records",
"identified",
"by",
"ids",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L119-L132 | [
"def",
"RefreshClaims",
"(",
"self",
",",
"ids",
",",
"timeout",
"=",
"\"30m\"",
")",
":",
"with",
"data_store",
".",
"DB",
".",
"GetMutationPool",
"(",
")",
"as",
"mutation_pool",
":",
"mutation_pool",
".",
"QueueRefreshClaims",
"(",
"ids",
",",
"timeout",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.DeleteRecords | Delete records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to delete with.
Raises:
LockError: If the queue is not locked. | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def DeleteRecords(cls, ids, token):
"""Delete records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to delete with.
Raises:
LockError: If the queue is not locked.
"""
with data_store.DB.GetMutationPool() as mutation_pool:
... | def DeleteRecords(cls, ids, token):
"""Delete records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to delete with.
Raises:
LockError: If the queue is not locked.
"""
with data_store.DB.GetMutationPool() as mutation_pool:
... | [
"Delete",
"records",
"identified",
"by",
"ids",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L135-L146 | [
"def",
"DeleteRecords",
"(",
"cls",
",",
"ids",
",",
"token",
")",
":",
"with",
"data_store",
".",
"DB",
".",
"GetMutationPool",
"(",
")",
"as",
"mutation_pool",
":",
"mutation_pool",
".",
"QueueDeleteRecords",
"(",
"ids",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Queue.ReleaseRecords | Release records identified by subjects.
Releases any claim on the records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to write with.
Raises:
LockError: If the queue is not locked. | grr/server/grr_response_server/aff4_objects/aff4_queue.py | def ReleaseRecords(cls, ids, token):
"""Release records identified by subjects.
Releases any claim on the records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to write with.
Raises:
LockError: If the queue is not locked.
... | def ReleaseRecords(cls, ids, token):
"""Release records identified by subjects.
Releases any claim on the records identified by ids.
Args:
ids: A list of ids provided by ClaimRecords.
token: The database access token to write with.
Raises:
LockError: If the queue is not locked.
... | [
"Release",
"records",
"identified",
"by",
"subjects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/aff4_queue.py#L154-L167 | [
"def",
"ReleaseRecords",
"(",
"cls",
",",
"ids",
",",
"token",
")",
":",
"with",
"data_store",
".",
"DB",
".",
"GetMutationPool",
"(",
")",
"as",
"mutation_pool",
":",
"mutation_pool",
".",
"QueueReleaseRecords",
"(",
"ids",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ChromeHistoryParser.Parse | Parse the History file. | grr/core/grr_response_core/lib/parsers/chrome_history.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the History file."""
_ = knowledge_base
# TODO(user): Convert this to use the far more intelligent plaso parser.
chrome = ChromeParser(file_object)
for timestamp, entry_type, url, data1, _, _ in chrome.Parse():
if entry_type == "CHRO... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the History file."""
_ = knowledge_base
# TODO(user): Convert this to use the far more intelligent plaso parser.
chrome = ChromeParser(file_object)
for timestamp, entry_type, url, data1, _, _ in chrome.Parse():
if entry_type == "CHRO... | [
"Parse",
"the",
"History",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/chrome_history.py#L25-L46 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
"=",
"knowledge_base",
"# TODO(user): Convert this to use the far more intelligent plaso parser.",
"chrome",
"=",
"ChromeParser",
"(",
"file_object",
")",
"for",
"timesta... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ChromeParser.Parse | Iterator returning a list for each entry in history.
We store all the download events in an array (choosing this over visits
since there are likely to be less of them). We later interleave them with
visit events to get an overall correct time order.
Yields:
a list of attributes for each entry | grr/core/grr_response_core/lib/parsers/chrome_history.py | def Parse(self):
"""Iterator returning a list for each entry in history.
We store all the download events in an array (choosing this over visits
since there are likely to be less of them). We later interleave them with
visit events to get an overall correct time order.
Yields:
a list of attr... | def Parse(self):
"""Iterator returning a list for each entry in history.
We store all the download events in an array (choosing this over visits
since there are likely to be less of them). We later interleave them with
visit events to get an overall correct time order.
Yields:
a list of attr... | [
"Iterator",
"returning",
"a",
"list",
"for",
"each",
"entry",
"in",
"history",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/chrome_history.py#L95-L121 | [
"def",
"Parse",
"(",
"self",
")",
":",
"# Query for old style and newstyle downloads storage.",
"query_iter",
"=",
"itertools",
".",
"chain",
"(",
"self",
".",
"Query",
"(",
"self",
".",
"DOWNLOADS_QUERY",
")",
",",
"self",
".",
"Query",
"(",
"self",
".",
"DOW... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientURN.ParseFromUnicode | Parse a string into a client URN.
Convert case so that all URNs are of the form C.[0-9a-f].
Args:
value: string value to parse | grr/core/grr_response_core/lib/rdfvalues/client.py | def ParseFromUnicode(self, value):
"""Parse a string into a client URN.
Convert case so that all URNs are of the form C.[0-9a-f].
Args:
value: string value to parse
"""
precondition.AssertType(value, Text)
value = value.strip()
super(ClientURN, self).ParseFromUnicode(value)
mat... | def ParseFromUnicode(self, value):
"""Parse a string into a client URN.
Convert case so that all URNs are of the form C.[0-9a-f].
Args:
value: string value to parse
"""
precondition.AssertType(value, Text)
value = value.strip()
super(ClientURN, self).ParseFromUnicode(value)
mat... | [
"Parse",
"a",
"string",
"into",
"a",
"client",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L77-L98 | [
"def",
"ParseFromUnicode",
"(",
"self",
",",
"value",
")",
":",
"precondition",
".",
"AssertType",
"(",
"value",
",",
"Text",
")",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"super",
"(",
"ClientURN",
",",
"self",
")",
".",
"ParseFromUnicode",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientURN.FromPublicKey | An alternate constructor which generates a new client id. | grr/core/grr_response_core/lib/rdfvalues/client.py | def FromPublicKey(cls, public_key):
"""An alternate constructor which generates a new client id."""
# Our CN will be the first 64 bits of the hash of the public key
# in MPI format - the length of the key in 4 bytes + the key
# prefixed with a 0. This weird format is an artifact from the way
# M2Cry... | def FromPublicKey(cls, public_key):
"""An alternate constructor which generates a new client id."""
# Our CN will be the first 64 bits of the hash of the public key
# in MPI format - the length of the key in 4 bytes + the key
# prefixed with a 0. This weird format is an artifact from the way
# M2Cry... | [
"An",
"alternate",
"constructor",
"which",
"generates",
"a",
"new",
"client",
"id",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L112-L124 | [
"def",
"FromPublicKey",
"(",
"cls",
",",
"public_key",
")",
":",
"# Our CN will be the first 64 bits of the hash of the public key",
"# in MPI format - the length of the key in 4 bytes + the key",
"# prefixed with a 0. This weird format is an artifact from the way",
"# M2Crypto handled this, w... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ClientURN.Add | Add a relative stem to the current value and return a new RDFURN.
Note that this returns an RDFURN, not a ClientURN since the resulting object
would not pass validation.
Args:
path: A string containing a relative path.
age: The age of the object. If None set to current time.
Returns:
... | grr/core/grr_response_core/lib/rdfvalues/client.py | def Add(self, path, age=None):
"""Add a relative stem to the current value and return a new RDFURN.
Note that this returns an RDFURN, not a ClientURN since the resulting object
would not pass validation.
Args:
path: A string containing a relative path.
age: The age of the object. If None s... | def Add(self, path, age=None):
"""Add a relative stem to the current value and return a new RDFURN.
Note that this returns an RDFURN, not a ClientURN since the resulting object
would not pass validation.
Args:
path: A string containing a relative path.
age: The age of the object. If None s... | [
"Add",
"a",
"relative",
"stem",
"to",
"the",
"current",
"value",
"and",
"return",
"a",
"new",
"RDFURN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L126-L148 | [
"def",
"Add",
"(",
"self",
",",
"path",
",",
"age",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"path",
",",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Only strings should be added to a URN.\"",
")",
"result",
"=",
"rdfvalue",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | KnowledgeBase.MergeOrAddUser | Merge a user into existing users or add new if it doesn't exist.
Args:
kb_user: A User rdfvalue.
Returns:
A list of strings with the set attribute names, e.g. ["users.sid"] | grr/core/grr_response_core/lib/rdfvalues/client.py | def MergeOrAddUser(self, kb_user):
"""Merge a user into existing users or add new if it doesn't exist.
Args:
kb_user: A User rdfvalue.
Returns:
A list of strings with the set attribute names, e.g. ["users.sid"]
"""
user = self.GetUser(
sid=kb_user.sid, uid=kb_user.uid, usernam... | def MergeOrAddUser(self, kb_user):
"""Merge a user into existing users or add new if it doesn't exist.
Args:
kb_user: A User rdfvalue.
Returns:
A list of strings with the set attribute names, e.g. ["users.sid"]
"""
user = self.GetUser(
sid=kb_user.sid, uid=kb_user.uid, usernam... | [
"Merge",
"a",
"user",
"into",
"existing",
"users",
"or",
"add",
"new",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L245-L268 | [
"def",
"MergeOrAddUser",
"(",
"self",
",",
"kb_user",
")",
":",
"user",
"=",
"self",
".",
"GetUser",
"(",
"sid",
"=",
"kb_user",
".",
"sid",
",",
"uid",
"=",
"kb_user",
".",
"uid",
",",
"username",
"=",
"kb_user",
".",
"username",
")",
"new_attrs",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | KnowledgeBase.GetUser | Retrieve a User based on sid, uid or username.
On windows we first get a SID and use it to find the username. We want to
avoid combining users with name collisions, which occur when local users
have the same username as domain users (something like Admin is particularly
common). So if a SID is provid... | grr/core/grr_response_core/lib/rdfvalues/client.py | def GetUser(self, sid=None, uid=None, username=None):
"""Retrieve a User based on sid, uid or username.
On windows we first get a SID and use it to find the username. We want to
avoid combining users with name collisions, which occur when local users
have the same username as domain users (something l... | def GetUser(self, sid=None, uid=None, username=None):
"""Retrieve a User based on sid, uid or username.
On windows we first get a SID and use it to find the username. We want to
avoid combining users with name collisions, which occur when local users
have the same username as domain users (something l... | [
"Retrieve",
"a",
"User",
"based",
"on",
"sid",
"uid",
"or",
"username",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L270-L311 | [
"def",
"GetUser",
"(",
"self",
",",
"sid",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"if",
"sid",
":",
"for",
"user",
"in",
"self",
".",
"users",
":",
"if",
"user",
".",
"sid",
"==",
"sid",
":",
"return",
"us... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Uname.arch | Return a more standard representation of the architecture. | grr/core/grr_response_core/lib/rdfvalues/client.py | def arch(self):
"""Return a more standard representation of the architecture."""
if self.machine in ["x86_64", "AMD64", "i686"]:
# 32 bit binaries running on AMD64 will still have a i386 arch.
if self.architecture == "32bit":
return "i386"
return "amd64"
elif self.machine == "x86"... | def arch(self):
"""Return a more standard representation of the architecture."""
if self.machine in ["x86_64", "AMD64", "i686"]:
# 32 bit binaries running on AMD64 will still have a i386 arch.
if self.architecture == "32bit":
return "i386"
return "amd64"
elif self.machine == "x86"... | [
"Return",
"a",
"more",
"standard",
"representation",
"of",
"the",
"architecture",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L510-L521 | [
"def",
"arch",
"(",
"self",
")",
":",
"if",
"self",
".",
"machine",
"in",
"[",
"\"x86_64\"",
",",
"\"AMD64\"",
",",
"\"i686\"",
"]",
":",
"# 32 bit binaries running on AMD64 will still have a i386 arch.",
"if",
"self",
".",
"architecture",
"==",
"\"32bit\"",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Uname.FromCurrentSystem | Fill a Uname from the currently running platform. | grr/core/grr_response_core/lib/rdfvalues/client.py | def FromCurrentSystem(cls):
"""Fill a Uname from the currently running platform."""
uname = platform.uname()
fqdn = socket.getfqdn()
system = uname[0]
architecture, _ = platform.architecture()
if system == "Windows":
service_pack = platform.win32_ver()[2]
kernel = uname[3] # 5.1.260... | def FromCurrentSystem(cls):
"""Fill a Uname from the currently running platform."""
uname = platform.uname()
fqdn = socket.getfqdn()
system = uname[0]
architecture, _ = platform.architecture()
if system == "Windows":
service_pack = platform.win32_ver()[2]
kernel = uname[3] # 5.1.260... | [
"Fill",
"a",
"Uname",
"from",
"the",
"currently",
"running",
"platform",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client.py#L534-L572 | [
"def",
"FromCurrentSystem",
"(",
"cls",
")",
":",
"uname",
"=",
"platform",
".",
"uname",
"(",
")",
"fqdn",
"=",
"socket",
".",
"getfqdn",
"(",
")",
"system",
"=",
"uname",
"[",
"0",
"]",
"architecture",
",",
"_",
"=",
"platform",
".",
"architecture",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IEHistoryParser.Parse | Parse the History file. | grr/core/grr_response_core/lib/parsers/ie_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.
ie = IEParser(file_object)
for dat in ie.Parse():
yield rdf_webhistory.BrowserHistoryItem(
url=dat["u... | 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.
ie = IEParser(file_object)
for dat in ie.Parse():
yield rdf_webhistory.BrowserHistoryItem(
url=dat["u... | [
"Parse",
"the",
"History",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/ie_history.py#L35-L46 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
",",
"_",
"=",
"stat",
",",
"knowledge_base",
"# TODO(user): Convert this to use the far more intelligent plaso parser.",
"ie",
"=",
"IEParser",
"(",
"file_object",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IEParser.Parse | Parse the file. | grr/core/grr_response_core/lib/parsers/ie_history.py | def Parse(self):
"""Parse the file."""
if not self._file:
logging.error("Couldn't open file")
return
# Limit read size to 5MB.
self.input_dat = self._file.read(1024 * 1024 * 5)
if not self.input_dat.startswith(self.FILE_HEADER):
logging.error("Invalid index.dat file %s", self._fil... | def Parse(self):
"""Parse the file."""
if not self._file:
logging.error("Couldn't open file")
return
# Limit read size to 5MB.
self.input_dat = self._file.read(1024 * 1024 * 5)
if not self.input_dat.startswith(self.FILE_HEADER):
logging.error("Invalid index.dat file %s", self._fil... | [
"Parse",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/ie_history.py#L72-L91 | [
"def",
"Parse",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_file",
":",
"logging",
".",
"error",
"(",
"\"Couldn't open file\"",
")",
"return",
"# Limit read size to 5MB.",
"self",
".",
"input_dat",
"=",
"self",
".",
"_file",
".",
"read",
"(",
"1024"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IEParser._GetRecord | Retrieve a single record from the file.
Args:
offset: offset from start of input_dat where header starts
record_size: length of the header according to file (untrusted)
Returns:
A dict containing a single browser history record. | grr/core/grr_response_core/lib/parsers/ie_history.py | def _GetRecord(self, offset, record_size):
"""Retrieve a single record from the file.
Args:
offset: offset from start of input_dat where header starts
record_size: length of the header according to file (untrusted)
Returns:
A dict containing a single browser history record.
"""
r... | def _GetRecord(self, offset, record_size):
"""Retrieve a single record from the file.
Args:
offset: offset from start of input_dat where header starts
record_size: length of the header according to file (untrusted)
Returns:
A dict containing a single browser history record.
"""
r... | [
"Retrieve",
"a",
"single",
"record",
"from",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/ie_history.py#L93-L135 | [
"def",
"_GetRecord",
"(",
"self",
",",
"offset",
",",
"record_size",
")",
":",
"record_header",
"=",
"\"<4sLQQL\"",
"get4",
"=",
"lambda",
"x",
":",
"struct",
".",
"unpack",
"(",
"\"<L\"",
",",
"self",
".",
"input_dat",
"[",
"x",
":",
"x",
"+",
"4",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IEParser._DoParse | Parse a file for history records yielding dicts.
Yields:
Dicts containing browser history | grr/core/grr_response_core/lib/parsers/ie_history.py | def _DoParse(self):
"""Parse a file for history records yielding dicts.
Yields:
Dicts containing browser history
"""
get4 = lambda x: struct.unpack("<L", self.input_dat[x:x + 4])[0]
filesize = get4(0x1c)
offset = get4(0x20)
coffset = offset
while coffset < filesize:
etype = ... | def _DoParse(self):
"""Parse a file for history records yielding dicts.
Yields:
Dicts containing browser history
"""
get4 = lambda x: struct.unpack("<L", self.input_dat[x:x + 4])[0]
filesize = get4(0x1c)
offset = get4(0x20)
coffset = offset
while coffset < filesize:
etype = ... | [
"Parse",
"a",
"file",
"for",
"history",
"records",
"yielding",
"dicts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/ie_history.py#L137-L155 | [
"def",
"_DoParse",
"(",
"self",
")",
":",
"get4",
"=",
"lambda",
"x",
":",
"struct",
".",
"unpack",
"(",
"\"<L\"",
",",
"self",
".",
"input_dat",
"[",
"x",
":",
"x",
"+",
"4",
"]",
")",
"[",
"0",
"]",
"filesize",
"=",
"get4",
"(",
"0x1c",
")",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GenerateCSRFKey | Update a config with a random csrf key. | grr/server/grr_response_server/bin/config_updater_keys_util.py | def _GenerateCSRFKey(config):
"""Update a config with a random csrf key."""
secret_key = config.Get("AdminUI.csrf_secret_key", None)
if not secret_key:
# TODO(amoser): Remove support for django_secret_key.
secret_key = config.Get("AdminUI.django_secret_key", None)
if secret_key:
config.Set("Admi... | def _GenerateCSRFKey(config):
"""Update a config with a random csrf key."""
secret_key = config.Get("AdminUI.csrf_secret_key", None)
if not secret_key:
# TODO(amoser): Remove support for django_secret_key.
secret_key = config.Get("AdminUI.django_secret_key", None)
if secret_key:
config.Set("Admi... | [
"Update",
"a",
"config",
"with",
"a",
"random",
"csrf",
"key",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_keys_util.py#L26-L39 | [
"def",
"_GenerateCSRFKey",
"(",
"config",
")",
":",
"secret_key",
"=",
"config",
".",
"Get",
"(",
"\"AdminUI.csrf_secret_key\"",
",",
"None",
")",
"if",
"not",
"secret_key",
":",
"# TODO(amoser): Remove support for django_secret_key.",
"secret_key",
"=",
"config",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GenerateKeys | Generate the keys we need for a GRR server. | grr/server/grr_response_server/bin/config_updater_keys_util.py | def GenerateKeys(config, overwrite_keys=False):
"""Generate the keys we need for a GRR server."""
if not hasattr(key_utils, "MakeCACert"):
raise OpenSourceKeyUtilsRequiredError(
"Generate keys can only run with open source key_utils.")
if (config.Get("PrivateKeys.server_key", default=None) and
n... | def GenerateKeys(config, overwrite_keys=False):
"""Generate the keys we need for a GRR server."""
if not hasattr(key_utils, "MakeCACert"):
raise OpenSourceKeyUtilsRequiredError(
"Generate keys can only run with open source key_utils.")
if (config.Get("PrivateKeys.server_key", default=None) and
n... | [
"Generate",
"the",
"keys",
"we",
"need",
"for",
"a",
"GRR",
"server",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_keys_util.py#L42-L76 | [
"def",
"GenerateKeys",
"(",
"config",
",",
"overwrite_keys",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"key_utils",
",",
"\"MakeCACert\"",
")",
":",
"raise",
"OpenSourceKeyUtilsRequiredError",
"(",
"\"Generate keys can only run with open source key_utils.\"",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ProcessIterator | Yields all (psutil-) processes that match certain criteria.
Args:
pids: A list of pids. If given, only the processes with those pids are
returned.
process_regex_string: If given, only processes whose name matches the regex
are returned.
ignore_grr_process: If True, the grr process itself will... | grr/client/grr_response_client/client_actions/memory.py | def ProcessIterator(pids, process_regex_string, ignore_grr_process, error_list):
"""Yields all (psutil-) processes that match certain criteria.
Args:
pids: A list of pids. If given, only the processes with those pids are
returned.
process_regex_string: If given, only processes whose name matches the ... | def ProcessIterator(pids, process_regex_string, ignore_grr_process, error_list):
"""Yields all (psutil-) processes that match certain criteria.
Args:
pids: A list of pids. If given, only the processes with those pids are
returned.
process_regex_string: If given, only processes whose name matches the ... | [
"Yields",
"all",
"(",
"psutil",
"-",
")",
"processes",
"that",
"match",
"certain",
"criteria",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/memory.py#L26-L71 | [
"def",
"ProcessIterator",
"(",
"pids",
",",
"process_regex_string",
",",
"ignore_grr_process",
",",
"error_list",
")",
":",
"pids",
"=",
"set",
"(",
"pids",
")",
"if",
"ignore_grr_process",
":",
"grr_pid",
"=",
"psutil",
".",
"Process",
"(",
")",
".",
"pid",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.Get | Fetch flow's data and return proper Flow object. | api_client/python/grr_api_client/flow.py | def Get(self):
"""Fetch flow's data and return proper Flow object."""
args = flow_pb2.ApiGetFlowArgs(
client_id=self.client_id, flow_id=self.flow_id)
data = self._context.SendRequest("GetFlow", args)
return Flow(data=data, context=self._context) | def Get(self):
"""Fetch flow's data and return proper Flow object."""
args = flow_pb2.ApiGetFlowArgs(
client_id=self.client_id, flow_id=self.flow_id)
data = self._context.SendRequest("GetFlow", args)
return Flow(data=data, context=self._context) | [
"Fetch",
"flow",
"s",
"data",
"and",
"return",
"proper",
"Flow",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/flow.py#L85-L91 | [
"def",
"Get",
"(",
"self",
")",
":",
"args",
"=",
"flow_pb2",
".",
"ApiGetFlowArgs",
"(",
"client_id",
"=",
"self",
".",
"client_id",
",",
"flow_id",
"=",
"self",
".",
"flow_id",
")",
"data",
"=",
"self",
".",
"_context",
".",
"SendRequest",
"(",
"\"Ge... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowBase.WaitUntilDone | Wait until the flow completes.
Args:
timeout: timeout in seconds. None means default timeout (1 hour). 0 means
no timeout (wait forever).
Returns:
Fresh flow object.
Raises:
PollTimeoutError: if timeout is reached.
FlowFailedError: if the flow is not successful. | api_client/python/grr_api_client/flow.py | def WaitUntilDone(self, timeout=None):
"""Wait until the flow completes.
Args:
timeout: timeout in seconds. None means default timeout (1 hour). 0 means
no timeout (wait forever).
Returns:
Fresh flow object.
Raises:
PollTimeoutError: if timeout is reached.
FlowFailedErr... | def WaitUntilDone(self, timeout=None):
"""Wait until the flow completes.
Args:
timeout: timeout in seconds. None means default timeout (1 hour). 0 means
no timeout (wait forever).
Returns:
Fresh flow object.
Raises:
PollTimeoutError: if timeout is reached.
FlowFailedErr... | [
"Wait",
"until",
"the",
"flow",
"completes",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/flow.py#L93-L115 | [
"def",
"WaitUntilDone",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"f",
"=",
"utils",
".",
"Poll",
"(",
"generator",
"=",
"self",
".",
"Get",
",",
"condition",
"=",
"lambda",
"f",
":",
"f",
".",
"data",
".",
"state",
"!=",
"f",
".",
"dat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FingerprintResponse.GetFingerprint | Gets the first fingerprint type from the protobuf. | grr/core/grr_response_core/lib/rdfvalues/client_action.py | def GetFingerprint(self, name):
"""Gets the first fingerprint type from the protobuf."""
for result in self.results:
if result.GetItem("name") == name:
return result | def GetFingerprint(self, name):
"""Gets the first fingerprint type from the protobuf."""
for result in self.results:
if result.GetItem("name") == name:
return result | [
"Gets",
"the",
"first",
"fingerprint",
"type",
"from",
"the",
"protobuf",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_action.py#L121-L125 | [
"def",
"GetFingerprint",
"(",
"self",
",",
"name",
")",
":",
"for",
"result",
"in",
"self",
".",
"results",
":",
"if",
"result",
".",
"GetItem",
"(",
"\"name\"",
")",
"==",
"name",
":",
"return",
"result"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.InitializeContext | Initializes the context of this flow. | grr/server/grr_response_server/flow_runner.py | def InitializeContext(self, args):
"""Initializes the context of this flow."""
if args is None:
args = rdf_flow_runner.FlowRunnerArgs()
output_plugins_states = []
for plugin_descriptor in args.output_plugins:
if not args.client_id:
self.Log(
"Not initializing output plug... | def InitializeContext(self, args):
"""Initializes the context of this flow."""
if args is None:
args = rdf_flow_runner.FlowRunnerArgs()
output_plugins_states = []
for plugin_descriptor in args.output_plugins:
if not args.client_id:
self.Log(
"Not initializing output plug... | [
"Initializes",
"the",
"context",
"of",
"this",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L200-L243 | [
"def",
"InitializeContext",
"(",
"self",
",",
"args",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"rdf_flow_runner",
".",
"FlowRunnerArgs",
"(",
")",
"output_plugins_states",
"=",
"[",
"]",
"for",
"plugin_descriptor",
"in",
"args",
".",
"output_p... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.GetNewSessionID | Returns a random session ID for this flow based on the runner args.
Returns:
A formatted session id URN. | grr/server/grr_response_server/flow_runner.py | def GetNewSessionID(self):
"""Returns a random session ID for this flow based on the runner args.
Returns:
A formatted session id URN.
"""
# Calculate a new session id based on the flow args. Note that our caller
# can specify the base path to the session id, but they can not influence
# ... | def GetNewSessionID(self):
"""Returns a random session ID for this flow based on the runner args.
Returns:
A formatted session id URN.
"""
# Calculate a new session id based on the flow args. Note that our caller
# can specify the base path to the session id, but they can not influence
# ... | [
"Returns",
"a",
"random",
"session",
"ID",
"for",
"this",
"flow",
"based",
"on",
"the",
"runner",
"args",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L245-L260 | [
"def",
"GetNewSessionID",
"(",
"self",
")",
":",
"# Calculate a new session id based on the flow args. Note that our caller",
"# can specify the base path to the session id, but they can not influence",
"# the exact session id we pick. This ensures that callers can not engineer a",
"# session id c... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.CallState | This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.
start_time: Start the flow at this time. This delays... | grr/server/grr_response_server/flow_runner.py | def CallState(self, next_state="", start_time=None):
"""This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.... | def CallState(self, next_state="", start_time=None):
"""This method is used to schedule a new state on a different worker.
This is basically the same as CallFlow() except we are calling
ourselves. The state will be invoked at a later time.
Args:
next_state: The state in this flow to be invoked.... | [
"This",
"method",
"is",
"used",
"to",
"schedule",
"a",
"new",
"state",
"on",
"a",
"different",
"worker",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L272-L311 | [
"def",
"CallState",
"(",
"self",
",",
"next_state",
"=",
"\"\"",
",",
"start_time",
"=",
"None",
")",
":",
"# Check if the state is valid",
"if",
"not",
"getattr",
"(",
"self",
".",
"flow_obj",
",",
"next_state",
")",
":",
"raise",
"FlowRunnerError",
"(",
"\... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.ScheduleKillNotification | Schedules a kill notification for this flow. | grr/server/grr_response_server/flow_runner.py | def ScheduleKillNotification(self):
"""Schedules a kill notification for this flow."""
# Create a notification for the flow in the future that
# indicates that this flow is in progess. We'll delete this
# notification when we're done with processing completed
# requests. If we're stuck for some reas... | def ScheduleKillNotification(self):
"""Schedules a kill notification for this flow."""
# Create a notification for the flow in the future that
# indicates that this flow is in progess. We'll delete this
# notification when we're done with processing completed
# requests. If we're stuck for some reas... | [
"Schedules",
"a",
"kill",
"notification",
"for",
"this",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L313-L330 | [
"def",
"ScheduleKillNotification",
"(",
"self",
")",
":",
"# Create a notification for the flow in the future that",
"# indicates that this flow is in progess. We'll delete this",
"# notification when we're done with processing completed",
"# requests. If we're stuck for some reason, the notificat... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.ProcessCompletedRequests | Go through the list of requests and process the completed ones.
We take a snapshot in time of all requests and responses for this flow. We
then process as many completed requests as possible. If responses are not
quite here we leave it for next time.
It is safe to call this function as many times as n... | grr/server/grr_response_server/flow_runner.py | def ProcessCompletedRequests(self, notification, unused_thread_pool=None):
"""Go through the list of requests and process the completed ones.
We take a snapshot in time of all requests and responses for this flow. We
then process as many completed requests as possible. If responses are not
quite here w... | def ProcessCompletedRequests(self, notification, unused_thread_pool=None):
"""Go through the list of requests and process the completed ones.
We take a snapshot in time of all requests and responses for this flow. We
then process as many completed requests as possible. If responses are not
quite here w... | [
"Go",
"through",
"the",
"list",
"of",
"requests",
"and",
"process",
"the",
"completed",
"ones",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L377-L396 | [
"def",
"ProcessCompletedRequests",
"(",
"self",
",",
"notification",
",",
"unused_thread_pool",
"=",
"None",
")",
":",
"self",
".",
"ScheduleKillNotification",
"(",
")",
"try",
":",
"self",
".",
"_ProcessCompletedRequests",
"(",
"notification",
")",
"finally",
":"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner._ProcessCompletedRequests | Does the actual processing of the completed requests. | grr/server/grr_response_server/flow_runner.py | def _ProcessCompletedRequests(self, notification):
"""Does the actual processing of the completed requests."""
# First ensure that client messages are all removed. NOTE: We make a new
# queue manager here because we want only the client messages to be removed
# ASAP. This must happen before we actually ... | def _ProcessCompletedRequests(self, notification):
"""Does the actual processing of the completed requests."""
# First ensure that client messages are all removed. NOTE: We make a new
# queue manager here because we want only the client messages to be removed
# ASAP. This must happen before we actually ... | [
"Does",
"the",
"actual",
"processing",
"of",
"the",
"completed",
"requests",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L398-L513 | [
"def",
"_ProcessCompletedRequests",
"(",
"self",
",",
"notification",
")",
":",
"# First ensure that client messages are all removed. NOTE: We make a new",
"# queue manager here because we want only the client messages to be removed",
"# ASAP. This must happen before we actually run the flow to ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.RunStateMethod | Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of GrrMessages responding to the request. | grr/server/grr_response_server/flow_runner.py | def RunStateMethod(self, method_name, request=None, responses=None):
"""Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of GrrMessages responding to the request.
"""
if self... | def RunStateMethod(self, method_name, request=None, responses=None):
"""Completes the request by calling the state method.
Args:
method_name: The name of the state method to call.
request: A RequestState protobuf.
responses: A list of GrrMessages responding to the request.
"""
if self... | [
"Completes",
"the",
"request",
"by",
"calling",
"the",
"state",
"method",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L524-L586 | [
"def",
"RunStateMethod",
"(",
"self",
",",
"method_name",
",",
"request",
"=",
"None",
",",
"responses",
"=",
"None",
")",
":",
"if",
"self",
".",
"_TerminationPending",
"(",
")",
":",
"return",
"client_id",
"=",
"None",
"try",
":",
"self",
".",
"context... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.CallClient | Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run
action may send back many responses. These will be queued by the
framework until a status message is sent by the client. The status
message will cause the entire transaction to be committed to the
speci... | grr/server/grr_response_server/flow_runner.py | def CallClient(self,
action_cls,
request=None,
next_state=None,
request_data=None,
**kwargs):
"""Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run
action may send back many re... | def CallClient(self,
action_cls,
request=None,
next_state=None,
request_data=None,
**kwargs):
"""Calls the client asynchronously.
This sends a message to the client to invoke an Action. The run
action may send back many re... | [
"Calls",
"the",
"client",
"asynchronously",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L594-L689 | [
"def",
"CallClient",
"(",
"self",
",",
"action_cls",
",",
"request",
"=",
"None",
",",
"next_state",
"=",
"None",
",",
"request_data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client_id",
"=",
"self",
".",
"runner_args",
".",
"client_id",
"if",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.CallFlow | Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send back many responses which will be
queued by the framework until the flow terminates. The final status message
will cause the entire transaction to be committed to the specified state.
Args:
flow_nam... | grr/server/grr_response_server/flow_runner.py | def CallFlow(self,
flow_name=None,
next_state=None,
request_data=None,
client_id=None,
base_session_id=None,
**kwargs):
"""Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send b... | def CallFlow(self,
flow_name=None,
next_state=None,
request_data=None,
client_id=None,
base_session_id=None,
**kwargs):
"""Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send b... | [
"Creates",
"a",
"new",
"flow",
"and",
"send",
"its",
"responses",
"to",
"a",
"state",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L691-L772 | [
"def",
"CallFlow",
"(",
"self",
",",
"flow_name",
"=",
"None",
",",
"next_state",
"=",
"None",
",",
"request_data",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"base_session_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client_id",
"=",
"c... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.SendReply | Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with the following tag. NOTE: supported
in REL_DB implementation only.
... | grr/server/grr_response_server/flow_runner.py | def SendReply(self, response, tag=None):
"""Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with the following tag. NOTE: suppo... | def SendReply(self, response, tag=None):
"""Allows this flow to send a message to its parent flow.
If this flow does not have a parent, the message is ignored.
Args:
response: An RDFValue() instance to be sent to the parent.
tag: If specified, tag the result with the following tag. NOTE: suppo... | [
"Allows",
"this",
"flow",
"to",
"send",
"a",
"message",
"to",
"its",
"parent",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L774-L819 | [
"def",
"SendReply",
"(",
"self",
",",
"response",
",",
"tag",
"=",
"None",
")",
":",
"del",
"tag",
"if",
"not",
"isinstance",
"(",
"response",
",",
"rdfvalue",
".",
"RDFValue",
")",
":",
"raise",
"ValueError",
"(",
"\"SendReply can only send a Semantic Value\"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.Error | Terminates this flow with an error. | grr/server/grr_response_server/flow_runner.py | def Error(self, backtrace, client_id=None, status_code=None):
"""Terminates this flow with an error."""
try:
self.queue_manager.DestroyFlowStates(self.session_id)
except queue_manager.MoreDataException:
pass
if not self.IsRunning():
return
# Set an error status
reply = rdf_fl... | def Error(self, backtrace, client_id=None, status_code=None):
"""Terminates this flow with an error."""
try:
self.queue_manager.DestroyFlowStates(self.session_id)
except queue_manager.MoreDataException:
pass
if not self.IsRunning():
return
# Set an error status
reply = rdf_fl... | [
"Terminates",
"this",
"flow",
"with",
"an",
"error",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L837-L881 | [
"def",
"Error",
"(",
"self",
",",
"backtrace",
",",
"client_id",
"=",
"None",
",",
"status_code",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"queue_manager",
".",
"DestroyFlowStates",
"(",
"self",
".",
"session_id",
")",
"except",
"queue_manager",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.ProcessRepliesWithOutputPlugins | Processes replies with output plugins. | grr/server/grr_response_server/flow_runner.py | def ProcessRepliesWithOutputPlugins(self, replies):
"""Processes replies with output plugins."""
for output_plugin_state in self.context.output_plugins_states:
plugin_descriptor = output_plugin_state.plugin_descriptor
output_plugin_cls = plugin_descriptor.GetPluginClass()
output_plugin = outpu... | def ProcessRepliesWithOutputPlugins(self, replies):
"""Processes replies with output plugins."""
for output_plugin_state in self.context.output_plugins_states:
plugin_descriptor = output_plugin_state.plugin_descriptor
output_plugin_cls = plugin_descriptor.GetPluginClass()
output_plugin = outpu... | [
"Processes",
"replies",
"with",
"output",
"plugins",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L893-L928 | [
"def",
"ProcessRepliesWithOutputPlugins",
"(",
"self",
",",
"replies",
")",
":",
"for",
"output_plugin_state",
"in",
"self",
".",
"context",
".",
"output_plugins_states",
":",
"plugin_descriptor",
"=",
"output_plugin_state",
".",
"plugin_descriptor",
"output_plugin_cls",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner._SendTerminationMessage | This notifies the parent flow of our termination. | grr/server/grr_response_server/flow_runner.py | def _SendTerminationMessage(self, status=None):
"""This notifies the parent flow of our termination."""
if not self.runner_args.request_state.session_id:
# No parent flow, nothing to do here.
return
if status is None:
status = rdf_flows.GrrStatus()
client_resources = self.context.cli... | def _SendTerminationMessage(self, status=None):
"""This notifies the parent flow of our termination."""
if not self.runner_args.request_state.session_id:
# No parent flow, nothing to do here.
return
if status is None:
status = rdf_flows.GrrStatus()
client_resources = self.context.cli... | [
"This",
"notifies",
"the",
"parent",
"flow",
"of",
"our",
"termination",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L930-L961 | [
"def",
"_SendTerminationMessage",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"runner_args",
".",
"request_state",
".",
"session_id",
":",
"# No parent flow, nothing to do here.",
"return",
"if",
"status",
"is",
"None",
":",
"sta... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.Terminate | Terminates this flow. | grr/server/grr_response_server/flow_runner.py | def Terminate(self, status=None):
"""Terminates this flow."""
try:
self.queue_manager.DestroyFlowStates(self.session_id)
except queue_manager.MoreDataException:
pass
# This flow might already not be running.
if not self.IsRunning():
return
self._SendTerminationMessage(status=... | def Terminate(self, status=None):
"""Terminates this flow."""
try:
self.queue_manager.DestroyFlowStates(self.session_id)
except queue_manager.MoreDataException:
pass
# This flow might already not be running.
if not self.IsRunning():
return
self._SendTerminationMessage(status=... | [
"Terminates",
"this",
"flow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L963-L978 | [
"def",
"Terminate",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"queue_manager",
".",
"DestroyFlowStates",
"(",
"self",
".",
"session_id",
")",
"except",
"queue_manager",
".",
"MoreDataException",
":",
"pass",
"# This flow might... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FlowRunner.UpdateProtoResources | Save cpu and network stats, check limits. | grr/server/grr_response_server/flow_runner.py | def UpdateProtoResources(self, status):
"""Save cpu and network stats, check limits."""
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.context.client_resources.cpu_usage.user_cpu_time += user_cpu
self.context.client_resources.cpu_usage.system_cpu... | def UpdateProtoResources(self, status):
"""Save cpu and network stats, check limits."""
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.context.client_resources.cpu_usage.user_cpu_time += user_cpu
self.context.client_resources.cpu_usage.system_cpu... | [
"Save",
"cpu",
"and",
"network",
"stats",
"check",
"limits",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_runner.py#L980-L1001 | [
"def",
"UpdateProtoResources",
"(",
"self",
",",
"status",
")",
":",
"user_cpu",
"=",
"status",
".",
"cpu_time_used",
".",
"user_cpu_time",
"system_cpu",
"=",
"status",
".",
"cpu_time_used",
".",
"system_cpu_time",
"self",
".",
"context",
".",
"client_resources",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _HostPrefix | Build a host prefix for a notification message based on a client id. | grr/server/grr_response_server/notification.py | def _HostPrefix(client_id):
"""Build a host prefix for a notification message based on a client id."""
if not client_id:
return ""
hostname = None
if data_store.RelationalDBEnabled():
client_snapshot = data_store.REL_DB.ReadClientSnapshot(client_id)
if client_snapshot:
hostname = client_snaps... | def _HostPrefix(client_id):
"""Build a host prefix for a notification message based on a client id."""
if not client_id:
return ""
hostname = None
if data_store.RelationalDBEnabled():
client_snapshot = data_store.REL_DB.ReadClientSnapshot(client_id)
if client_snapshot:
hostname = client_snaps... | [
"Build",
"a",
"host",
"prefix",
"for",
"a",
"notification",
"message",
"based",
"on",
"a",
"client",
"id",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/notification.py#L16-L33 | [
"def",
"_HostPrefix",
"(",
"client_id",
")",
":",
"if",
"not",
"client_id",
":",
"return",
"\"\"",
"hostname",
"=",
"None",
"if",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
":",
"client_snapshot",
"=",
"data_store",
".",
"REL_DB",
".",
"ReadClientSnap... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _MapLegacyArgs | Maps UserNotification object to legacy GRRUser.Notify arguments. | grr/server/grr_response_server/notification.py | def _MapLegacyArgs(nt, message, ref):
"""Maps UserNotification object to legacy GRRUser.Notify arguments."""
unt = rdf_objects.UserNotification.Type
if nt == unt.TYPE_CLIENT_INTERROGATED:
return [
"Discovery",
aff4.ROOT_URN.Add(ref.client.client_id),
_HostPrefix(ref.client.client_id) ... | def _MapLegacyArgs(nt, message, ref):
"""Maps UserNotification object to legacy GRRUser.Notify arguments."""
unt = rdf_objects.UserNotification.Type
if nt == unt.TYPE_CLIENT_INTERROGATED:
return [
"Discovery",
aff4.ROOT_URN.Add(ref.client.client_id),
_HostPrefix(ref.client.client_id) ... | [
"Maps",
"UserNotification",
"object",
"to",
"legacy",
"GRRUser",
".",
"Notify",
"arguments",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/notification.py#L36-L179 | [
"def",
"_MapLegacyArgs",
"(",
"nt",
",",
"message",
",",
"ref",
")",
":",
"unt",
"=",
"rdf_objects",
".",
"UserNotification",
".",
"Type",
"if",
"nt",
"==",
"unt",
".",
"TYPE_CLIENT_INTERROGATED",
":",
"return",
"[",
"\"Discovery\"",
",",
"aff4",
".",
"ROO... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _NotifyLegacy | Schedules a legacy AFF4 user notification. | grr/server/grr_response_server/notification.py | def _NotifyLegacy(username, notification_type, message, object_reference):
"""Schedules a legacy AFF4 user notification."""
try:
with aff4.FACTORY.Open(
aff4.ROOT_URN.Add("users").Add(username),
aff4_type=aff4_users.GRRUser,
mode="rw") as fd:
args = _MapLegacyArgs(notification_ty... | def _NotifyLegacy(username, notification_type, message, object_reference):
"""Schedules a legacy AFF4 user notification."""
try:
with aff4.FACTORY.Open(
aff4.ROOT_URN.Add("users").Add(username),
aff4_type=aff4_users.GRRUser,
mode="rw") as fd:
args = _MapLegacyArgs(notification_ty... | [
"Schedules",
"a",
"legacy",
"AFF4",
"user",
"notification",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/notification.py#L182-L196 | [
"def",
"_NotifyLegacy",
"(",
"username",
",",
"notification_type",
",",
"message",
",",
"object_reference",
")",
":",
"try",
":",
"with",
"aff4",
".",
"FACTORY",
".",
"Open",
"(",
"aff4",
".",
"ROOT_URN",
".",
"Add",
"(",
"\"users\"",
")",
".",
"Add",
"(... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _Notify | Schedules a new-style REL_DB user notification. | grr/server/grr_response_server/notification.py | def _Notify(username, notification_type, message, object_reference):
"""Schedules a new-style REL_DB user notification."""
# Do not try to notify system users (e.g. Cron).
if username in aff4_users.GRRUser.SYSTEM_USERS:
return
if object_reference:
uc = object_reference.UnionCast()
if hasattr(uc, "... | def _Notify(username, notification_type, message, object_reference):
"""Schedules a new-style REL_DB user notification."""
# Do not try to notify system users (e.g. Cron).
if username in aff4_users.GRRUser.SYSTEM_USERS:
return
if object_reference:
uc = object_reference.UnionCast()
if hasattr(uc, "... | [
"Schedules",
"a",
"new",
"-",
"style",
"REL_DB",
"user",
"notification",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/notification.py#L199-L217 | [
"def",
"_Notify",
"(",
"username",
",",
"notification_type",
",",
"message",
",",
"object_reference",
")",
":",
"# Do not try to notify system users (e.g. Cron).",
"if",
"username",
"in",
"aff4_users",
".",
"GRRUser",
".",
"SYSTEM_USERS",
":",
"return",
"if",
"object_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SequentialCollection.StaticAdd | Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The caller is responsible for ensuring that the collection
exists and is of the correct type.
Args:
collection_urn: The urn of the collection to add to.
rdf_value: The ... | grr/server/grr_response_server/sequential_collection.py | def StaticAdd(cls,
collection_urn,
rdf_value,
timestamp=None,
suffix=None,
mutation_pool=None):
"""Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The ca... | def StaticAdd(cls,
collection_urn,
rdf_value,
timestamp=None,
suffix=None,
mutation_pool=None):
"""Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The ca... | [
"Adds",
"an",
"rdf",
"value",
"to",
"a",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L43-L91 | [
"def",
"StaticAdd",
"(",
"cls",
",",
"collection_urn",
",",
"rdf_value",
",",
"timestamp",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"mutation_pool",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"rdf_value",
",",
"cls",
".",
"RDF_TYPE",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SequentialCollection.Add | Adds an rdf value to the collection.
Adds an rdf value to the collection. Does not require that the collection
be locked.
Args:
rdf_value: The rdf value to add to the collection.
timestamp: The timestamp (in microseconds) to store the rdf value at.
Defaults to the current time.
s... | grr/server/grr_response_server/sequential_collection.py | def Add(self, rdf_value, timestamp=None, suffix=None, mutation_pool=None):
"""Adds an rdf value to the collection.
Adds an rdf value to the collection. Does not require that the collection
be locked.
Args:
rdf_value: The rdf value to add to the collection.
timestamp: The timestamp (in micr... | def Add(self, rdf_value, timestamp=None, suffix=None, mutation_pool=None):
"""Adds an rdf value to the collection.
Adds an rdf value to the collection. Does not require that the collection
be locked.
Args:
rdf_value: The rdf value to add to the collection.
timestamp: The timestamp (in micr... | [
"Adds",
"an",
"rdf",
"value",
"to",
"the",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L93-L120 | [
"def",
"Add",
"(",
"self",
",",
"rdf_value",
",",
"timestamp",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"mutation_pool",
"=",
"None",
")",
":",
"return",
"self",
".",
"StaticAdd",
"(",
"self",
".",
"collection_id",
",",
"rdf_value",
",",
"timestamp"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SequentialCollection.Scan | Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
after_timestamp: If set, only returns values recorded after timestamp.
include_suffix: If true, the timestamps returned are pairs of the form
(micros_since_epoc, suffix) where suffix... | grr/server/grr_response_server/sequential_collection.py | def Scan(self, after_timestamp=None, include_suffix=False, max_records=None):
"""Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
after_timestamp: If set, only returns values recorded after timestamp.
include_suffix: If true, the times... | def Scan(self, after_timestamp=None, include_suffix=False, max_records=None):
"""Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
after_timestamp: If set, only returns values recorded after timestamp.
include_suffix: If true, the times... | [
"Scans",
"for",
"stored",
"records",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L122-L154 | [
"def",
"Scan",
"(",
"self",
",",
"after_timestamp",
"=",
"None",
",",
"include_suffix",
"=",
"False",
",",
"max_records",
"=",
"None",
")",
":",
"suffix",
"=",
"None",
"if",
"isinstance",
"(",
"after_timestamp",
",",
"tuple",
")",
":",
"suffix",
"=",
"af... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SequentialCollection.MultiResolve | Lookup multiple values by their record objects. | grr/server/grr_response_server/sequential_collection.py | def MultiResolve(self, records):
"""Lookup multiple values by their record objects."""
for value, timestamp in data_store.DB.CollectionReadItems(records):
rdf_value = self.RDF_TYPE.FromSerializedString(value)
rdf_value.age = timestamp
yield rdf_value | def MultiResolve(self, records):
"""Lookup multiple values by their record objects."""
for value, timestamp in data_store.DB.CollectionReadItems(records):
rdf_value = self.RDF_TYPE.FromSerializedString(value)
rdf_value.age = timestamp
yield rdf_value | [
"Lookup",
"multiple",
"values",
"by",
"their",
"record",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L156-L161 | [
"def",
"MultiResolve",
"(",
"self",
",",
"records",
")",
":",
"for",
"value",
",",
"timestamp",
"in",
"data_store",
".",
"DB",
".",
"CollectionReadItems",
"(",
"records",
")",
":",
"rdf_value",
"=",
"self",
".",
"RDF_TYPE",
".",
"FromSerializedString",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | BackgroundIndexUpdater.UpdateLoop | Main loop that usually never terminates. | grr/server/grr_response_server/sequential_collection.py | def UpdateLoop(self):
"""Main loop that usually never terminates."""
while not self.exit_now:
with self.cv:
while not self.to_process:
self.cv.wait()
next_update = self.to_process.popleft()
if next_update is None:
return
now = time.time()
next_cls =... | def UpdateLoop(self):
"""Main loop that usually never terminates."""
while not self.exit_now:
with self.cv:
while not self.to_process:
self.cv.wait()
next_update = self.to_process.popleft()
if next_update is None:
return
now = time.time()
next_cls =... | [
"Main",
"loop",
"that",
"usually",
"never",
"terminates",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L198-L216 | [
"def",
"UpdateLoop",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"exit_now",
":",
"with",
"self",
".",
"cv",
":",
"while",
"not",
"self",
".",
"to_process",
":",
"self",
".",
"cv",
".",
"wait",
"(",
")",
"next_update",
"=",
"self",
".",
"to... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IndexedSequentialCollection._MaybeWriteIndex | Write index marker i. | grr/server/grr_response_server/sequential_collection.py | def _MaybeWriteIndex(self, i, ts, mutation_pool):
"""Write index marker i."""
if i > self._max_indexed and i % self.INDEX_SPACING == 0:
# We only write the index if the timestamp is more than 5 minutes in the
# past: hacky defense against a late write changing the count.
if ts[0] < (rdfvalue.R... | def _MaybeWriteIndex(self, i, ts, mutation_pool):
"""Write index marker i."""
if i > self._max_indexed and i % self.INDEX_SPACING == 0:
# We only write the index if the timestamp is more than 5 minutes in the
# past: hacky defense against a late write changing the count.
if ts[0] < (rdfvalue.R... | [
"Write",
"index",
"marker",
"i",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L280-L289 | [
"def",
"_MaybeWriteIndex",
"(",
"self",
",",
"i",
",",
"ts",
",",
"mutation_pool",
")",
":",
"if",
"i",
">",
"self",
".",
"_max_indexed",
"and",
"i",
"%",
"self",
".",
"INDEX_SPACING",
"==",
"0",
":",
"# We only write the index if the timestamp is more than 5 mi... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IndexedSequentialCollection._IndexedScan | Scan records starting with index i. | grr/server/grr_response_server/sequential_collection.py | def _IndexedScan(self, i, max_records=None):
"""Scan records starting with index i."""
self._ReadIndex()
# The record number that we will read next.
idx = 0
# The timestamp that we will start reading from.
start_ts = 0
if i >= self._max_indexed:
start_ts = max((0, 0), (self._index[sel... | def _IndexedScan(self, i, max_records=None):
"""Scan records starting with index i."""
self._ReadIndex()
# The record number that we will read next.
idx = 0
# The timestamp that we will start reading from.
start_ts = 0
if i >= self._max_indexed:
start_ts = max((0, 0), (self._index[sel... | [
"Scan",
"records",
"starting",
"with",
"index",
"i",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L291-L323 | [
"def",
"_IndexedScan",
"(",
"self",
",",
"i",
",",
"max_records",
"=",
"None",
")",
":",
"self",
".",
"_ReadIndex",
"(",
")",
"# The record number that we will read next.",
"idx",
"=",
"0",
"# The timestamp that we will start reading from.",
"start_ts",
"=",
"0",
"i... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GrrMessageCollection.AddAsMessage | Helper method to add rdfvalues as GrrMessages for testing. | grr/server/grr_response_server/sequential_collection.py | def AddAsMessage(self, rdfvalue_in, source, mutation_pool=None):
"""Helper method to add rdfvalues as GrrMessages for testing."""
self.Add(
rdf_flows.GrrMessage(payload=rdfvalue_in, source=source),
mutation_pool=mutation_pool) | def AddAsMessage(self, rdfvalue_in, source, mutation_pool=None):
"""Helper method to add rdfvalues as GrrMessages for testing."""
self.Add(
rdf_flows.GrrMessage(payload=rdfvalue_in, source=source),
mutation_pool=mutation_pool) | [
"Helper",
"method",
"to",
"add",
"rdfvalues",
"as",
"GrrMessages",
"for",
"testing",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/sequential_collection.py#L406-L410 | [
"def",
"AddAsMessage",
"(",
"self",
",",
"rdfvalue_in",
",",
"source",
",",
"mutation_pool",
"=",
"None",
")",
":",
"self",
".",
"Add",
"(",
"rdf_flows",
".",
"GrrMessage",
"(",
"payload",
"=",
"rdfvalue_in",
",",
"source",
"=",
"source",
")",
",",
"muta... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PasswdParser.Parse | Parse the passwd file. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the passwd file."""
_, _ = stat, knowledge_base
lines = [
l.strip()
for l in utils.ReadFileBytesAsUnicode(file_object).splitlines()
]
for index, line in enumerate(lines):
user = self.ParseLine(index, line)
if us... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the passwd file."""
_, _ = stat, knowledge_base
lines = [
l.strip()
for l in utils.ReadFileBytesAsUnicode(file_object).splitlines()
]
for index, line in enumerate(lines):
user = self.ParseLine(index, line)
if us... | [
"Parse",
"the",
"passwd",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L121-L131 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
",",
"_",
"=",
"stat",
",",
"knowledge_base",
"lines",
"=",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"utils",
".",
"ReadFileBytesAsUnicode",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxWtmpParser.Parse | Parse the wtmp file. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the wtmp file."""
_, _ = stat, knowledge_base
users = {}
wtmp = file_object.read()
while wtmp:
try:
record = UtmpStruct(wtmp)
except utils.ParsingError:
break
wtmp = wtmp[record.size:]
# Users only ... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the wtmp file."""
_, _ = stat, knowledge_base
users = {}
wtmp = file_object.read()
while wtmp:
try:
record = UtmpStruct(wtmp)
except utils.ParsingError:
break
wtmp = wtmp[record.size:]
# Users only ... | [
"Parse",
"the",
"wtmp",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L179-L208 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
",",
"_",
"=",
"stat",
",",
"knowledge_base",
"users",
"=",
"{",
"}",
"wtmp",
"=",
"file_object",
".",
"read",
"(",
")",
"while",
"wtmp",
":",
"try",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | NetgroupParser.Parse | Parse the netgroup file and return User objects.
Lines are of the form:
group1 (-,user1,) (-,user2,) (-,user3,)
Groups are ignored, we return users in lines that match the filter regexes,
or all users in the file if no filters are specified.
We assume usernames are in the default regex format s... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def Parse(self, stat, file_object, knowledge_base):
"""Parse the netgroup file and return User objects.
Lines are of the form:
group1 (-,user1,) (-,user2,) (-,user3,)
Groups are ignored, we return users in lines that match the filter regexes,
or all users in the file if no filters are specified.... | def Parse(self, stat, file_object, knowledge_base):
"""Parse the netgroup file and return User objects.
Lines are of the form:
group1 (-,user1,) (-,user2,) (-,user3,)
Groups are ignored, we return users in lines that match the filter regexes,
or all users in the file if no filters are specified.... | [
"Parse",
"the",
"netgroup",
"file",
"and",
"return",
"User",
"objects",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L260-L285 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_object",
",",
"knowledge_base",
")",
":",
"_",
",",
"_",
"=",
"stat",
",",
"knowledge_base",
"lines",
"=",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"utils",
".",
"ReadFileBytesAsUnicode",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxBaseShadowParser.GetHashType | Identify the type of hash in a hash string.
Args:
hash_str: A string value that may be a hash.
Returns:
A string description of the type of hash. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def GetHashType(self, hash_str):
"""Identify the type of hash in a hash string.
Args:
hash_str: A string value that may be a hash.
Returns:
A string description of the type of hash.
"""
# Return the type of the first matching hash.
for hash_type, hash_re in self.hashes:
if ha... | def GetHashType(self, hash_str):
"""Identify the type of hash in a hash string.
Args:
hash_str: A string value that may be a hash.
Returns:
A string description of the type of hash.
"""
# Return the type of the first matching hash.
for hash_type, hash_re in self.hashes:
if ha... | [
"Identify",
"the",
"type",
"of",
"hash",
"in",
"a",
"hash",
"string",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L346-L360 | [
"def",
"GetHashType",
"(",
"self",
",",
"hash_str",
")",
":",
"# Return the type of the first matching hash.",
"for",
"hash_type",
",",
"hash_re",
"in",
"self",
".",
"hashes",
":",
"if",
"hash_re",
".",
"match",
"(",
"hash_str",
")",
":",
"return",
"hash_type",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxBaseShadowParser._ParseFile | Process a file line by line.
Args:
file_obj: The file to parse.
line_parser: The parser method used to process and store line content.
Raises:
parser.ParseError if the parser is unable to process the line. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def _ParseFile(self, file_obj, line_parser):
"""Process a file line by line.
Args:
file_obj: The file to parse.
line_parser: The parser method used to process and store line content.
Raises:
parser.ParseError if the parser is unable to process the line.
"""
lines = [
l.st... | def _ParseFile(self, file_obj, line_parser):
"""Process a file line by line.
Args:
file_obj: The file to parse.
line_parser: The parser method used to process and store line content.
Raises:
parser.ParseError if the parser is unable to process the line.
"""
lines = [
l.st... | [
"Process",
"a",
"file",
"line",
"by",
"line",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L362-L380 | [
"def",
"_ParseFile",
"(",
"self",
",",
"file_obj",
",",
"line_parser",
")",
":",
"lines",
"=",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"utils",
".",
"ReadFileBytesAsUnicode",
"(",
"file_obj",
")",
".",
"splitlines",
"(",
")",
"]",
"try",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxBaseShadowParser.ReconcileShadow | Verify that entries that claim to use shadow files have a shadow entry.
If the entries of the non-shadowed file indicate that a shadow file is used,
check that there is actually an entry for that file in shadow.
Args:
store_type: The type of password store that should be used (e.g.
/etc/shad... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ReconcileShadow(self, store_type):
"""Verify that entries that claim to use shadow files have a shadow entry.
If the entries of the non-shadowed file indicate that a shadow file is used,
check that there is actually an entry for that file in shadow.
Args:
store_type: The type of password sto... | def ReconcileShadow(self, store_type):
"""Verify that entries that claim to use shadow files have a shadow entry.
If the entries of the non-shadowed file indicate that a shadow file is used,
check that there is actually an entry for that file in shadow.
Args:
store_type: The type of password sto... | [
"Verify",
"that",
"entries",
"that",
"claim",
"to",
"use",
"shadow",
"files",
"have",
"a",
"shadow",
"entry",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L382-L398 | [
"def",
"ReconcileShadow",
"(",
"self",
",",
"store_type",
")",
":",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"entry",
")",
":",
"if",
"v",
".",
"pw_entry",
".",
"store",
"==",
"store_type",
":",
"shadow_entry",
"=",
"self",
".",
"sh... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxBaseShadowParser.MemberDiff | Helper method to perform bidirectional set differences. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def MemberDiff(data1, set1_name, data2, set2_name):
"""Helper method to perform bidirectional set differences."""
set1 = set(data1)
set2 = set(data2)
diffs = []
msg = "Present in %s, missing in %s: %s"
if set1 != set2:
in_set1 = set1 - set2
in_set2 = set2 - set1
if in_set1:
... | def MemberDiff(data1, set1_name, data2, set2_name):
"""Helper method to perform bidirectional set differences."""
set1 = set(data1)
set2 = set(data2)
diffs = []
msg = "Present in %s, missing in %s: %s"
if set1 != set2:
in_set1 = set1 - set2
in_set2 = set2 - set1
if in_set1:
... | [
"Helper",
"method",
"to",
"perform",
"bidirectional",
"set",
"differences",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L405-L418 | [
"def",
"MemberDiff",
"(",
"data1",
",",
"set1_name",
",",
"data2",
",",
"set2_name",
")",
":",
"set1",
"=",
"set",
"(",
"data1",
")",
"set2",
"=",
"set",
"(",
"data2",
")",
"diffs",
"=",
"[",
"]",
"msg",
"=",
"\"Present in %s, missing in %s: %s\"",
"if",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxBaseShadowParser.ParseMultiple | Process files together. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseMultiple(self, stats, file_objs, kb):
"""Process files together."""
fileset = {stat.pathspec.path: obj for stat, obj in zip(stats, file_objs)}
return self.ParseFileset(fileset) | def ParseMultiple(self, stats, file_objs, kb):
"""Process files together."""
fileset = {stat.pathspec.path: obj for stat, obj in zip(stats, file_objs)}
return self.ParseFileset(fileset) | [
"Process",
"files",
"together",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L420-L423 | [
"def",
"ParseMultiple",
"(",
"self",
",",
"stats",
",",
"file_objs",
",",
"kb",
")",
":",
"fileset",
"=",
"{",
"stat",
".",
"pathspec",
".",
"path",
":",
"obj",
"for",
"stat",
",",
"obj",
"in",
"zip",
"(",
"stats",
",",
"file_objs",
")",
"}",
"retu... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemGroupParser.ParseGshadowEntry | Extract the members of each group from /etc/gshadow.
Identifies the groups in /etc/gshadow and several attributes of the group,
including how the password is crypted (if set).
gshadow files have the format group_name:passwd:admins:members
admins are both group members and can manage passwords and memb... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseGshadowEntry(self, line):
"""Extract the members of each group from /etc/gshadow.
Identifies the groups in /etc/gshadow and several attributes of the group,
including how the password is crypted (if set).
gshadow files have the format group_name:passwd:admins:members
admins are both group... | def ParseGshadowEntry(self, line):
"""Extract the members of each group from /etc/gshadow.
Identifies the groups in /etc/gshadow and several attributes of the group,
including how the password is crypted (if set).
gshadow files have the format group_name:passwd:admins:members
admins are both group... | [
"Extract",
"the",
"members",
"of",
"each",
"group",
"from",
"/",
"etc",
"/",
"gshadow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L439-L463 | [
"def",
"ParseGshadowEntry",
"(",
"self",
",",
"line",
")",
":",
"fields",
"=",
"(",
"\"name\"",
",",
"\"passwd\"",
",",
"\"administrators\"",
",",
"\"members\"",
")",
"if",
"line",
":",
"rslt",
"=",
"dict",
"(",
"zip",
"(",
"fields",
",",
"line",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemGroupParser.ParseGroupEntry | Extract the members of a group from /etc/group. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseGroupEntry(self, line):
"""Extract the members of a group from /etc/group."""
fields = ("name", "passwd", "gid", "members")
if line:
rslt = dict(zip(fields, line.split(":")))
name = rslt["name"]
group = self.entry.setdefault(name, rdf_client.Group(name=name))
group.pw_entry.... | def ParseGroupEntry(self, line):
"""Extract the members of a group from /etc/group."""
fields = ("name", "passwd", "gid", "members")
if line:
rslt = dict(zip(fields, line.split(":")))
name = rslt["name"]
group = self.entry.setdefault(name, rdf_client.Group(name=name))
group.pw_entry.... | [
"Extract",
"the",
"members",
"of",
"a",
"group",
"from",
"/",
"etc",
"/",
"group",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L465-L478 | [
"def",
"ParseGroupEntry",
"(",
"self",
",",
"line",
")",
":",
"fields",
"=",
"(",
"\"name\"",
",",
"\"passwd\"",
",",
"\"gid\"",
",",
"\"members\"",
")",
"if",
"line",
":",
"rslt",
"=",
"dict",
"(",
"zip",
"(",
"fields",
",",
"line",
".",
"split",
"(... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemGroupParser.MergeMembers | Add shadow group members to the group if gshadow is used.
Normally group and shadow should be in sync, but no guarantees. Merges the
two stores as membership in either file may confer membership. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def MergeMembers(self):
"""Add shadow group members to the group if gshadow is used.
Normally group and shadow should be in sync, but no guarantees. Merges the
two stores as membership in either file may confer membership.
"""
for group_name, members in iteritems(self.gshadow_members):
group ... | def MergeMembers(self):
"""Add shadow group members to the group if gshadow is used.
Normally group and shadow should be in sync, but no guarantees. Merges the
two stores as membership in either file may confer membership.
"""
for group_name, members in iteritems(self.gshadow_members):
group ... | [
"Add",
"shadow",
"group",
"members",
"to",
"the",
"group",
"if",
"gshadow",
"is",
"used",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L480-L489 | [
"def",
"MergeMembers",
"(",
"self",
")",
":",
"for",
"group_name",
",",
"members",
"in",
"iteritems",
"(",
"self",
".",
"gshadow_members",
")",
":",
"group",
"=",
"self",
".",
"entry",
".",
"get",
"(",
"group_name",
")",
"if",
"group",
"and",
"group",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemGroupParser.FindAnomalies | Identify any anomalous group attributes or memberships. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def FindAnomalies(self):
"""Identify any anomalous group attributes or memberships."""
for grp_name, group in iteritems(self.entry):
shadow = self.shadow.get(grp_name)
gshadows = self.gshadow_members.get(grp_name, [])
if shadow is not None:
diff = self.MemberDiff(group.members, "group"... | def FindAnomalies(self):
"""Identify any anomalous group attributes or memberships."""
for grp_name, group in iteritems(self.entry):
shadow = self.shadow.get(grp_name)
gshadows = self.gshadow_members.get(grp_name, [])
if shadow is not None:
diff = self.MemberDiff(group.members, "group"... | [
"Identify",
"any",
"anomalous",
"group",
"attributes",
"or",
"memberships",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L491-L504 | [
"def",
"FindAnomalies",
"(",
"self",
")",
":",
"for",
"grp_name",
",",
"group",
"in",
"iteritems",
"(",
"self",
".",
"entry",
")",
":",
"shadow",
"=",
"self",
".",
"shadow",
".",
"get",
"(",
"grp_name",
")",
"gshadows",
"=",
"self",
".",
"gshadow_membe... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemGroupParser.ParseFileset | Process linux system group and gshadow files.
Orchestrates collection of account entries from /etc/group and /etc/gshadow.
The group and gshadow entries are reconciled and member users are added to
the entry.
Args:
fileset: A dict of files mapped from path to an open file.
Yields:
- A... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseFileset(self, fileset=None):
"""Process linux system group and gshadow files.
Orchestrates collection of account entries from /etc/group and /etc/gshadow.
The group and gshadow entries are reconciled and member users are added to
the entry.
Args:
fileset: A dict of files mapped from... | def ParseFileset(self, fileset=None):
"""Process linux system group and gshadow files.
Orchestrates collection of account entries from /etc/group and /etc/gshadow.
The group and gshadow entries are reconciled and member users are added to
the entry.
Args:
fileset: A dict of files mapped from... | [
"Process",
"linux",
"system",
"group",
"and",
"gshadow",
"files",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L506-L542 | [
"def",
"ParseFileset",
"(",
"self",
",",
"fileset",
"=",
"None",
")",
":",
"# Get relevant shadow attributes.",
"gshadow",
"=",
"fileset",
".",
"get",
"(",
"\"/etc/gshadow\"",
")",
"if",
"gshadow",
":",
"self",
".",
"_ParseFile",
"(",
"gshadow",
",",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.ParseShadowEntry | Extract the user accounts in /etc/shadow.
Identifies the users in /etc/shadow and several attributes of their account,
including how their password is crypted and password aging characteristics.
Args:
line: An entry of the shadow file. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseShadowEntry(self, line):
"""Extract the user accounts in /etc/shadow.
Identifies the users in /etc/shadow and several attributes of their account,
including how their password is crypted and password aging characteristics.
Args:
line: An entry of the shadow file.
"""
fields = ("... | def ParseShadowEntry(self, line):
"""Extract the user accounts in /etc/shadow.
Identifies the users in /etc/shadow and several attributes of their account,
including how their password is crypted and password aging characteristics.
Args:
line: An entry of the shadow file.
"""
fields = ("... | [
"Extract",
"the",
"user",
"accounts",
"in",
"/",
"etc",
"/",
"shadow",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L561-L583 | [
"def",
"ParseShadowEntry",
"(",
"self",
",",
"line",
")",
":",
"fields",
"=",
"(",
"\"login\"",
",",
"\"passwd\"",
",",
"\"last_change\"",
",",
"\"min_age\"",
",",
"\"max_age\"",
",",
"\"warn_time\"",
",",
"\"inactivity\"",
",",
"\"expire\"",
",",
"\"reserved\""... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.ParsePasswdEntry | Process the passwd entry fields and primary group memberships. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParsePasswdEntry(self, line):
"""Process the passwd entry fields and primary group memberships."""
fields = ("uname", "passwd", "uid", "gid", "fullname", "homedir", "shell")
if line:
rslt = dict(zip(fields, line.split(":")))
user = self.entry.setdefault(rslt["uname"], rdf_client.User())
... | def ParsePasswdEntry(self, line):
"""Process the passwd entry fields and primary group memberships."""
fields = ("uname", "passwd", "uid", "gid", "fullname", "homedir", "shell")
if line:
rslt = dict(zip(fields, line.split(":")))
user = self.entry.setdefault(rslt["uname"], rdf_client.User())
... | [
"Process",
"the",
"passwd",
"entry",
"fields",
"and",
"primary",
"group",
"memberships",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L585-L608 | [
"def",
"ParsePasswdEntry",
"(",
"self",
",",
"line",
")",
":",
"fields",
"=",
"(",
"\"uname\"",
",",
"\"passwd\"",
",",
"\"uid\"",
",",
"\"gid\"",
",",
"\"fullname\"",
",",
"\"homedir\"",
",",
"\"shell\"",
")",
"if",
"line",
":",
"rslt",
"=",
"dict",
"("... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser._Members | Unify members of a group and accounts with the group as primary gid. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def _Members(self, group):
"""Unify members of a group and accounts with the group as primary gid."""
group.members = set(group.members).union(self.gids.get(group.gid, []))
return group | def _Members(self, group):
"""Unify members of a group and accounts with the group as primary gid."""
group.members = set(group.members).union(self.gids.get(group.gid, []))
return group | [
"Unify",
"members",
"of",
"a",
"group",
"and",
"accounts",
"with",
"the",
"group",
"as",
"primary",
"gid",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L610-L613 | [
"def",
"_Members",
"(",
"self",
",",
"group",
")",
":",
"group",
".",
"members",
"=",
"set",
"(",
"group",
".",
"members",
")",
".",
"union",
"(",
"self",
".",
"gids",
".",
"get",
"(",
"group",
".",
"gid",
",",
"[",
"]",
")",
")",
"return",
"gr... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.AddGroupMemberships | Adds aggregate group membership from group, gshadow and passwd. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def AddGroupMemberships(self):
"""Adds aggregate group membership from group, gshadow and passwd."""
self.groups = {g.name: self._Members(g) for g in itervalues(self.groups)}
# Map the groups a user is a member of, irrespective of primary/extra gid.
for g in itervalues(self.groups):
for user in g.... | def AddGroupMemberships(self):
"""Adds aggregate group membership from group, gshadow and passwd."""
self.groups = {g.name: self._Members(g) for g in itervalues(self.groups)}
# Map the groups a user is a member of, irrespective of primary/extra gid.
for g in itervalues(self.groups):
for user in g.... | [
"Adds",
"aggregate",
"group",
"membership",
"from",
"group",
"gshadow",
"and",
"passwd",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L615-L625 | [
"def",
"AddGroupMemberships",
"(",
"self",
")",
":",
"self",
".",
"groups",
"=",
"{",
"g",
".",
"name",
":",
"self",
".",
"_Members",
"(",
"g",
")",
"for",
"g",
"in",
"itervalues",
"(",
"self",
".",
"groups",
")",
"}",
"# Map the groups a user is a membe... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.FindAnomalies | Identify anomalies in the password/shadow and group/gshadow data. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def FindAnomalies(self):
"""Identify anomalies in the password/shadow and group/gshadow data."""
# Find anomalous group entries.
findings = []
group_entries = {g.gid for g in itervalues(self.groups)}
for gid in set(self.gids) - group_entries:
undefined = ",".join(self.gids.get(gid, []))
... | def FindAnomalies(self):
"""Identify anomalies in the password/shadow and group/gshadow data."""
# Find anomalous group entries.
findings = []
group_entries = {g.gid for g in itervalues(self.groups)}
for gid in set(self.gids) - group_entries:
undefined = ",".join(self.gids.get(gid, []))
... | [
"Identify",
"anomalies",
"in",
"the",
"password",
"/",
"shadow",
"and",
"group",
"/",
"gshadow",
"data",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L627-L661 | [
"def",
"FindAnomalies",
"(",
"self",
")",
":",
"# Find anomalous group entries.",
"findings",
"=",
"[",
"]",
"group_entries",
"=",
"{",
"g",
".",
"gid",
"for",
"g",
"in",
"itervalues",
"(",
"self",
".",
"groups",
")",
"}",
"for",
"gid",
"in",
"set",
"(",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.AddPassword | Add the passwd entries to the shadow store. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def AddPassword(self, fileset):
"""Add the passwd entries to the shadow store."""
passwd = fileset.get("/etc/passwd")
if passwd:
self._ParseFile(passwd, self.ParsePasswdEntry)
else:
logging.debug("No /etc/passwd file.") | def AddPassword(self, fileset):
"""Add the passwd entries to the shadow store."""
passwd = fileset.get("/etc/passwd")
if passwd:
self._ParseFile(passwd, self.ParsePasswdEntry)
else:
logging.debug("No /etc/passwd file.") | [
"Add",
"the",
"passwd",
"entries",
"to",
"the",
"shadow",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L663-L669 | [
"def",
"AddPassword",
"(",
"self",
",",
"fileset",
")",
":",
"passwd",
"=",
"fileset",
".",
"get",
"(",
"\"/etc/passwd\"",
")",
"if",
"passwd",
":",
"self",
".",
"_ParseFile",
"(",
"passwd",
",",
"self",
".",
"ParsePasswdEntry",
")",
"else",
":",
"loggin... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.AddShadow | Add the shadow entries to the shadow store. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def AddShadow(self, fileset):
"""Add the shadow entries to the shadow store."""
shadow = fileset.get("/etc/shadow")
if shadow:
self._ParseFile(shadow, self.ParseShadowEntry)
else:
logging.debug("No /etc/shadow file.") | def AddShadow(self, fileset):
"""Add the shadow entries to the shadow store."""
shadow = fileset.get("/etc/shadow")
if shadow:
self._ParseFile(shadow, self.ParseShadowEntry)
else:
logging.debug("No /etc/shadow file.") | [
"Add",
"the",
"shadow",
"entries",
"to",
"the",
"shadow",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L671-L677 | [
"def",
"AddShadow",
"(",
"self",
",",
"fileset",
")",
":",
"shadow",
"=",
"fileset",
".",
"get",
"(",
"\"/etc/shadow\"",
")",
"if",
"shadow",
":",
"self",
".",
"_ParseFile",
"(",
"shadow",
",",
"self",
".",
"ParseShadowEntry",
")",
"else",
":",
"logging"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LinuxSystemPasswdParser.ParseFileset | Process linux system login files.
Orchestrates collection of account entries from /etc/passwd and
/etc/shadow. The passwd and shadow entries are reconciled and group
memberships are mapped to the account.
Args:
fileset: A dict of files mapped from path to an open file.
Yields:
- A se... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def ParseFileset(self, fileset=None):
"""Process linux system login files.
Orchestrates collection of account entries from /etc/passwd and
/etc/shadow. The passwd and shadow entries are reconciled and group
memberships are mapped to the account.
Args:
fileset: A dict of files mapped from pa... | def ParseFileset(self, fileset=None):
"""Process linux system login files.
Orchestrates collection of account entries from /etc/passwd and
/etc/shadow. The passwd and shadow entries are reconciled and group
memberships are mapped to the account.
Args:
fileset: A dict of files mapped from pa... | [
"Process",
"linux",
"system",
"login",
"files",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L679-L711 | [
"def",
"ParseFileset",
"(",
"self",
",",
"fileset",
"=",
"None",
")",
":",
"self",
".",
"AddPassword",
"(",
"fileset",
")",
"self",
".",
"AddShadow",
"(",
"fileset",
")",
"self",
".",
"ReconcileShadow",
"(",
"self",
".",
"shadow_store",
")",
"# Get group m... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PathParser._ExpandPath | Extract path information, interpolating current path values as needed. | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def _ExpandPath(self, target, vals, paths):
"""Extract path information, interpolating current path values as needed."""
if target not in self._TARGETS:
return
expanded = []
for val in vals:
# Null entries specify the current directory, so :a::b:c: is equivalent
# to .:a:.:b:c:.
... | def _ExpandPath(self, target, vals, paths):
"""Extract path information, interpolating current path values as needed."""
if target not in self._TARGETS:
return
expanded = []
for val in vals:
# Null entries specify the current directory, so :a::b:c: is equivalent
# to .:a:.:b:c:.
... | [
"Extract",
"path",
"information",
"interpolating",
"current",
"path",
"values",
"as",
"needed",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L749-L770 | [
"def",
"_ExpandPath",
"(",
"self",
",",
"target",
",",
"vals",
",",
"paths",
")",
":",
"if",
"target",
"not",
"in",
"self",
".",
"_TARGETS",
":",
"return",
"expanded",
"=",
"[",
"]",
"for",
"val",
"in",
"vals",
":",
"# Null entries specify the current dire... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PathParser._ParseShVariables | Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:
lines: A list of lines, each of whic... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def _ParseShVariables(self, lines):
"""Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:... | def _ParseShVariables(self, lines):
"""Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:... | [
"Extract",
"env_var",
"and",
"path",
"values",
"from",
"sh",
"derivative",
"shells",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L772-L803 | [
"def",
"_ParseShVariables",
"(",
"self",
",",
"lines",
")",
":",
"paths",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"for",
"entry",
"in",
"line",
":",
"if",
"\"=\"",
"in",
"entry",
":",
"# Pad out the list so that it's always 2 elements, even if the spli... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PathParser._ParseCshVariables | Extract env_var and path values from csh derivative shells.
Path attributes can be set several ways:
- setenv takes the form "setenv PATH_NAME COLON:SEPARATED:LIST"
- set takes the form "set path_name=(space separated list)" and is
automatically exported for several types of files.
The first ent... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def _ParseCshVariables(self, lines):
"""Extract env_var and path values from csh derivative shells.
Path attributes can be set several ways:
- setenv takes the form "setenv PATH_NAME COLON:SEPARATED:LIST"
- set takes the form "set path_name=(space separated list)" and is
automatically exported fo... | def _ParseCshVariables(self, lines):
"""Extract env_var and path values from csh derivative shells.
Path attributes can be set several ways:
- setenv takes the form "setenv PATH_NAME COLON:SEPARATED:LIST"
- set takes the form "set path_name=(space separated list)" and is
automatically exported fo... | [
"Extract",
"env_var",
"and",
"path",
"values",
"from",
"csh",
"derivative",
"shells",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L805-L842 | [
"def",
"_ParseCshVariables",
"(",
"self",
",",
"lines",
")",
":",
"paths",
"=",
"{",
"}",
"for",
"line",
"in",
"lines",
":",
"if",
"len",
"(",
"line",
")",
"<",
"2",
":",
"continue",
"action",
"=",
"line",
"[",
"0",
"]",
"if",
"action",
"==",
"\"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | PathParser.Parse | Identifies the paths set within a file.
Expands paths within the context of the file, but does not infer fully
expanded paths from external states. There are plenty of cases where path
attributes are unresolved, e.g. sourcing other files.
Lines are not handled literally. A field parser is used to:
... | grr/core/grr_response_core/lib/parsers/linux_file_parser.py | def Parse(self, stat, file_obj, knowledge_base):
"""Identifies the paths set within a file.
Expands paths within the context of the file, but does not infer fully
expanded paths from external states. There are plenty of cases where path
attributes are unresolved, e.g. sourcing other files.
Lines a... | def Parse(self, stat, file_obj, knowledge_base):
"""Identifies the paths set within a file.
Expands paths within the context of the file, but does not infer fully
expanded paths from external states. There are plenty of cases where path
attributes are unresolved, e.g. sourcing other files.
Lines a... | [
"Identifies",
"the",
"paths",
"set",
"within",
"a",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/linux_file_parser.py#L844-L875 | [
"def",
"Parse",
"(",
"self",
",",
"stat",
",",
"file_obj",
",",
"knowledge_base",
")",
":",
"_",
"=",
"knowledge_base",
"lines",
"=",
"self",
".",
"parser",
".",
"ParseEntries",
"(",
"utils",
".",
"ReadFileBytesAsUnicode",
"(",
"file_obj",
")",
")",
"if",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSHandler.Seek | Seek to an offset in the file. | grr/client/grr_response_client/vfs_handlers/base.py | def Seek(self, offset, whence=os.SEEK_SET):
"""Seek to an offset in the file."""
if whence == os.SEEK_SET:
self.offset = offset
elif whence == os.SEEK_CUR:
self.offset += offset
elif whence == os.SEEK_END:
self.offset = self.size + offset
else:
raise ValueError("Illegal whenc... | def Seek(self, offset, whence=os.SEEK_SET):
"""Seek to an offset in the file."""
if whence == os.SEEK_SET:
self.offset = offset
elif whence == os.SEEK_CUR:
self.offset += offset
elif whence == os.SEEK_END:
self.offset = self.size + offset
else:
raise ValueError("Illegal whenc... | [
"Seek",
"to",
"an",
"offset",
"in",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/base.py#L89-L98 | [
"def",
"Seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"whence",
"==",
"os",
".",
"SEEK_SET",
":",
"self",
".",
"offset",
"=",
"offset",
"elif",
"whence",
"==",
"os",
".",
"SEEK_CUR",
":",
"self",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSHandler.OpenAsContainer | Guesses a container from the current object. | grr/client/grr_response_client/vfs_handlers/base.py | def OpenAsContainer(self):
"""Guesses a container from the current object."""
if self.IsDirectory():
return self
# TODO(user): Add support for more containers here (e.g. registries, zip
# files etc).
else: # For now just guess TSK.
tsk_handler = self._handlers[rdf_paths.PathSpec.PathTy... | def OpenAsContainer(self):
"""Guesses a container from the current object."""
if self.IsDirectory():
return self
# TODO(user): Add support for more containers here (e.g. registries, zip
# files etc).
else: # For now just guess TSK.
tsk_handler = self._handlers[rdf_paths.PathSpec.PathTy... | [
"Guesses",
"a",
"container",
"from",
"the",
"current",
"object",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/base.py#L121-L136 | [
"def",
"OpenAsContainer",
"(",
"self",
")",
":",
"if",
"self",
".",
"IsDirectory",
"(",
")",
":",
"return",
"self",
"# TODO(user): Add support for more containers here (e.g. registries, zip",
"# files etc).",
"else",
":",
"# For now just guess TSK.",
"tsk_handler",
"=",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSHandler.MatchBestComponentName | Returns the name of the component which matches best our base listing.
In order to do the best case insensitive matching we list the files in the
base handler and return the base match for this component.
Args:
component: A component name which should be present in this directory.
Returns:
... | grr/client/grr_response_client/vfs_handlers/base.py | def MatchBestComponentName(self, component):
"""Returns the name of the component which matches best our base listing.
In order to do the best case insensitive matching we list the files in the
base handler and return the base match for this component.
Args:
component: A component name which sho... | def MatchBestComponentName(self, component):
"""Returns the name of the component which matches best our base listing.
In order to do the best case insensitive matching we list the files in the
base handler and return the base match for this component.
Args:
component: A component name which sho... | [
"Returns",
"the",
"name",
"of",
"the",
"component",
"which",
"matches",
"best",
"our",
"base",
"listing",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/base.py#L138-L171 | [
"def",
"MatchBestComponentName",
"(",
"self",
",",
"component",
")",
":",
"fd",
"=",
"self",
".",
"OpenAsContainer",
"(",
")",
"# Adjust the component casing",
"file_listing",
"=",
"set",
"(",
"fd",
".",
"ListNames",
"(",
")",
")",
"# First try an exact match",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VFSHandler.Open | Try to correct the casing of component.
This method is called when we failed to open the component directly. We try
to transform the component into something which is likely to work.
In this implementation, we correct the case of the component until we can
not open the path any more.
Args:
... | grr/client/grr_response_client/vfs_handlers/base.py | def Open(cls, fd, component, handlers, pathspec=None, progress_callback=None):
"""Try to correct the casing of component.
This method is called when we failed to open the component directly. We try
to transform the component into something which is likely to work.
In this implementation, we correct th... | def Open(cls, fd, component, handlers, pathspec=None, progress_callback=None):
"""Try to correct the casing of component.
This method is called when we failed to open the component directly. We try
to transform the component into something which is likely to work.
In this implementation, we correct th... | [
"Try",
"to",
"correct",
"the",
"casing",
"of",
"component",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/vfs_handlers/base.py#L199-L272 | [
"def",
"Open",
"(",
"cls",
",",
"fd",
",",
"component",
",",
"handlers",
",",
"pathspec",
"=",
"None",
",",
"progress_callback",
"=",
"None",
")",
":",
"# The handler for this component",
"try",
":",
"handler",
"=",
"handlers",
"[",
"component",
".",
"pathty... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiTypeCollection.StaticAdd | Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The caller is responsible for ensuring that the collection
exists and is of the correct type.
Args:
collection_urn: The urn of the collection to add to.
rdf_value: The ... | grr/server/grr_response_server/multi_type_collection.py | def StaticAdd(cls,
collection_urn,
rdf_value,
timestamp=None,
suffix=None,
mutation_pool=None):
"""Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The ca... | def StaticAdd(cls,
collection_urn,
rdf_value,
timestamp=None,
suffix=None,
mutation_pool=None):
"""Adds an rdf value to a collection.
Adds an rdf value to a collection. Does not require that the collection be
open. NOTE: The ca... | [
"Adds",
"an",
"rdf",
"value",
"to",
"a",
"collection",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/multi_type_collection.py#L26-L79 | [
"def",
"StaticAdd",
"(",
"cls",
",",
"collection_urn",
",",
"rdf_value",
",",
"timestamp",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"mutation_pool",
"=",
"None",
")",
":",
"if",
"rdf_value",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Can't add ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiTypeCollection.ScanByType | Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
type_name: Type of the records to scan.
after_timestamp: If set, only returns values recorded after timestamp.
include_suffix: If true, the timestamps returned are pairs of the form
... | grr/server/grr_response_server/multi_type_collection.py | def ScanByType(self,
type_name,
after_timestamp=None,
include_suffix=False,
max_records=None):
"""Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
type_name: Type of the rec... | def ScanByType(self,
type_name,
after_timestamp=None,
include_suffix=False,
max_records=None):
"""Scans for stored records.
Scans through the collection, returning stored values ordered by timestamp.
Args:
type_name: Type of the rec... | [
"Scans",
"for",
"stored",
"records",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/multi_type_collection.py#L85-L115 | [
"def",
"ScanByType",
"(",
"self",
",",
"type_name",
",",
"after_timestamp",
"=",
"None",
",",
"include_suffix",
"=",
"False",
",",
"max_records",
"=",
"None",
")",
":",
"sub_collection_urn",
"=",
"self",
".",
"collection_id",
".",
"Add",
"(",
"type_name",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.