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 | InitializeNoPrompt | Initialize GRR with no prompts.
Args:
config: config object
external_hostname: A hostname.
admin_password: A password used for the admin user.
mysql_hostname: A hostname used for establishing connection to MySQL.
mysql_port: A port used for establishing connection to MySQL.
mysql_username: A ... | grr/server/grr_response_server/bin/config_updater_util.py | def InitializeNoPrompt(config=None,
external_hostname = None,
admin_password = None,
mysql_hostname = None,
mysql_port = None,
mysql_username = None,
mysql_password = None,
... | def InitializeNoPrompt(config=None,
external_hostname = None,
admin_password = None,
mysql_hostname = None,
mysql_port = None,
mysql_username = None,
mysql_password = None,
... | [
"Initialize",
"GRR",
"with",
"no",
"prompts",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L538-L635 | [
"def",
"InitializeNoPrompt",
"(",
"config",
"=",
"None",
",",
"external_hostname",
"=",
"None",
",",
"admin_password",
"=",
"None",
",",
"mysql_hostname",
"=",
"None",
",",
"mysql_port",
"=",
"None",
",",
"mysql_username",
"=",
"None",
",",
"mysql_password",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UploadSignedBinary | Signs a binary and uploads it to the datastore.
Args:
source_path: Path to the binary to upload.
binary_type: Type of the binary, e.g python-hack or executable.
platform: Client platform where the binary is intended to be run.
upload_subdirectory: Path of a subdirectory to upload the binary to,
... | grr/server/grr_response_server/bin/config_updater_util.py | def UploadSignedBinary(source_path,
binary_type,
platform,
upload_subdirectory=""):
"""Signs a binary and uploads it to the datastore.
Args:
source_path: Path to the binary to upload.
binary_type: Type of the binary, e.g python-hack or ex... | def UploadSignedBinary(source_path,
binary_type,
platform,
upload_subdirectory=""):
"""Signs a binary and uploads it to the datastore.
Args:
source_path: Path to the binary to upload.
binary_type: Type of the binary, e.g python-hack or ex... | [
"Signs",
"a",
"binary",
"and",
"uploads",
"it",
"to",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L645-L686 | [
"def",
"UploadSignedBinary",
"(",
"source_path",
",",
"binary_type",
",",
"platform",
",",
"upload_subdirectory",
"=",
"\"\"",
")",
":",
"file_size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"source_path",
")",
"if",
"file_size",
">",
"_MAX_SIGNED_BINARY_BYT... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateUser | Creates a new GRR user. | grr/server/grr_response_server/bin/config_updater_util.py | def CreateUser(username, password=None, is_admin=False):
"""Creates a new GRR user."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
user_exists = grr_api.GrrUser(username).Get() is not None
except api_errors.ResourceNotFoundError:
user_exists = False
if user_exists:
raise UserAlreadyExistsErr... | def CreateUser(username, password=None, is_admin=False):
"""Creates a new GRR user."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
user_exists = grr_api.GrrUser(username).Get() is not None
except api_errors.ResourceNotFoundError:
user_exists = False
if user_exists:
raise UserAlreadyExistsErr... | [
"Creates",
"a",
"new",
"GRR",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L689-L701 | [
"def",
"CreateUser",
"(",
"username",
",",
"password",
"=",
"None",
",",
"is_admin",
"=",
"False",
")",
":",
"grr_api",
"=",
"maintenance_utils",
".",
"InitGRRRootAPI",
"(",
")",
"try",
":",
"user_exists",
"=",
"grr_api",
".",
"GrrUser",
"(",
"username",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UpdateUser | Updates the password or privilege-level for a user. | grr/server/grr_response_server/bin/config_updater_util.py | def UpdateUser(username, password=None, is_admin=False):
"""Updates the password or privilege-level for a user."""
user_type, password = _GetUserTypeAndPassword(
username, password=password, is_admin=is_admin)
grr_api = maintenance_utils.InitGRRRootAPI()
grr_user = grr_api.GrrUser(username).Get()
grr_us... | def UpdateUser(username, password=None, is_admin=False):
"""Updates the password or privilege-level for a user."""
user_type, password = _GetUserTypeAndPassword(
username, password=password, is_admin=is_admin)
grr_api = maintenance_utils.InitGRRRootAPI()
grr_user = grr_api.GrrUser(username).Get()
grr_us... | [
"Updates",
"the",
"password",
"or",
"privilege",
"-",
"level",
"for",
"a",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L704-L710 | [
"def",
"UpdateUser",
"(",
"username",
",",
"password",
"=",
"None",
",",
"is_admin",
"=",
"False",
")",
":",
"user_type",
",",
"password",
"=",
"_GetUserTypeAndPassword",
"(",
"username",
",",
"password",
"=",
"password",
",",
"is_admin",
"=",
"is_admin",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetUserSummary | Returns a string with summary info for a user. | grr/server/grr_response_server/bin/config_updater_util.py | def GetUserSummary(username):
"""Returns a string with summary info for a user."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
return _Summarize(grr_api.GrrUser(username).Get().data)
except api_errors.ResourceNotFoundError:
raise UserNotFoundError(username) | def GetUserSummary(username):
"""Returns a string with summary info for a user."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
return _Summarize(grr_api.GrrUser(username).Get().data)
except api_errors.ResourceNotFoundError:
raise UserNotFoundError(username) | [
"Returns",
"a",
"string",
"with",
"summary",
"info",
"for",
"a",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L713-L719 | [
"def",
"GetUserSummary",
"(",
"username",
")",
":",
"grr_api",
"=",
"maintenance_utils",
".",
"InitGRRRootAPI",
"(",
")",
"try",
":",
"return",
"_Summarize",
"(",
"grr_api",
".",
"GrrUser",
"(",
"username",
")",
".",
"Get",
"(",
")",
".",
"data",
")",
"e... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetAllUserSummaries | Returns a string containing summary info for all GRR users. | grr/server/grr_response_server/bin/config_updater_util.py | def GetAllUserSummaries():
"""Returns a string containing summary info for all GRR users."""
grr_api = maintenance_utils.InitGRRRootAPI()
user_wrappers = sorted(grr_api.ListGrrUsers(), key=lambda x: x.username)
summaries = [_Summarize(w.data) for w in user_wrappers]
return "\n\n".join(summaries) | def GetAllUserSummaries():
"""Returns a string containing summary info for all GRR users."""
grr_api = maintenance_utils.InitGRRRootAPI()
user_wrappers = sorted(grr_api.ListGrrUsers(), key=lambda x: x.username)
summaries = [_Summarize(w.data) for w in user_wrappers]
return "\n\n".join(summaries) | [
"Returns",
"a",
"string",
"containing",
"summary",
"info",
"for",
"all",
"GRR",
"users",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L722-L727 | [
"def",
"GetAllUserSummaries",
"(",
")",
":",
"grr_api",
"=",
"maintenance_utils",
".",
"InitGRRRootAPI",
"(",
")",
"user_wrappers",
"=",
"sorted",
"(",
"grr_api",
".",
"ListGrrUsers",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"username",
")"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _Summarize | Returns a string with summary info for a user. | grr/server/grr_response_server/bin/config_updater_util.py | def _Summarize(user_info):
"""Returns a string with summary info for a user."""
return "Username: %s\nIs Admin: %s" % (
user_info.username,
user_info.user_type == api_user.ApiGrrUser.UserType.USER_TYPE_ADMIN) | def _Summarize(user_info):
"""Returns a string with summary info for a user."""
return "Username: %s\nIs Admin: %s" % (
user_info.username,
user_info.user_type == api_user.ApiGrrUser.UserType.USER_TYPE_ADMIN) | [
"Returns",
"a",
"string",
"with",
"summary",
"info",
"for",
"a",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L730-L734 | [
"def",
"_Summarize",
"(",
"user_info",
")",
":",
"return",
"\"Username: %s\\nIs Admin: %s\"",
"%",
"(",
"user_info",
".",
"username",
",",
"user_info",
".",
"user_type",
"==",
"api_user",
".",
"ApiGrrUser",
".",
"UserType",
".",
"USER_TYPE_ADMIN",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeleteUser | Deletes a GRR user from the datastore. | grr/server/grr_response_server/bin/config_updater_util.py | def DeleteUser(username):
"""Deletes a GRR user from the datastore."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
grr_api.GrrUser(username).Get().Delete()
except api_errors.ResourceNotFoundError:
raise UserNotFoundError(username) | def DeleteUser(username):
"""Deletes a GRR user from the datastore."""
grr_api = maintenance_utils.InitGRRRootAPI()
try:
grr_api.GrrUser(username).Get().Delete()
except api_errors.ResourceNotFoundError:
raise UserNotFoundError(username) | [
"Deletes",
"a",
"GRR",
"user",
"from",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L737-L743 | [
"def",
"DeleteUser",
"(",
"username",
")",
":",
"grr_api",
"=",
"maintenance_utils",
".",
"InitGRRRootAPI",
"(",
")",
"try",
":",
"grr_api",
".",
"GrrUser",
"(",
"username",
")",
".",
"Get",
"(",
")",
".",
"Delete",
"(",
")",
"except",
"api_errors",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | _GetUserTypeAndPassword | Returns the user-type and password for a user.
Args:
username: Username for the user.
password: Password for the user. If None, or not provided, we will prompt
for one via the terminal.
is_admin: Indicates whether the user should have admin privileges. | grr/server/grr_response_server/bin/config_updater_util.py | def _GetUserTypeAndPassword(username, password=None, is_admin=False):
"""Returns the user-type and password for a user.
Args:
username: Username for the user.
password: Password for the user. If None, or not provided, we will prompt
for one via the terminal.
is_admin: Indicates whether the user s... | def _GetUserTypeAndPassword(username, password=None, is_admin=False):
"""Returns the user-type and password for a user.
Args:
username: Username for the user.
password: Password for the user. If None, or not provided, we will prompt
for one via the terminal.
is_admin: Indicates whether the user s... | [
"Returns",
"the",
"user",
"-",
"type",
"and",
"password",
"for",
"a",
"user",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/config_updater_util.py#L746-L765 | [
"def",
"_GetUserTypeAndPassword",
"(",
"username",
",",
"password",
"=",
"None",
",",
"is_admin",
"=",
"False",
")",
":",
"if",
"is_admin",
":",
"user_type",
"=",
"api_user",
".",
"ApiGrrUser",
".",
"UserType",
".",
"USER_TYPE_ADMIN",
"else",
":",
"user_type",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Responses.FromResponses | Creates a Responses object from new style flow request and responses. | grr/server/grr_response_server/flow_responses.py | def FromResponses(cls, request=None, responses=None):
"""Creates a Responses object from new style flow request and responses."""
res = cls()
res.request = request
if request:
res.request_data = request.request_data
for r in responses or []:
if isinstance(r, rdf_flow_objects.FlowRespons... | def FromResponses(cls, request=None, responses=None):
"""Creates a Responses object from new style flow request and responses."""
res = cls()
res.request = request
if request:
res.request_data = request.request_data
for r in responses or []:
if isinstance(r, rdf_flow_objects.FlowRespons... | [
"Creates",
"a",
"Responses",
"object",
"from",
"new",
"style",
"flow",
"request",
"and",
"responses",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_responses.py#L30-L47 | [
"def",
"FromResponses",
"(",
"cls",
",",
"request",
"=",
"None",
",",
"responses",
"=",
"None",
")",
":",
"res",
"=",
"cls",
"(",
")",
"res",
".",
"request",
"=",
"request",
"if",
"request",
":",
"res",
".",
"request_data",
"=",
"request",
".",
"requ... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Responses.FromLegacyResponses | Creates a Responses object from old style flow request and responses. | grr/server/grr_response_server/flow_responses.py | def FromLegacyResponses(cls, request=None, responses=None):
"""Creates a Responses object from old style flow request and responses."""
res = cls()
res.request = request
if request:
res.request_data = rdf_protodict.Dict(request.data)
dropped_responses = []
# The iterator that was returned ... | def FromLegacyResponses(cls, request=None, responses=None):
"""Creates a Responses object from old style flow request and responses."""
res = cls()
res.request = request
if request:
res.request_data = rdf_protodict.Dict(request.data)
dropped_responses = []
# The iterator that was returned ... | [
"Creates",
"a",
"Responses",
"object",
"from",
"old",
"style",
"flow",
"request",
"and",
"responses",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow_responses.py#L50-L145 | [
"def",
"FromLegacyResponses",
"(",
"cls",
",",
"request",
"=",
"None",
",",
"responses",
"=",
"None",
")",
":",
"res",
"=",
"cls",
"(",
")",
"res",
".",
"request",
"=",
"request",
"if",
"request",
":",
"res",
".",
"request_data",
"=",
"rdf_protodict",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Kill.Run | Run the kill. | grr/client/grr_response_client/client_actions/admin.py | def Run(self, unused_arg):
"""Run the kill."""
# Send a message back to the service to say that we are about to shutdown.
reply = rdf_flows.GrrStatus(status=rdf_flows.GrrStatus.ReturnedStatus.OK)
# Queue up the response message, jump the queue.
self.SendReply(reply, message_type=rdf_flows.GrrMessage... | def Run(self, unused_arg):
"""Run the kill."""
# Send a message back to the service to say that we are about to shutdown.
reply = rdf_flows.GrrStatus(status=rdf_flows.GrrStatus.ReturnedStatus.OK)
# Queue up the response message, jump the queue.
self.SendReply(reply, message_type=rdf_flows.GrrMessage... | [
"Run",
"the",
"kill",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/admin.py#L80-L92 | [
"def",
"Run",
"(",
"self",
",",
"unused_arg",
")",
":",
"# Send a message back to the service to say that we are about to shutdown.",
"reply",
"=",
"rdf_flows",
".",
"GrrStatus",
"(",
"status",
"=",
"rdf_flows",
".",
"GrrStatus",
".",
"ReturnedStatus",
".",
"OK",
")",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetConfiguration.Run | Retrieve the configuration except for the blocked parameters. | grr/client/grr_response_client/client_actions/admin.py | def Run(self, unused_arg):
"""Retrieve the configuration except for the blocked parameters."""
out = self.out_rdfvalues[0]()
for descriptor in config.CONFIG.type_infos:
if descriptor.name in self.BLOCKED_PARAMETERS:
value = "[Redacted]"
else:
try:
value = config.CONFIG... | def Run(self, unused_arg):
"""Retrieve the configuration except for the blocked parameters."""
out = self.out_rdfvalues[0]()
for descriptor in config.CONFIG.type_infos:
if descriptor.name in self.BLOCKED_PARAMETERS:
value = "[Redacted]"
else:
try:
value = config.CONFIG... | [
"Retrieve",
"the",
"configuration",
"except",
"for",
"the",
"blocked",
"parameters",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/admin.py#L143-L160 | [
"def",
"Run",
"(",
"self",
",",
"unused_arg",
")",
":",
"out",
"=",
"self",
".",
"out_rdfvalues",
"[",
"0",
"]",
"(",
")",
"for",
"descriptor",
"in",
"config",
".",
"CONFIG",
".",
"type_infos",
":",
"if",
"descriptor",
".",
"name",
"in",
"self",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | UpdateConfiguration.Run | Does the actual work. | grr/client/grr_response_client/client_actions/admin.py | def Run(self, arg):
"""Does the actual work."""
try:
if self.grr_worker.client.FleetspeakEnabled():
raise ValueError("Not supported on Fleetspeak enabled clients.")
except AttributeError:
pass
smart_arg = {str(field): value for field, value in iteritems(arg)}
disallowed_fields ... | def Run(self, arg):
"""Does the actual work."""
try:
if self.grr_worker.client.FleetspeakEnabled():
raise ValueError("Not supported on Fleetspeak enabled clients.")
except AttributeError:
pass
smart_arg = {str(field): value for field, value in iteritems(arg)}
disallowed_fields ... | [
"Does",
"the",
"actual",
"work",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/admin.py#L228-L274 | [
"def",
"Run",
"(",
"self",
",",
"arg",
")",
":",
"try",
":",
"if",
"self",
".",
"grr_worker",
".",
"client",
".",
"FleetspeakEnabled",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"Not supported on Fleetspeak enabled clients.\"",
")",
"except",
"AttributeError",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetClientStats.Run | Returns the client stats. | grr/client/grr_response_client/client_actions/admin.py | def Run(self, arg):
"""Returns the client stats."""
if arg is None:
arg = rdf_client_action.GetClientStatsRequest()
proc = psutil.Process(os.getpid())
meminfo = proc.memory_info()
boot_time = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(psutil.boot_time())
create_time = rdfvalue.RDFDatetime... | def Run(self, arg):
"""Returns the client stats."""
if arg is None:
arg = rdf_client_action.GetClientStatsRequest()
proc = psutil.Process(os.getpid())
meminfo = proc.memory_info()
boot_time = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(psutil.boot_time())
create_time = rdfvalue.RDFDatetime... | [
"Returns",
"the",
"client",
"stats",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/admin.py#L299-L324 | [
"def",
"Run",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"rdf_client_action",
".",
"GetClientStatsRequest",
"(",
")",
"proc",
"=",
"psutil",
".",
"Process",
"(",
"os",
".",
"getpid",
"(",
")",
")",
"meminfo",
"=",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SendStartupInfo.Run | Returns the startup information. | grr/client/grr_response_client/client_actions/admin.py | def Run(self, unused_arg, ttl=None):
"""Returns the startup information."""
logging.debug("Sending startup information.")
boot_time = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(psutil.boot_time())
response = rdf_client.StartupInfo(
boot_time=boot_time, client_info=GetClientInformation())
se... | def Run(self, unused_arg, ttl=None):
"""Returns the startup information."""
logging.debug("Sending startup information.")
boot_time = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(psutil.boot_time())
response = rdf_client.StartupInfo(
boot_time=boot_time, client_info=GetClientInformation())
se... | [
"Returns",
"the",
"startup",
"information",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/admin.py#L350-L364 | [
"def",
"Run",
"(",
"self",
",",
"unused_arg",
",",
"ttl",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\"Sending startup information.\"",
")",
"boot_time",
"=",
"rdfvalue",
".",
"RDFDatetime",
".",
"FromSecondsSinceEpoch",
"(",
"psutil",
".",
"boot_ti... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ConvertStringToFilename | Converts an unicode string to a filesystem safe filename.
For maximum compatibility we escape all chars which are not alphanumeric (in
the unicode sense).
Args:
name: a unicode string that is part of a subject.
Returns:
A safe filename with escaped special chars. | grr/server/grr_response_server/data_stores/common.py | def ConvertStringToFilename(name):
"""Converts an unicode string to a filesystem safe filename.
For maximum compatibility we escape all chars which are not alphanumeric (in
the unicode sense).
Args:
name: a unicode string that is part of a subject.
Returns:
A safe filename with escaped special chars... | def ConvertStringToFilename(name):
"""Converts an unicode string to a filesystem safe filename.
For maximum compatibility we escape all chars which are not alphanumeric (in
the unicode sense).
Args:
name: a unicode string that is part of a subject.
Returns:
A safe filename with escaped special chars... | [
"Converts",
"an",
"unicode",
"string",
"to",
"a",
"filesystem",
"safe",
"filename",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/common.py#L16-L30 | [
"def",
"ConvertStringToFilename",
"(",
"name",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r\"\\W\"",
",",
"lambda",
"x",
":",
"\"%%%02X\"",
"%",
"ord",
"(",
"x",
".",
"group",
"(",
"0",
")",
")",
",",
"name",
",",
"flags",
"=",
"re",
".",
"UNICODE... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ResolveSubjectDestination | Returns the directory/filename where the subject will be stored.
Args:
subject: The subject.
regexes: The list of regular expressions by priority.
Returns:
File name and directory. | grr/server/grr_response_server/data_stores/common.py | def ResolveSubjectDestination(subject, regexes):
"""Returns the directory/filename where the subject will be stored.
Args:
subject: The subject.
regexes: The list of regular expressions by priority.
Returns:
File name and directory.
"""
components = Components(subject)
if not components:
# No... | def ResolveSubjectDestination(subject, regexes):
"""Returns the directory/filename where the subject will be stored.
Args:
subject: The subject.
regexes: The list of regular expressions by priority.
Returns:
File name and directory.
"""
components = Components(subject)
if not components:
# No... | [
"Returns",
"the",
"directory",
"/",
"filename",
"where",
"the",
"subject",
"will",
"be",
"stored",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/common.py#L40-L65 | [
"def",
"ResolveSubjectDestination",
"(",
"subject",
",",
"regexes",
")",
":",
"components",
"=",
"Components",
"(",
"subject",
")",
"if",
"not",
"components",
":",
"# No components to work with.",
"return",
"\"aff4\"",
",",
"\"\"",
"# Make all the components safe to use... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MakeDestinationKey | Creates a name that identifies a database file. | grr/server/grr_response_server/data_stores/common.py | def MakeDestinationKey(directory, filename):
"""Creates a name that identifies a database file."""
return utils.SmartStr(utils.JoinPath(directory, filename)).lstrip("/") | def MakeDestinationKey(directory, filename):
"""Creates a name that identifies a database file."""
return utils.SmartStr(utils.JoinPath(directory, filename)).lstrip("/") | [
"Creates",
"a",
"name",
"that",
"identifies",
"a",
"database",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/common.py#L68-L70 | [
"def",
"MakeDestinationKey",
"(",
"directory",
",",
"filename",
")",
":",
"return",
"utils",
".",
"SmartStr",
"(",
"utils",
".",
"JoinPath",
"(",
"directory",
",",
"filename",
")",
")",
".",
"lstrip",
"(",
"\"/\"",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DatabaseDirectorySize | Compute size (in bytes) and number of files of a file-based data store. | grr/server/grr_response_server/data_stores/common.py | def DatabaseDirectorySize(root_path, extension):
"""Compute size (in bytes) and number of files of a file-based data store."""
directories = collections.deque([root_path])
total_size = 0
total_files = 0
while directories:
directory = directories.popleft()
try:
items = os.listdir(directory)
e... | def DatabaseDirectorySize(root_path, extension):
"""Compute size (in bytes) and number of files of a file-based data store."""
directories = collections.deque([root_path])
total_size = 0
total_files = 0
while directories:
directory = directories.popleft()
try:
items = os.listdir(directory)
e... | [
"Compute",
"size",
"(",
"in",
"bytes",
")",
"and",
"number",
"of",
"files",
"of",
"a",
"file",
"-",
"based",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_stores/common.py#L73-L98 | [
"def",
"DatabaseDirectorySize",
"(",
"root_path",
",",
"extension",
")",
":",
"directories",
"=",
"collections",
".",
"deque",
"(",
"[",
"root_path",
"]",
")",
"total_size",
"=",
"0",
"total_files",
"=",
"0",
"while",
"directories",
":",
"directory",
"=",
"d... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FileStore.GetChildrenByPriority | Generator that yields active filestore children in priority order. | grr/server/grr_response_server/aff4_objects/filestore.py | def GetChildrenByPriority(self, allow_external=True):
"""Generator that yields active filestore children in priority order."""
for child in sorted(self.OpenChildren(), key=lambda x: x.PRIORITY):
if not allow_external and child.EXTERNAL:
continue
if child.Get(child.Schema.ACTIVE):
yie... | def GetChildrenByPriority(self, allow_external=True):
"""Generator that yields active filestore children in priority order."""
for child in sorted(self.OpenChildren(), key=lambda x: x.PRIORITY):
if not allow_external and child.EXTERNAL:
continue
if child.Get(child.Schema.ACTIVE):
yie... | [
"Generator",
"that",
"yields",
"active",
"filestore",
"children",
"in",
"priority",
"order",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L42-L48 | [
"def",
"GetChildrenByPriority",
"(",
"self",
",",
"allow_external",
"=",
"True",
")",
":",
"for",
"child",
"in",
"sorted",
"(",
"self",
".",
"OpenChildren",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"PRIORITY",
")",
":",
"if",
"not",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FileStore.CheckHashes | Checks a list of hashes for presence in the store.
Sub stores need to pass back the original HashDigest objects since they
carry state about the original file source.
Only unique hashes are checked, if there is duplication in the hashes input
it is the caller's responsibility to maintain any necessary... | grr/server/grr_response_server/aff4_objects/filestore.py | def CheckHashes(self, hashes, external=True):
"""Checks a list of hashes for presence in the store.
Sub stores need to pass back the original HashDigest objects since they
carry state about the original file source.
Only unique hashes are checked, if there is duplication in the hashes input
it is ... | def CheckHashes(self, hashes, external=True):
"""Checks a list of hashes for presence in the store.
Sub stores need to pass back the original HashDigest objects since they
carry state about the original file source.
Only unique hashes are checked, if there is duplication in the hashes input
it is ... | [
"Checks",
"a",
"list",
"of",
"hashes",
"for",
"presence",
"in",
"the",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L57-L82 | [
"def",
"CheckHashes",
"(",
"self",
",",
"hashes",
",",
"external",
"=",
"True",
")",
":",
"hashes",
"=",
"set",
"(",
"hashes",
")",
"for",
"child",
"in",
"self",
".",
"GetChildrenByPriority",
"(",
"allow_external",
"=",
"external",
")",
":",
"for",
"urn"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FileStore.AddFile | Create a new file in the file store.
We delegate the actual file addition to our contained
implementations. Implementations can either implement the AddFile() method,
returning a file like object which will be written on, or directly support
the AddBlobToStore() method which can copy the VFSBlobImage e... | grr/server/grr_response_server/aff4_objects/filestore.py | def AddFile(self, fd, external=True):
"""Create a new file in the file store.
We delegate the actual file addition to our contained
implementations. Implementations can either implement the AddFile() method,
returning a file like object which will be written on, or directly support
the AddBlobToSto... | def AddFile(self, fd, external=True):
"""Create a new file in the file store.
We delegate the actual file addition to our contained
implementations. Implementations can either implement the AddFile() method,
returning a file like object which will be written on, or directly support
the AddBlobToSto... | [
"Create",
"a",
"new",
"file",
"in",
"the",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L84-L114 | [
"def",
"AddFile",
"(",
"self",
",",
"fd",
",",
"external",
"=",
"True",
")",
":",
"files_for_write",
"=",
"[",
"]",
"for",
"sub_store",
"in",
"self",
".",
"GetChildrenByPriority",
"(",
"allow_external",
"=",
"external",
")",
":",
"new_file",
"=",
"sub_stor... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.Query | Search the index for matches starting with target_prefix.
Args:
index_urn: The index to use. Should be a urn that points to the sha256
namespace.
target_prefix: The prefix to match against the index.
limit: Either a tuple of (start, limit) or a maximum number of results to
re... | grr/server/grr_response_server/aff4_objects/filestore.py | def Query(cls, index_urn, target_prefix="", limit=100, token=None):
"""Search the index for matches starting with target_prefix.
Args:
index_urn: The index to use. Should be a urn that points to the sha256
namespace.
target_prefix: The prefix to match against the index.
limit: Eit... | def Query(cls, index_urn, target_prefix="", limit=100, token=None):
"""Search the index for matches starting with target_prefix.
Args:
index_urn: The index to use. Should be a urn that points to the sha256
namespace.
target_prefix: The prefix to match against the index.
limit: Eit... | [
"Search",
"the",
"index",
"for",
"matches",
"starting",
"with",
"target_prefix",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L212-L228 | [
"def",
"Query",
"(",
"cls",
",",
"index_urn",
",",
"target_prefix",
"=",
"\"\"",
",",
"limit",
"=",
"100",
",",
"token",
"=",
"None",
")",
":",
"return",
"data_store",
".",
"DB",
".",
"FileHashIndexQuery",
"(",
"index_urn",
",",
"target_prefix",
",",
"li... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.CheckHashes | Check hashes against the filestore.
Blobs use the hash in the schema:
aff4:/files/hash/generic/sha256/[sha256hash]
Args:
hashes: A list of Hash objects to check.
Yields:
Tuples of (RDFURN, hash object) that exist in the store. | grr/server/grr_response_server/aff4_objects/filestore.py | def CheckHashes(self, hashes):
"""Check hashes against the filestore.
Blobs use the hash in the schema:
aff4:/files/hash/generic/sha256/[sha256hash]
Args:
hashes: A list of Hash objects to check.
Yields:
Tuples of (RDFURN, hash object) that exist in the store.
"""
hash_map = {... | def CheckHashes(self, hashes):
"""Check hashes against the filestore.
Blobs use the hash in the schema:
aff4:/files/hash/generic/sha256/[sha256hash]
Args:
hashes: A list of Hash objects to check.
Yields:
Tuples of (RDFURN, hash object) that exist in the store.
"""
hash_map = {... | [
"Check",
"hashes",
"against",
"the",
"filestore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L253-L273 | [
"def",
"CheckHashes",
"(",
"self",
",",
"hashes",
")",
":",
"hash_map",
"=",
"{",
"}",
"for",
"hsh",
"in",
"hashes",
":",
"if",
"hsh",
".",
"HasField",
"(",
"\"sha256\"",
")",
":",
"# The canonical name of the file is where we store the file hash.",
"hash_map",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore._HashFile | Look for the required hashes in the file. | grr/server/grr_response_server/aff4_objects/filestore.py | def _HashFile(self, fd):
"""Look for the required hashes in the file."""
hashes = data_store_utils.GetFileHashEntry(fd)
if hashes:
found_all = True
for fingerprint_type, hash_types in iteritems(self.HASH_TYPES):
for hash_type in hash_types:
if fingerprint_type == "pecoff":
... | def _HashFile(self, fd):
"""Look for the required hashes in the file."""
hashes = data_store_utils.GetFileHashEntry(fd)
if hashes:
found_all = True
for fingerprint_type, hash_types in iteritems(self.HASH_TYPES):
for hash_type in hash_types:
if fingerprint_type == "pecoff":
... | [
"Look",
"for",
"the",
"required",
"hashes",
"in",
"the",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L282-L336 | [
"def",
"_HashFile",
"(",
"self",
",",
"fd",
")",
":",
"hashes",
"=",
"data_store_utils",
".",
"GetFileHashEntry",
"(",
"fd",
")",
"if",
"hashes",
":",
"found_all",
"=",
"True",
"for",
"fingerprint_type",
",",
"hash_types",
"in",
"iteritems",
"(",
"self",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.AddFile | Adds a file to the hash file store.
We take a file in the client space:
aff4:/C.123123123/fs/os/usr/local/blah
Hash it, update the hash in the original file if its different to the
one calculated on the client, and copy the original AFF4 object to
aff4:/files/hash/generic/sha256/123123123 (ca... | grr/server/grr_response_server/aff4_objects/filestore.py | def AddFile(self, fd):
"""Adds a file to the hash file store.
We take a file in the client space:
aff4:/C.123123123/fs/os/usr/local/blah
Hash it, update the hash in the original file if its different to the
one calculated on the client, and copy the original AFF4 object to
aff4:/files/has... | def AddFile(self, fd):
"""Adds a file to the hash file store.
We take a file in the client space:
aff4:/C.123123123/fs/os/usr/local/blah
Hash it, update the hash in the original file if its different to the
one calculated on the client, and copy the original AFF4 object to
aff4:/files/has... | [
"Adds",
"a",
"file",
"to",
"the",
"hash",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L338-L415 | [
"def",
"AddFile",
"(",
"self",
",",
"fd",
")",
":",
"hashes",
"=",
"self",
".",
"_HashFile",
"(",
"fd",
")",
"# The empty file is very common, we don't keep the back references for it",
"# in the DB since it just takes up too much space.",
"empty_hash",
"=",
"(",
"\"e3b0c44... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.ListHashes | Yields all the hashes in the file store.
Args:
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be aff4.NEWEST_TIME or a time range given as a tuple
(start, end) in microseconds since Jan 1st, 1970. If just a microseconds
value is given it's treat... | grr/server/grr_response_server/aff4_objects/filestore.py | def ListHashes(age=aff4.NEWEST_TIME):
"""Yields all the hashes in the file store.
Args:
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be aff4.NEWEST_TIME or a time range given as a tuple
(start, end) in microseconds since Jan 1st, 1970. If just a m... | def ListHashes(age=aff4.NEWEST_TIME):
"""Yields all the hashes in the file store.
Args:
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be aff4.NEWEST_TIME or a time range given as a tuple
(start, end) in microseconds since Jan 1st, 1970. If just a m... | [
"Yields",
"all",
"the",
"hashes",
"in",
"the",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L418-L444 | [
"def",
"ListHashes",
"(",
"age",
"=",
"aff4",
".",
"NEWEST_TIME",
")",
":",
"if",
"age",
"==",
"aff4",
".",
"ALL_TIMES",
":",
"raise",
"ValueError",
"(",
"\"age==aff4.ALL_TIMES is not allowed.\"",
")",
"urns",
"=",
"[",
"]",
"for",
"fingerprint_type",
",",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.GetClientsForHash | Yields client_files for the specified file store hash.
Args:
hash_obj: RDFURN that we want to get hits for.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be aff4.NEWEST_TIME or a time range given as a tuple
(start, en... | grr/server/grr_response_server/aff4_objects/filestore.py | def GetClientsForHash(cls, hash_obj, token=None, age=aff4.NEWEST_TIME):
"""Yields client_files for the specified file store hash.
Args:
hash_obj: RDFURN that we want to get hits for.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec.... | def GetClientsForHash(cls, hash_obj, token=None, age=aff4.NEWEST_TIME):
"""Yields client_files for the specified file store hash.
Args:
hash_obj: RDFURN that we want to get hits for.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec.... | [
"Yields",
"client_files",
"for",
"the",
"specified",
"file",
"store",
"hash",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L447-L472 | [
"def",
"GetClientsForHash",
"(",
"cls",
",",
"hash_obj",
",",
"token",
"=",
"None",
",",
"age",
"=",
"aff4",
".",
"NEWEST_TIME",
")",
":",
"if",
"age",
"==",
"aff4",
".",
"ALL_TIMES",
":",
"raise",
"ValueError",
"(",
"\"age==aff4.ALL_TIMES is not supported.\""... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | HashFileStore.GetClientsForHashes | Yields (hash, client_files) pairs for all the specified hashes.
Args:
hashes: List of RDFURN's.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be aff4.NEWEST_TIME or a time range given as a tuple
(start, end) in micros... | grr/server/grr_response_server/aff4_objects/filestore.py | def GetClientsForHashes(cls, hashes, token=None, age=aff4.NEWEST_TIME):
"""Yields (hash, client_files) pairs for all the specified hashes.
Args:
hashes: List of RDFURN's.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be a... | def GetClientsForHashes(cls, hashes, token=None, age=aff4.NEWEST_TIME):
"""Yields (hash, client_files) pairs for all the specified hashes.
Args:
hashes: List of RDFURN's.
token: Security token.
age: AFF4 age specification. Only get hits corresponding to the given age
spec. Should be a... | [
"Yields",
"(",
"hash",
"client_files",
")",
"pairs",
"for",
"all",
"the",
"specified",
"hashes",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L475-L508 | [
"def",
"GetClientsForHashes",
"(",
"cls",
",",
"hashes",
",",
"token",
"=",
"None",
",",
"age",
"=",
"aff4",
".",
"NEWEST_TIME",
")",
":",
"if",
"age",
"==",
"aff4",
".",
"ALL_TIMES",
":",
"raise",
"ValueError",
"(",
"\"age==aff4.ALL_TIMES is not supported.\""... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | NSRLFileStore.CheckHashes | Checks a list of hashes for presence in the store.
Only unique sha1 hashes are checked, if there is duplication in the hashes
input it is the caller's responsibility to maintain any necessary mappings.
Args:
hashes: A list of Hash objects to check.
unused_external: Ignored.
Yields:
... | grr/server/grr_response_server/aff4_objects/filestore.py | def CheckHashes(self, hashes, unused_external=True):
"""Checks a list of hashes for presence in the store.
Only unique sha1 hashes are checked, if there is duplication in the hashes
input it is the caller's responsibility to maintain any necessary mappings.
Args:
hashes: A list of Hash objects t... | def CheckHashes(self, hashes, unused_external=True):
"""Checks a list of hashes for presence in the store.
Only unique sha1 hashes are checked, if there is duplication in the hashes
input it is the caller's responsibility to maintain any necessary mappings.
Args:
hashes: A list of Hash objects t... | [
"Checks",
"a",
"list",
"of",
"hashes",
"for",
"presence",
"in",
"the",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L568-L589 | [
"def",
"CheckHashes",
"(",
"self",
",",
"hashes",
",",
"unused_external",
"=",
"True",
")",
":",
"hash_map",
"=",
"{",
"}",
"for",
"hsh",
"in",
"hashes",
":",
"if",
"hsh",
".",
"HasField",
"(",
"\"sha1\"",
")",
":",
"hash_urn",
"=",
"self",
".",
"PAT... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | NSRLFileStore.AddHash | Adds a new file from the NSRL hash database.
We create a new subject in:
aff4:/files/nsrl/<sha1>
with all the other arguments as attributes.
Args:
sha1: SHA1 digest as a hex encoded string.
md5: MD5 digest as a hex encoded string.
crc: File CRC as an integer.
file_name: Filen... | grr/server/grr_response_server/aff4_objects/filestore.py | def AddHash(self, sha1, md5, crc, file_name, file_size, product_code_list,
op_system_code_list, special_code):
"""Adds a new file from the NSRL hash database.
We create a new subject in:
aff4:/files/nsrl/<sha1>
with all the other arguments as attributes.
Args:
sha1: SHA1 dige... | def AddHash(self, sha1, md5, crc, file_name, file_size, product_code_list,
op_system_code_list, special_code):
"""Adds a new file from the NSRL hash database.
We create a new subject in:
aff4:/files/nsrl/<sha1>
with all the other arguments as attributes.
Args:
sha1: SHA1 dige... | [
"Adds",
"a",
"new",
"file",
"from",
"the",
"NSRL",
"hash",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L591-L624 | [
"def",
"AddHash",
"(",
"self",
",",
"sha1",
",",
"md5",
",",
"crc",
",",
"file_name",
",",
"file_size",
",",
"product_code_list",
",",
"op_system_code_list",
",",
"special_code",
")",
":",
"file_store_urn",
"=",
"self",
".",
"PATH",
".",
"Add",
"(",
"sha1"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FileStoreInit.Run | Create FileStore and HashFileStore namespaces. | grr/server/grr_response_server/aff4_objects/filestore.py | def Run(self):
"""Create FileStore and HashFileStore namespaces."""
if not data_store.AFF4Enabled():
return
try:
filestore = aff4.FACTORY.Create(
FileStore.PATH, FileStore, mode="rw", token=aff4.FACTORY.root_token)
filestore.Close()
hash_filestore = aff4.FACTORY.Create(
... | def Run(self):
"""Create FileStore and HashFileStore namespaces."""
if not data_store.AFF4Enabled():
return
try:
filestore = aff4.FACTORY.Create(
FileStore.PATH, FileStore, mode="rw", token=aff4.FACTORY.root_token)
filestore.Close()
hash_filestore = aff4.FACTORY.Create(
... | [
"Create",
"FileStore",
"and",
"HashFileStore",
"namespaces",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L636-L660 | [
"def",
"Run",
"(",
"self",
")",
":",
"if",
"not",
"data_store",
".",
"AFF4Enabled",
"(",
")",
":",
"return",
"try",
":",
"filestore",
"=",
"aff4",
".",
"FACTORY",
".",
"Create",
"(",
"FileStore",
".",
"PATH",
",",
"FileStore",
",",
"mode",
"=",
"\"rw... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLDBArtifactsMixin.WriteArtifact | Writes new artifact to the database. | grr/server/grr_response_server/databases/mysql_artifacts.py | def WriteArtifact(self, artifact, cursor=None):
"""Writes new artifact to the database."""
name = Text(artifact.name)
try:
cursor.execute("INSERT INTO artifacts (name, definition) VALUES (%s, %s)",
[name, artifact.SerializeToString()])
except MySQLdb.IntegrityError as error:
... | def WriteArtifact(self, artifact, cursor=None):
"""Writes new artifact to the database."""
name = Text(artifact.name)
try:
cursor.execute("INSERT INTO artifacts (name, definition) VALUES (%s, %s)",
[name, artifact.SerializeToString()])
except MySQLdb.IntegrityError as error:
... | [
"Writes",
"new",
"artifact",
"to",
"the",
"database",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_artifacts.py#L24-L35 | [
"def",
"WriteArtifact",
"(",
"self",
",",
"artifact",
",",
"cursor",
"=",
"None",
")",
":",
"name",
"=",
"Text",
"(",
"artifact",
".",
"name",
")",
"try",
":",
"cursor",
".",
"execute",
"(",
"\"INSERT INTO artifacts (name, definition) VALUES (%s, %s)\"",
",",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLDBArtifactsMixin.ReadArtifact | Looks up an artifact with given name from the database. | grr/server/grr_response_server/databases/mysql_artifacts.py | def ReadArtifact(self, name, cursor=None):
"""Looks up an artifact with given name from the database."""
cursor.execute("SELECT definition FROM artifacts WHERE name = %s", [name])
row = cursor.fetchone()
if row is None:
raise db.UnknownArtifactError(name)
else:
return _RowToArtifact(row... | def ReadArtifact(self, name, cursor=None):
"""Looks up an artifact with given name from the database."""
cursor.execute("SELECT definition FROM artifacts WHERE name = %s", [name])
row = cursor.fetchone()
if row is None:
raise db.UnknownArtifactError(name)
else:
return _RowToArtifact(row... | [
"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/mysql_artifacts.py#L38-L46 | [
"def",
"ReadArtifact",
"(",
"self",
",",
"name",
",",
"cursor",
"=",
"None",
")",
":",
"cursor",
".",
"execute",
"(",
"\"SELECT definition FROM artifacts WHERE name = %s\"",
",",
"[",
"name",
"]",
")",
"row",
"=",
"cursor",
".",
"fetchone",
"(",
")",
"if",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLDBArtifactsMixin.ReadAllArtifacts | Lists all artifacts that are stored in the database. | grr/server/grr_response_server/databases/mysql_artifacts.py | def ReadAllArtifacts(self, cursor=None):
"""Lists all artifacts that are stored in the database."""
cursor.execute("SELECT definition FROM artifacts")
return [_RowToArtifact(row) for row in cursor.fetchall()] | def ReadAllArtifacts(self, cursor=None):
"""Lists all artifacts that are stored in the database."""
cursor.execute("SELECT definition FROM artifacts")
return [_RowToArtifact(row) for row in cursor.fetchall()] | [
"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/mysql_artifacts.py#L49-L52 | [
"def",
"ReadAllArtifacts",
"(",
"self",
",",
"cursor",
"=",
"None",
")",
":",
"cursor",
".",
"execute",
"(",
"\"SELECT definition FROM artifacts\"",
")",
"return",
"[",
"_RowToArtifact",
"(",
"row",
")",
"for",
"row",
"in",
"cursor",
".",
"fetchall",
"(",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MySQLDBArtifactsMixin.DeleteArtifact | Deletes an artifact with given name from the database. | grr/server/grr_response_server/databases/mysql_artifacts.py | def DeleteArtifact(self, name, cursor=None):
"""Deletes an artifact with given name from the database."""
cursor.execute("DELETE FROM artifacts WHERE name = %s", [name])
if cursor.rowcount == 0:
raise db.UnknownArtifactError(name) | def DeleteArtifact(self, name, cursor=None):
"""Deletes an artifact with given name from the database."""
cursor.execute("DELETE FROM artifacts WHERE name = %s", [name])
if cursor.rowcount == 0:
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/mysql_artifacts.py#L55-L61 | [
"def",
"DeleteArtifact",
"(",
"self",
",",
"name",
",",
"cursor",
"=",
"None",
")",
":",
"cursor",
".",
"execute",
"(",
"\"DELETE FROM artifacts WHERE name = %s\"",
",",
"[",
"name",
"]",
")",
"if",
"cursor",
".",
"rowcount",
"==",
"0",
":",
"raise",
"db",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | Enroler.ProcessMessage | Begins an enrollment flow for this client.
Args:
message: The Certificate sent by the client. Note that this message is
not authenticated. | grr/server/grr_response_server/flows/general/ca_enroller.py | def ProcessMessage(self, message):
"""Begins an enrollment flow for this client.
Args:
message: The Certificate sent by the client. Note that this message is
not authenticated.
"""
cert = rdf_crypto.Certificate(message.payload)
queue = self.well_known_session_id.Queue()
clie... | def ProcessMessage(self, message):
"""Begins an enrollment flow for this client.
Args:
message: The Certificate sent by the client. Note that this message is
not authenticated.
"""
cert = rdf_crypto.Certificate(message.payload)
queue = self.well_known_session_id.Queue()
clie... | [
"Begins",
"an",
"enrollment",
"flow",
"for",
"this",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/ca_enroller.py#L107-L158 | [
"def",
"ProcessMessage",
"(",
"self",
",",
"message",
")",
":",
"cert",
"=",
"rdf_crypto",
".",
"Certificate",
"(",
"message",
".",
"payload",
")",
"queue",
"=",
"self",
".",
"well_known_session_id",
".",
"Queue",
"(",
")",
"client_id",
"=",
"message",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFleetspeakClient.Run | The main run method of the client. | grr/client/grr_response_client/fleetspeak_client.py | def Run(self):
"""The main run method of the client."""
for thread in itervalues(self._threads):
thread.start()
logging.info(START_STRING)
while True:
dead_threads = [
tn for (tn, t) in iteritems(self._threads) if not t.isAlive()
]
if dead_threads:
raise FatalE... | def Run(self):
"""The main run method of the client."""
for thread in itervalues(self._threads):
thread.start()
logging.info(START_STRING)
while True:
dead_threads = [
tn for (tn, t) in iteritems(self._threads) if not t.isAlive()
]
if dead_threads:
raise FatalE... | [
"The",
"main",
"run",
"method",
"of",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/fleetspeak_client.py#L107-L120 | [
"def",
"Run",
"(",
"self",
")",
":",
"for",
"thread",
"in",
"itervalues",
"(",
"self",
".",
"_threads",
")",
":",
"thread",
".",
"start",
"(",
")",
"logging",
".",
"info",
"(",
"START_STRING",
")",
"while",
"True",
":",
"dead_threads",
"=",
"[",
"tn"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFleetspeakClient._ForemanOp | Sends Foreman checks periodically. | grr/client/grr_response_client/fleetspeak_client.py | def _ForemanOp(self):
"""Sends Foreman checks periodically."""
period = config.CONFIG["Client.foreman_check_frequency"]
self._threads["Worker"].SendReply(
rdf_protodict.DataBlob(),
session_id=rdfvalue.FlowSessionID(flow_name="Foreman"),
require_fastpoll=False)
time.sleep(period) | def _ForemanOp(self):
"""Sends Foreman checks periodically."""
period = config.CONFIG["Client.foreman_check_frequency"]
self._threads["Worker"].SendReply(
rdf_protodict.DataBlob(),
session_id=rdfvalue.FlowSessionID(flow_name="Foreman"),
require_fastpoll=False)
time.sleep(period) | [
"Sends",
"Foreman",
"checks",
"periodically",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/fleetspeak_client.py#L122-L129 | [
"def",
"_ForemanOp",
"(",
"self",
")",
":",
"period",
"=",
"config",
".",
"CONFIG",
"[",
"\"Client.foreman_check_frequency\"",
"]",
"self",
".",
"_threads",
"[",
"\"Worker\"",
"]",
".",
"SendReply",
"(",
"rdf_protodict",
".",
"DataBlob",
"(",
")",
",",
"sess... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFleetspeakClient._SendMessages | Sends a block of messages through Fleetspeak. | grr/client/grr_response_client/fleetspeak_client.py | def _SendMessages(self, grr_msgs, background=False):
"""Sends a block of messages through Fleetspeak."""
message_list = rdf_flows.PackedMessageList()
communicator.Communicator.EncodeMessageList(
rdf_flows.MessageList(job=grr_msgs), message_list)
fs_msg = fs_common_pb2.Message(
message_ty... | def _SendMessages(self, grr_msgs, background=False):
"""Sends a block of messages through Fleetspeak."""
message_list = rdf_flows.PackedMessageList()
communicator.Communicator.EncodeMessageList(
rdf_flows.MessageList(job=grr_msgs), message_list)
fs_msg = fs_common_pb2.Message(
message_ty... | [
"Sends",
"a",
"block",
"of",
"messages",
"through",
"Fleetspeak",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/fleetspeak_client.py#L131-L149 | [
"def",
"_SendMessages",
"(",
"self",
",",
"grr_msgs",
",",
"background",
"=",
"False",
")",
":",
"message_list",
"=",
"rdf_flows",
".",
"PackedMessageList",
"(",
")",
"communicator",
".",
"Communicator",
".",
"EncodeMessageList",
"(",
"rdf_flows",
".",
"MessageL... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFleetspeakClient._SendOp | Sends messages through Fleetspeak. | grr/client/grr_response_client/fleetspeak_client.py | def _SendOp(self):
"""Sends messages through Fleetspeak."""
msg = self._sender_queue.get()
msgs = []
background_msgs = []
if not msg.require_fastpoll:
background_msgs.append(msg)
else:
msgs.append(msg)
count = 1
size = len(msg.SerializeToString())
while count < 100 and ... | def _SendOp(self):
"""Sends messages through Fleetspeak."""
msg = self._sender_queue.get()
msgs = []
background_msgs = []
if not msg.require_fastpoll:
background_msgs.append(msg)
else:
msgs.append(msg)
count = 1
size = len(msg.SerializeToString())
while count < 100 and ... | [
"Sends",
"messages",
"through",
"Fleetspeak",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/fleetspeak_client.py#L151-L179 | [
"def",
"_SendOp",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"_sender_queue",
".",
"get",
"(",
")",
"msgs",
"=",
"[",
"]",
"background_msgs",
"=",
"[",
"]",
"if",
"not",
"msg",
".",
"require_fastpoll",
":",
"background_msgs",
".",
"append",
"(",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFleetspeakClient._ReceiveOp | Receives a single message through Fleetspeak. | grr/client/grr_response_client/fleetspeak_client.py | def _ReceiveOp(self):
"""Receives a single message through Fleetspeak."""
try:
fs_msg, received_bytes = self._fs.Recv()
except (IOError, struct.error):
logging.critical("Broken local Fleetspeak connection (read end).")
raise
received_type = fs_msg.data.TypeName()
if not received_t... | def _ReceiveOp(self):
"""Receives a single message through Fleetspeak."""
try:
fs_msg, received_bytes = self._fs.Recv()
except (IOError, struct.error):
logging.critical("Broken local Fleetspeak connection (read end).")
raise
received_type = fs_msg.data.TypeName()
if not received_t... | [
"Receives",
"a",
"single",
"message",
"through",
"Fleetspeak",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/fleetspeak_client.py#L181-L202 | [
"def",
"_ReceiveOp",
"(",
"self",
")",
":",
"try",
":",
"fs_msg",
",",
"received_bytes",
"=",
"self",
".",
"_fs",
".",
"Recv",
"(",
")",
"except",
"(",
"IOError",
",",
"struct",
".",
"error",
")",
":",
"logging",
".",
"critical",
"(",
"\"Broken local F... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | DeleteArtifactsFromDatastore | Deletes a list of artifacts from the data store. | grr/server/grr_response_server/artifact_registry.py | def DeleteArtifactsFromDatastore(artifact_names, reload_artifacts=True):
"""Deletes a list of artifacts from the data store."""
artifacts_list = sorted(
REGISTRY.GetArtifacts(reload_datastore_artifacts=reload_artifacts))
to_delete = set(artifact_names)
deps = set()
for artifact_obj in artifacts_list:
... | def DeleteArtifactsFromDatastore(artifact_names, reload_artifacts=True):
"""Deletes a list of artifacts from the data store."""
artifacts_list = sorted(
REGISTRY.GetArtifacts(reload_datastore_artifacts=reload_artifacts))
to_delete = set(artifact_names)
deps = set()
for artifact_obj in artifacts_list:
... | [
"Deletes",
"a",
"list",
"of",
"artifacts",
"from",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L522-L572 | [
"def",
"DeleteArtifactsFromDatastore",
"(",
"artifact_names",
",",
"reload_artifacts",
"=",
"True",
")",
":",
"artifacts_list",
"=",
"sorted",
"(",
"REGISTRY",
".",
"GetArtifacts",
"(",
"reload_datastore_artifacts",
"=",
"reload_artifacts",
")",
")",
"to_delete",
"=",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValidateSyntax | Validates artifact syntax.
This method can be used to validate individual artifacts as they are loaded,
without needing all artifacts to be loaded first, as for Validate().
Args:
rdf_artifact: RDF object artifact.
Raises:
ArtifactSyntaxError: If artifact syntax is invalid. | grr/server/grr_response_server/artifact_registry.py | def ValidateSyntax(rdf_artifact):
"""Validates artifact syntax.
This method can be used to validate individual artifacts as they are loaded,
without needing all artifacts to be loaded first, as for Validate().
Args:
rdf_artifact: RDF object artifact.
Raises:
ArtifactSyntaxError: If artifact syntax ... | def ValidateSyntax(rdf_artifact):
"""Validates artifact syntax.
This method can be used to validate individual artifacts as they are loaded,
without needing all artifacts to be loaded first, as for Validate().
Args:
rdf_artifact: RDF object artifact.
Raises:
ArtifactSyntaxError: If artifact syntax ... | [
"Validates",
"artifact",
"syntax",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L575-L629 | [
"def",
"ValidateSyntax",
"(",
"rdf_artifact",
")",
":",
"if",
"not",
"rdf_artifact",
".",
"doc",
":",
"raise",
"rdf_artifacts",
".",
"ArtifactSyntaxError",
"(",
"rdf_artifact",
",",
"\"missing doc\"",
")",
"for",
"supp_os",
"in",
"rdf_artifact",
".",
"supported_os... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ValidateDependencies | Validates artifact dependencies.
This method checks whether all dependencies of the artifact are present
and contain no errors.
This method can be called only after all other artifacts have been loaded.
Args:
rdf_artifact: RDF object artifact.
Raises:
ArtifactDependencyError: If a dependency is mi... | grr/server/grr_response_server/artifact_registry.py | def ValidateDependencies(rdf_artifact):
"""Validates artifact dependencies.
This method checks whether all dependencies of the artifact are present
and contain no errors.
This method can be called only after all other artifacts have been loaded.
Args:
rdf_artifact: RDF object artifact.
Raises:
A... | def ValidateDependencies(rdf_artifact):
"""Validates artifact dependencies.
This method checks whether all dependencies of the artifact are present
and contain no errors.
This method can be called only after all other artifacts have been loaded.
Args:
rdf_artifact: RDF object artifact.
Raises:
A... | [
"Validates",
"artifact",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L632-L656 | [
"def",
"ValidateDependencies",
"(",
"rdf_artifact",
")",
":",
"for",
"dependency",
"in",
"GetArtifactDependencies",
"(",
"rdf_artifact",
")",
":",
"try",
":",
"dependency_obj",
"=",
"REGISTRY",
".",
"GetArtifact",
"(",
"dependency",
")",
"except",
"rdf_artifacts",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactDependencies | Return a set of artifact dependencies.
Args:
rdf_artifact: RDF object artifact.
recursive: If True recurse into dependencies to find their dependencies.
depth: Used for limiting recursion depth.
Returns:
A set of strings containing the dependent artifact names.
Raises:
RuntimeError: If maxi... | grr/server/grr_response_server/artifact_registry.py | def GetArtifactDependencies(rdf_artifact, recursive=False, depth=1):
"""Return a set of artifact dependencies.
Args:
rdf_artifact: RDF object artifact.
recursive: If True recurse into dependencies to find their dependencies.
depth: Used for limiting recursion depth.
Returns:
A set of strings con... | def GetArtifactDependencies(rdf_artifact, recursive=False, depth=1):
"""Return a set of artifact dependencies.
Args:
rdf_artifact: RDF object artifact.
recursive: If True recurse into dependencies to find their dependencies.
depth: Used for limiting recursion depth.
Returns:
A set of strings con... | [
"Return",
"a",
"set",
"of",
"artifact",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L675-L710 | [
"def",
"GetArtifactDependencies",
"(",
"rdf_artifact",
",",
"recursive",
"=",
"False",
",",
"depth",
"=",
"1",
")",
":",
"deps",
"=",
"set",
"(",
")",
"for",
"source",
"in",
"rdf_artifact",
".",
"sources",
":",
"# ARTIFACT is the legacy name for ARTIFACT_GROUP",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactsDependenciesClosure | For all the artifacts in the list returns them and their dependencies. | grr/server/grr_response_server/artifact_registry.py | def GetArtifactsDependenciesClosure(name_list, os_name=None):
"""For all the artifacts in the list returns them and their dependencies."""
artifacts = set(REGISTRY.GetArtifacts(os_name=os_name, name_list=name_list))
dependencies = set()
for art in artifacts:
dependencies.update(GetArtifactDependencies(art... | def GetArtifactsDependenciesClosure(name_list, os_name=None):
"""For all the artifacts in the list returns them and their dependencies."""
artifacts = set(REGISTRY.GetArtifacts(os_name=os_name, name_list=name_list))
dependencies = set()
for art in artifacts:
dependencies.update(GetArtifactDependencies(art... | [
"For",
"all",
"the",
"artifacts",
"in",
"the",
"list",
"returns",
"them",
"and",
"their",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L715-L729 | [
"def",
"GetArtifactsDependenciesClosure",
"(",
"name_list",
",",
"os_name",
"=",
"None",
")",
":",
"artifacts",
"=",
"set",
"(",
"REGISTRY",
".",
"GetArtifacts",
"(",
"os_name",
"=",
"os_name",
",",
"name_list",
"=",
"name_list",
")",
")",
"dependencies",
"=",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactPathDependencies | Return a set of knowledgebase path dependencies.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"] | grr/server/grr_response_server/artifact_registry.py | def GetArtifactPathDependencies(rdf_artifact):
"""Return a set of knowledgebase path dependencies.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"]
"""
deps = set()
for source in rdf_artifact.sources:
for ar... | def GetArtifactPathDependencies(rdf_artifact):
"""Return a set of knowledgebase path dependencies.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"]
"""
deps = set()
for source in rdf_artifact.sources:
for ar... | [
"Return",
"a",
"set",
"of",
"knowledgebase",
"path",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L732-L757 | [
"def",
"GetArtifactPathDependencies",
"(",
"rdf_artifact",
")",
":",
"deps",
"=",
"set",
"(",
")",
"for",
"source",
"in",
"rdf_artifact",
".",
"sources",
":",
"for",
"arg",
",",
"value",
"in",
"iteritems",
"(",
"source",
".",
"attributes",
")",
":",
"paths... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetArtifactParserDependencies | Return the set of knowledgebase path dependencies required by the parser.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"] | grr/server/grr_response_server/artifact_registry.py | def GetArtifactParserDependencies(rdf_artifact):
"""Return the set of knowledgebase path dependencies required by the parser.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"]
"""
deps = set()
processors = parser... | def GetArtifactParserDependencies(rdf_artifact):
"""Return the set of knowledgebase path dependencies required by the parser.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"]
"""
deps = set()
processors = parser... | [
"Return",
"the",
"set",
"of",
"knowledgebase",
"path",
"dependencies",
"required",
"by",
"the",
"parser",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L760-L774 | [
"def",
"GetArtifactParserDependencies",
"(",
"rdf_artifact",
")",
":",
"deps",
"=",
"set",
"(",
")",
"processors",
"=",
"parser",
".",
"Parser",
".",
"GetClassesByArtifact",
"(",
"rdf_artifact",
".",
"name",
")",
"for",
"p",
"in",
"processors",
":",
"deps",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistrySources.AddDir | Adds a directory path as a source.
Args:
dirpath: a string representing a path to the directory.
Returns:
True if the directory is not an already existing source. | grr/server/grr_response_server/artifact_registry.py | def AddDir(self, dirpath):
"""Adds a directory path as a source.
Args:
dirpath: a string representing a path to the directory.
Returns:
True if the directory is not an already existing source.
"""
if dirpath not in self._dirs:
self._dirs.add(dirpath)
return True
return ... | def AddDir(self, dirpath):
"""Adds a directory path as a source.
Args:
dirpath: a string representing a path to the directory.
Returns:
True if the directory is not an already existing source.
"""
if dirpath not in self._dirs:
self._dirs.add(dirpath)
return True
return ... | [
"Adds",
"a",
"directory",
"path",
"as",
"a",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L40-L52 | [
"def",
"AddDir",
"(",
"self",
",",
"dirpath",
")",
":",
"if",
"dirpath",
"not",
"in",
"self",
".",
"_dirs",
":",
"self",
".",
"_dirs",
".",
"add",
"(",
"dirpath",
")",
"return",
"True",
"return",
"False"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistrySources.AddFile | Adds a file path as a source.
Args:
filepath: a string representing a path to the file.
Returns:
True if the file is not an already existing source. | grr/server/grr_response_server/artifact_registry.py | def AddFile(self, filepath):
"""Adds a file path as a source.
Args:
filepath: a string representing a path to the file.
Returns:
True if the file is not an already existing source.
"""
if filepath not in self._files:
self._files.add(filepath)
return True
return False | def AddFile(self, filepath):
"""Adds a file path as a source.
Args:
filepath: a string representing a path to the file.
Returns:
True if the file is not an already existing source.
"""
if filepath not in self._files:
self._files.add(filepath)
return True
return False | [
"Adds",
"a",
"file",
"path",
"as",
"a",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L54-L66 | [
"def",
"AddFile",
"(",
"self",
",",
"filepath",
")",
":",
"if",
"filepath",
"not",
"in",
"self",
".",
"_files",
":",
"self",
".",
"_files",
".",
"add",
"(",
"filepath",
")",
"return",
"True",
"return",
"False"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistrySources.AddDatastore | Adds a datastore URN as a source.
Args:
urn: an RDF URN value of the datastore.
Returns:
True if the datastore is not an already existing source. | grr/server/grr_response_server/artifact_registry.py | def AddDatastore(self, urn):
"""Adds a datastore URN as a source.
Args:
urn: an RDF URN value of the datastore.
Returns:
True if the datastore is not an already existing source.
"""
if urn not in self._datastores:
self._datastores.add(urn)
return True
return False | def AddDatastore(self, urn):
"""Adds a datastore URN as a source.
Args:
urn: an RDF URN value of the datastore.
Returns:
True if the datastore is not an already existing source.
"""
if urn not in self._datastores:
self._datastores.add(urn)
return True
return False | [
"Adds",
"a",
"datastore",
"URN",
"as",
"a",
"source",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L68-L80 | [
"def",
"AddDatastore",
"(",
"self",
",",
"urn",
")",
":",
"if",
"urn",
"not",
"in",
"self",
".",
"_datastores",
":",
"self",
".",
"_datastores",
".",
"add",
"(",
"urn",
")",
"return",
"True",
"return",
"False"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistrySources.GetAllFiles | Yields all defined source file paths.
This includes file paths defined directly and those defined implicitly by
defining a directory. | grr/server/grr_response_server/artifact_registry.py | def GetAllFiles(self):
"""Yields all defined source file paths.
This includes file paths defined directly and those defined implicitly by
defining a directory.
"""
for filepath in self._files:
yield filepath
for dirpath in self._dirs:
for filepath in ArtifactRegistrySources._GetDir... | def GetAllFiles(self):
"""Yields all defined source file paths.
This includes file paths defined directly and those defined implicitly by
defining a directory.
"""
for filepath in self._files:
yield filepath
for dirpath in self._dirs:
for filepath in ArtifactRegistrySources._GetDir... | [
"Yields",
"all",
"defined",
"source",
"file",
"paths",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L99-L112 | [
"def",
"GetAllFiles",
"(",
"self",
")",
":",
"for",
"filepath",
"in",
"self",
".",
"_files",
":",
"yield",
"filepath",
"for",
"dirpath",
"in",
"self",
".",
"_dirs",
":",
"for",
"filepath",
"in",
"ArtifactRegistrySources",
".",
"_GetDirYamlFiles",
"(",
"dirpa... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry._LoadArtifactsFromDatastore | Load artifacts from the data store. | grr/server/grr_response_server/artifact_registry.py | def _LoadArtifactsFromDatastore(self):
"""Load artifacts from the data store."""
loaded_artifacts = []
# TODO(hanuszczak): Why do we have to remove anything? If some artifact
# tries to shadow system artifact shouldn't we just ignore them and perhaps
# issue some warning instead? The datastore bein... | def _LoadArtifactsFromDatastore(self):
"""Load artifacts from the data store."""
loaded_artifacts = []
# TODO(hanuszczak): Why do we have to remove anything? If some artifact
# tries to shadow system artifact shouldn't we just ignore them and perhaps
# issue some warning instead? The datastore bein... | [
"Load",
"artifacts",
"from",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L135-L196 | [
"def",
"_LoadArtifactsFromDatastore",
"(",
"self",
")",
":",
"loaded_artifacts",
"=",
"[",
"]",
"# TODO(hanuszczak): Why do we have to remove anything? If some artifact",
"# tries to shadow system artifact shouldn't we just ignore them and perhaps",
"# issue some warning instead? The datasto... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.ArtifactsFromYaml | Get a list of Artifacts from yaml. | grr/server/grr_response_server/artifact_registry.py | def ArtifactsFromYaml(self, yaml_content):
"""Get a list of Artifacts from yaml."""
raw_list = yaml.ParseMany(yaml_content)
# TODO(hanuszczak): I am very sceptical about that "doing the right thing"
# below. What are the real use cases?
# Try to do the right thing with json/yaml formatted as a lis... | def ArtifactsFromYaml(self, yaml_content):
"""Get a list of Artifacts from yaml."""
raw_list = yaml.ParseMany(yaml_content)
# TODO(hanuszczak): I am very sceptical about that "doing the right thing"
# below. What are the real use cases?
# Try to do the right thing with json/yaml formatted as a lis... | [
"Get",
"a",
"list",
"of",
"Artifacts",
"from",
"yaml",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L199-L227 | [
"def",
"ArtifactsFromYaml",
"(",
"self",
",",
"yaml_content",
")",
":",
"raw_list",
"=",
"yaml",
".",
"ParseMany",
"(",
"yaml_content",
")",
"# TODO(hanuszczak): I am very sceptical about that \"doing the right thing\"",
"# below. What are the real use cases?",
"# Try to do the r... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry._LoadArtifactsFromFiles | Load artifacts from file paths as json or yaml. | grr/server/grr_response_server/artifact_registry.py | def _LoadArtifactsFromFiles(self, file_paths, overwrite_if_exists=True):
"""Load artifacts from file paths as json or yaml."""
loaded_files = []
loaded_artifacts = []
for file_path in file_paths:
try:
with io.open(file_path, mode="r", encoding="utf-8") as fh:
logging.debug("Loadi... | def _LoadArtifactsFromFiles(self, file_paths, overwrite_if_exists=True):
"""Load artifacts from file paths as json or yaml."""
loaded_files = []
loaded_artifacts = []
for file_path in file_paths:
try:
with io.open(file_path, mode="r", encoding="utf-8") as fh:
logging.debug("Loadi... | [
"Load",
"artifacts",
"from",
"file",
"paths",
"as",
"json",
"or",
"yaml",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L229-L256 | [
"def",
"_LoadArtifactsFromFiles",
"(",
"self",
",",
"file_paths",
",",
"overwrite_if_exists",
"=",
"True",
")",
":",
"loaded_files",
"=",
"[",
"]",
"loaded_artifacts",
"=",
"[",
"]",
"for",
"file_path",
"in",
"file_paths",
":",
"try",
":",
"with",
"io",
".",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.RegisterArtifact | Registers a new artifact. | grr/server/grr_response_server/artifact_registry.py | def RegisterArtifact(self,
artifact_rdfvalue,
source="datastore",
overwrite_if_exists=False,
overwrite_system_artifacts=False):
"""Registers a new artifact."""
artifact_name = artifact_rdfvalue.name
if artifact_name ... | def RegisterArtifact(self,
artifact_rdfvalue,
source="datastore",
overwrite_if_exists=False,
overwrite_system_artifacts=False):
"""Registers a new artifact."""
artifact_name = artifact_rdfvalue.name
if artifact_name ... | [
"Registers",
"a",
"new",
"artifact",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L293-L316 | [
"def",
"RegisterArtifact",
"(",
"self",
",",
"artifact_rdfvalue",
",",
"source",
"=",
"\"datastore\"",
",",
"overwrite_if_exists",
"=",
"False",
",",
"overwrite_system_artifacts",
"=",
"False",
")",
":",
"artifact_name",
"=",
"artifact_rdfvalue",
".",
"name",
"if",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry._ReloadArtifacts | Load artifacts from all sources. | grr/server/grr_response_server/artifact_registry.py | def _ReloadArtifacts(self):
"""Load artifacts from all sources."""
self._artifacts = {}
self._LoadArtifactsFromFiles(self._sources.GetAllFiles())
self.ReloadDatastoreArtifacts() | def _ReloadArtifacts(self):
"""Load artifacts from all sources."""
self._artifacts = {}
self._LoadArtifactsFromFiles(self._sources.GetAllFiles())
self.ReloadDatastoreArtifacts() | [
"Load",
"artifacts",
"from",
"all",
"sources",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L330-L334 | [
"def",
"_ReloadArtifacts",
"(",
"self",
")",
":",
"self",
".",
"_artifacts",
"=",
"{",
"}",
"self",
".",
"_LoadArtifactsFromFiles",
"(",
"self",
".",
"_sources",
".",
"GetAllFiles",
"(",
")",
")",
"self",
".",
"ReloadDatastoreArtifacts",
"(",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry._UnregisterDatastoreArtifacts | Remove artifacts that came from the datastore. | grr/server/grr_response_server/artifact_registry.py | def _UnregisterDatastoreArtifacts(self):
"""Remove artifacts that came from the datastore."""
to_remove = []
for name, artifact in iteritems(self._artifacts):
if artifact.loaded_from.startswith("datastore"):
to_remove.append(name)
for key in to_remove:
self._artifacts.pop(key) | def _UnregisterDatastoreArtifacts(self):
"""Remove artifacts that came from the datastore."""
to_remove = []
for name, artifact in iteritems(self._artifacts):
if artifact.loaded_from.startswith("datastore"):
to_remove.append(name)
for key in to_remove:
self._artifacts.pop(key) | [
"Remove",
"artifacts",
"that",
"came",
"from",
"the",
"datastore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L336-L343 | [
"def",
"_UnregisterDatastoreArtifacts",
"(",
"self",
")",
":",
"to_remove",
"=",
"[",
"]",
"for",
"name",
",",
"artifact",
"in",
"iteritems",
"(",
"self",
".",
"_artifacts",
")",
":",
"if",
"artifact",
".",
"loaded_from",
".",
"startswith",
"(",
"\"datastore... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.GetArtifacts | Retrieve artifact classes with optional filtering.
All filters must match for the artifact to be returned.
Args:
os_name: string to match against supported_os
name_list: list of strings to match against artifact names
source_type: rdf_artifacts.ArtifactSource.SourceType to match against
... | grr/server/grr_response_server/artifact_registry.py | def GetArtifacts(self,
os_name=None,
name_list=None,
source_type=None,
exclude_dependents=False,
provides=None,
reload_datastore_artifacts=False):
"""Retrieve artifact classes with optional filtering.
... | def GetArtifacts(self,
os_name=None,
name_list=None,
source_type=None,
exclude_dependents=False,
provides=None,
reload_datastore_artifacts=False):
"""Retrieve artifact classes with optional filtering.
... | [
"Retrieve",
"artifact",
"classes",
"with",
"optional",
"filtering",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L360-L411 | [
"def",
"GetArtifacts",
"(",
"self",
",",
"os_name",
"=",
"None",
",",
"name_list",
"=",
"None",
",",
"source_type",
"=",
"None",
",",
"exclude_dependents",
"=",
"False",
",",
"provides",
"=",
"None",
",",
"reload_datastore_artifacts",
"=",
"False",
")",
":",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.GetArtifact | Get artifact by name.
Args:
name: artifact name string.
Returns:
artifact object.
Raises:
ArtifactNotRegisteredError: if artifact doesn't exist in the registy. | grr/server/grr_response_server/artifact_registry.py | def GetArtifact(self, name):
"""Get artifact by name.
Args:
name: artifact name string.
Returns:
artifact object.
Raises:
ArtifactNotRegisteredError: if artifact doesn't exist in the registy.
"""
self._CheckDirty()
result = self._artifacts.get(name)
if not result:
... | def GetArtifact(self, name):
"""Get artifact by name.
Args:
name: artifact name string.
Returns:
artifact object.
Raises:
ArtifactNotRegisteredError: if artifact doesn't exist in the registy.
"""
self._CheckDirty()
result = self._artifacts.get(name)
if not result:
... | [
"Get",
"artifact",
"by",
"name",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L418-L435 | [
"def",
"GetArtifact",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_CheckDirty",
"(",
")",
"result",
"=",
"self",
".",
"_artifacts",
".",
"get",
"(",
"name",
")",
"if",
"not",
"result",
":",
"raise",
"rdf_artifacts",
".",
"ArtifactNotRegisteredError",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.SearchDependencies | Return a set of artifact names needed to fulfill dependencies.
Search the path dependency tree for all artifacts that can fulfill
dependencies of artifact_name_list. If multiple artifacts provide a
dependency, they are all included.
Args:
os_name: operating system string
artifact_name_lis... | grr/server/grr_response_server/artifact_registry.py | def SearchDependencies(self,
os_name,
artifact_name_list,
existing_artifact_deps=None,
existing_expansion_deps=None):
"""Return a set of artifact names needed to fulfill dependencies.
Search the path dependency ... | def SearchDependencies(self,
os_name,
artifact_name_list,
existing_artifact_deps=None,
existing_expansion_deps=None):
"""Return a set of artifact names needed to fulfill dependencies.
Search the path dependency ... | [
"Return",
"a",
"set",
"of",
"artifact",
"names",
"needed",
"to",
"fulfill",
"dependencies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L442-L491 | [
"def",
"SearchDependencies",
"(",
"self",
",",
"os_name",
",",
"artifact_name_list",
",",
"existing_artifact_deps",
"=",
"None",
",",
"existing_expansion_deps",
"=",
"None",
")",
":",
"artifact_deps",
"=",
"existing_artifact_deps",
"or",
"set",
"(",
")",
"expansion_... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ArtifactRegistry.DumpArtifactsToYaml | Dump a list of artifacts into a yaml string. | grr/server/grr_response_server/artifact_registry.py | def DumpArtifactsToYaml(self, sort_by_os=True):
"""Dump a list of artifacts into a yaml string."""
artifact_list = self.GetArtifacts()
if sort_by_os:
# Sort so its easier to split these if necessary.
yaml_list = []
done_set = set()
for os_name in rdf_artifacts.Artifact.SUPPORTED_OS_L... | def DumpArtifactsToYaml(self, sort_by_os=True):
"""Dump a list of artifacts into a yaml string."""
artifact_list = self.GetArtifacts()
if sort_by_os:
# Sort so its easier to split these if necessary.
yaml_list = []
done_set = set()
for os_name in rdf_artifacts.Artifact.SUPPORTED_OS_L... | [
"Dump",
"a",
"list",
"of",
"artifacts",
"into",
"a",
"yaml",
"string",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L494-L512 | [
"def",
"DumpArtifactsToYaml",
"(",
"self",
",",
"sort_by_os",
"=",
"True",
")",
":",
"artifact_list",
"=",
"self",
".",
"GetArtifacts",
"(",
")",
"if",
"sort_by_os",
":",
"# Sort so its easier to split these if necessary.",
"yaml_list",
"=",
"[",
"]",
"done_set",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | IsFleetspeakEnabledClient | Returns whether the provided GRR id is a Fleetspeak client. | grr/server/grr_response_server/fleetspeak_utils.py | def IsFleetspeakEnabledClient(grr_id, token=None):
"""Returns whether the provided GRR id is a Fleetspeak client."""
if grr_id is None:
return False
if data_store.RelationalDBEnabled():
md = data_store.REL_DB.ReadClientMetadata(grr_id)
if not md:
return False
return md.fleetspeak_enabled
... | def IsFleetspeakEnabledClient(grr_id, token=None):
"""Returns whether the provided GRR id is a Fleetspeak client."""
if grr_id is None:
return False
if data_store.RelationalDBEnabled():
md = data_store.REL_DB.ReadClientMetadata(grr_id)
if not md:
return False
return md.fleetspeak_enabled
... | [
"Returns",
"whether",
"the",
"provided",
"GRR",
"id",
"is",
"a",
"Fleetspeak",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/fleetspeak_utils.py#L19-L36 | [
"def",
"IsFleetspeakEnabledClient",
"(",
"grr_id",
",",
"token",
"=",
"None",
")",
":",
"if",
"grr_id",
"is",
"None",
":",
"return",
"False",
"if",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
":",
"md",
"=",
"data_store",
".",
"REL_DB",
".",
"ReadC... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SendGrrMessageThroughFleetspeak | Sends the given GrrMessage through FS. | grr/server/grr_response_server/fleetspeak_utils.py | def SendGrrMessageThroughFleetspeak(grr_id, msg):
"""Sends the given GrrMessage through FS."""
fs_msg = fs_common_pb2.Message(
message_type="GrrMessage",
destination=fs_common_pb2.Address(
client_id=GRRIDToFleetspeakID(grr_id), service_name="GRR"))
fs_msg.data.Pack(msg.AsPrimitiveProto())
... | def SendGrrMessageThroughFleetspeak(grr_id, msg):
"""Sends the given GrrMessage through FS."""
fs_msg = fs_common_pb2.Message(
message_type="GrrMessage",
destination=fs_common_pb2.Address(
client_id=GRRIDToFleetspeakID(grr_id), service_name="GRR"))
fs_msg.data.Pack(msg.AsPrimitiveProto())
... | [
"Sends",
"the",
"given",
"GrrMessage",
"through",
"FS",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/fleetspeak_utils.py#L39-L46 | [
"def",
"SendGrrMessageThroughFleetspeak",
"(",
"grr_id",
",",
"msg",
")",
":",
"fs_msg",
"=",
"fs_common_pb2",
".",
"Message",
"(",
"message_type",
"=",
"\"GrrMessage\"",
",",
"destination",
"=",
"fs_common_pb2",
".",
"Address",
"(",
"client_id",
"=",
"GRRIDToFlee... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetLabelFromFleetspeak | Returns the primary GRR label to use for a fleetspeak client. | grr/server/grr_response_server/fleetspeak_utils.py | def GetLabelFromFleetspeak(client_id):
"""Returns the primary GRR label to use for a fleetspeak client."""
res = fleetspeak_connector.CONN.outgoing.ListClients(
admin_pb2.ListClientsRequest(client_ids=[GRRIDToFleetspeakID(client_id)]))
if not res.clients or not res.clients[0].labels:
return fleetspeak_c... | def GetLabelFromFleetspeak(client_id):
"""Returns the primary GRR label to use for a fleetspeak client."""
res = fleetspeak_connector.CONN.outgoing.ListClients(
admin_pb2.ListClientsRequest(client_ids=[GRRIDToFleetspeakID(client_id)]))
if not res.clients or not res.clients[0].labels:
return fleetspeak_c... | [
"Returns",
"the",
"primary",
"GRR",
"label",
"to",
"use",
"for",
"a",
"fleetspeak",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/fleetspeak_utils.py#L63-L76 | [
"def",
"GetLabelFromFleetspeak",
"(",
"client_id",
")",
":",
"res",
"=",
"fleetspeak_connector",
".",
"CONN",
".",
"outgoing",
".",
"ListClients",
"(",
"admin_pb2",
".",
"ListClientsRequest",
"(",
"client_ids",
"=",
"[",
"GRRIDToFleetspeakID",
"(",
"client_id",
")... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.Start | Initialize our state. | grr/server/grr_response_server/flows/general/transfer.py | def Start(self,
file_size=0,
maximum_pending_files=1000,
use_external_stores=False):
"""Initialize our state."""
super(MultiGetFileLogic, self).Start()
self.state.files_hashed = 0
self.state.use_external_stores = use_external_stores
self.state.file_size = file_si... | def Start(self,
file_size=0,
maximum_pending_files=1000,
use_external_stores=False):
"""Initialize our state."""
super(MultiGetFileLogic, self).Start()
self.state.files_hashed = 0
self.state.use_external_stores = use_external_stores
self.state.file_size = file_si... | [
"Initialize",
"our",
"state",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L270-L313 | [
"def",
"Start",
"(",
"self",
",",
"file_size",
"=",
"0",
",",
"maximum_pending_files",
"=",
"1000",
",",
"use_external_stores",
"=",
"False",
")",
":",
"super",
"(",
"MultiGetFileLogic",
",",
"self",
")",
".",
"Start",
"(",
")",
"self",
".",
"state",
"."... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.StartFileFetch | The entry point for this flow mixin - Schedules new file transfer. | grr/server/grr_response_server/flows/general/transfer.py | def StartFileFetch(self, pathspec, request_data=None):
"""The entry point for this flow mixin - Schedules new file transfer."""
# Create an index so we can find this pathspec later.
self.state.indexed_pathspecs.append(pathspec)
self.state.request_data_list.append(request_data)
self._TryToStartNextPa... | def StartFileFetch(self, pathspec, request_data=None):
"""The entry point for this flow mixin - Schedules new file transfer."""
# Create an index so we can find this pathspec later.
self.state.indexed_pathspecs.append(pathspec)
self.state.request_data_list.append(request_data)
self._TryToStartNextPa... | [
"The",
"entry",
"point",
"for",
"this",
"flow",
"mixin",
"-",
"Schedules",
"new",
"file",
"transfer",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L315-L320 | [
"def",
"StartFileFetch",
"(",
"self",
",",
"pathspec",
",",
"request_data",
"=",
"None",
")",
":",
"# Create an index so we can find this pathspec later.",
"self",
".",
"state",
".",
"indexed_pathspecs",
".",
"append",
"(",
"pathspec",
")",
"self",
".",
"state",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._TryToStartNextPathspec | Try to schedule the next pathspec if there is enough capacity. | grr/server/grr_response_server/flows/general/transfer.py | def _TryToStartNextPathspec(self):
"""Try to schedule the next pathspec if there is enough capacity."""
# Nothing to do here.
if self.state.maximum_pending_files <= len(self.state.pending_files):
return
if self.state.maximum_pending_files <= len(self.state.pending_hashes):
return
try:... | def _TryToStartNextPathspec(self):
"""Try to schedule the next pathspec if there is enough capacity."""
# Nothing to do here.
if self.state.maximum_pending_files <= len(self.state.pending_files):
return
if self.state.maximum_pending_files <= len(self.state.pending_hashes):
return
try:... | [
"Try",
"to",
"schedule",
"the",
"next",
"pathspec",
"if",
"there",
"is",
"enough",
"capacity",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L322-L377 | [
"def",
"_TryToStartNextPathspec",
"(",
"self",
")",
":",
"# Nothing to do here.",
"if",
"self",
".",
"state",
".",
"maximum_pending_files",
"<=",
"len",
"(",
"self",
".",
"state",
".",
"pending_files",
")",
":",
"return",
"if",
"self",
".",
"state",
".",
"ma... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._RemoveCompletedPathspec | Removes a pathspec from the list of pathspecs. | grr/server/grr_response_server/flows/general/transfer.py | def _RemoveCompletedPathspec(self, index):
"""Removes a pathspec from the list of pathspecs."""
pathspec = self.state.indexed_pathspecs[index]
request_data = self.state.request_data_list[index]
self.state.indexed_pathspecs[index] = None
self.state.request_data_list[index] = None
self.state.pend... | def _RemoveCompletedPathspec(self, index):
"""Removes a pathspec from the list of pathspecs."""
pathspec = self.state.indexed_pathspecs[index]
request_data = self.state.request_data_list[index]
self.state.indexed_pathspecs[index] = None
self.state.request_data_list[index] = None
self.state.pend... | [
"Removes",
"a",
"pathspec",
"from",
"the",
"list",
"of",
"pathspecs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L379-L392 | [
"def",
"_RemoveCompletedPathspec",
"(",
"self",
",",
"index",
")",
":",
"pathspec",
"=",
"self",
".",
"state",
".",
"indexed_pathspecs",
"[",
"index",
"]",
"request_data",
"=",
"self",
".",
"state",
".",
"request_data_list",
"[",
"index",
"]",
"self",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._ReceiveFetchedFile | Remove pathspec for this index and call the ReceiveFetchedFile method. | grr/server/grr_response_server/flows/general/transfer.py | def _ReceiveFetchedFile(self, tracker):
"""Remove pathspec for this index and call the ReceiveFetchedFile method."""
index = tracker["index"]
_, request_data = self._RemoveCompletedPathspec(index)
# Report the request_data for this flow's caller.
self.ReceiveFetchedFile(
tracker["stat_entr... | def _ReceiveFetchedFile(self, tracker):
"""Remove pathspec for this index and call the ReceiveFetchedFile method."""
index = tracker["index"]
_, request_data = self._RemoveCompletedPathspec(index)
# Report the request_data for this flow's caller.
self.ReceiveFetchedFile(
tracker["stat_entr... | [
"Remove",
"pathspec",
"for",
"this",
"index",
"and",
"call",
"the",
"ReceiveFetchedFile",
"method",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L394-L402 | [
"def",
"_ReceiveFetchedFile",
"(",
"self",
",",
"tracker",
")",
":",
"index",
"=",
"tracker",
"[",
"\"index\"",
"]",
"_",
",",
"request_data",
"=",
"self",
".",
"_RemoveCompletedPathspec",
"(",
"index",
")",
"# Report the request_data for this flow's caller.",
"self... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._FileFetchFailed | Remove pathspec for this index and call the FileFetchFailed method. | grr/server/grr_response_server/flows/general/transfer.py | def _FileFetchFailed(self, index, request_name):
"""Remove pathspec for this index and call the FileFetchFailed method."""
pathspec, request_data = self._RemoveCompletedPathspec(index)
# Report the request_data for this flow's caller.
self.FileFetchFailed(pathspec, request_name, request_data=request_d... | def _FileFetchFailed(self, index, request_name):
"""Remove pathspec for this index and call the FileFetchFailed method."""
pathspec, request_data = self._RemoveCompletedPathspec(index)
# Report the request_data for this flow's caller.
self.FileFetchFailed(pathspec, request_name, request_data=request_d... | [
"Remove",
"pathspec",
"for",
"this",
"index",
"and",
"call",
"the",
"FileFetchFailed",
"method",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L414-L420 | [
"def",
"_FileFetchFailed",
"(",
"self",
",",
"index",
",",
"request_name",
")",
":",
"pathspec",
",",
"request_data",
"=",
"self",
".",
"_RemoveCompletedPathspec",
"(",
"index",
")",
"# Report the request_data for this flow's caller.",
"self",
".",
"FileFetchFailed",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.StoreStat | Stores stat entry in the flow's state. | grr/server/grr_response_server/flows/general/transfer.py | def StoreStat(self, responses):
"""Stores stat entry in the flow's state."""
index = responses.request_data["index"]
if not responses.success:
self.Log("Failed to stat file: %s", responses.status)
# Report failure.
self._FileFetchFailed(index, responses.request_data["request_name"])
... | def StoreStat(self, responses):
"""Stores stat entry in the flow's state."""
index = responses.request_data["index"]
if not responses.success:
self.Log("Failed to stat file: %s", responses.status)
# Report failure.
self._FileFetchFailed(index, responses.request_data["request_name"])
... | [
"Stores",
"stat",
"entry",
"in",
"the",
"flow",
"s",
"state",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L432-L442 | [
"def",
"StoreStat",
"(",
"self",
",",
"responses",
")",
":",
"index",
"=",
"responses",
".",
"request_data",
"[",
"\"index\"",
"]",
"if",
"not",
"responses",
".",
"success",
":",
"self",
".",
"Log",
"(",
"\"Failed to stat file: %s\"",
",",
"responses",
".",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.ReceiveFileHash | Add hash digest to tracker and check with filestore. | grr/server/grr_response_server/flows/general/transfer.py | def ReceiveFileHash(self, responses):
"""Add hash digest to tracker and check with filestore."""
index = responses.request_data["index"]
if not responses.success:
self.Log("Failed to hash file: %s", responses.status)
self.state.pending_hashes.pop(index, None)
# Report the error.
self... | def ReceiveFileHash(self, responses):
"""Add hash digest to tracker and check with filestore."""
index = responses.request_data["index"]
if not responses.success:
self.Log("Failed to hash file: %s", responses.status)
self.state.pending_hashes.pop(index, None)
# Report the error.
self... | [
"Add",
"hash",
"digest",
"to",
"tracker",
"and",
"check",
"with",
"filestore",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L444-L490 | [
"def",
"ReceiveFileHash",
"(",
"self",
",",
"responses",
")",
":",
"index",
"=",
"responses",
".",
"request_data",
"[",
"\"index\"",
"]",
"if",
"not",
"responses",
".",
"success",
":",
"self",
".",
"Log",
"(",
"\"Failed to hash file: %s\"",
",",
"responses",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._LegacyCheckHashesWithFileStore | Check all queued up hashes for existence in file store (legacy).
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
If a file was found in the file store it is copied... | grr/server/grr_response_server/flows/general/transfer.py | def _LegacyCheckHashesWithFileStore(self):
"""Check all queued up hashes for existence in file store (legacy).
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
... | def _LegacyCheckHashesWithFileStore(self):
"""Check all queued up hashes for existence in file store (legacy).
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
... | [
"Check",
"all",
"queued",
"up",
"hashes",
"for",
"existence",
"in",
"file",
"store",
"(",
"legacy",
")",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L492-L620 | [
"def",
"_LegacyCheckHashesWithFileStore",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"state",
".",
"pending_hashes",
":",
"return",
"# This map represents all the hashes in the pending urns.",
"file_hashes",
"=",
"{",
"}",
"# Store a mapping of hash to tracker. Keys are... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic._CheckHashesWithFileStore | Check all queued up hashes for existence in file store.
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
If a file was found in the file store it is not scheduled f... | grr/server/grr_response_server/flows/general/transfer.py | def _CheckHashesWithFileStore(self):
"""Check all queued up hashes for existence in file store.
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
If a file was f... | def _CheckHashesWithFileStore(self):
"""Check all queued up hashes for existence in file store.
Hashes which do not exist in the file store will be downloaded. This
function flushes the entire queue (self.state.pending_hashes) in order to
minimize the round trips to the file store.
If a file was f... | [
"Check",
"all",
"queued",
"up",
"hashes",
"for",
"existence",
"in",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L622-L737 | [
"def",
"_CheckHashesWithFileStore",
"(",
"self",
")",
":",
"if",
"not",
"data_store",
".",
"RelationalDBEnabled",
"(",
")",
":",
"return",
"self",
".",
"_LegacyCheckHashesWithFileStore",
"(",
")",
"if",
"not",
"self",
".",
"state",
".",
"pending_hashes",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.CheckHash | Adds the block hash to the file tracker responsible for this vfs URN. | grr/server/grr_response_server/flows/general/transfer.py | def CheckHash(self, responses):
"""Adds the block hash to the file tracker responsible for this vfs URN."""
index = responses.request_data["index"]
if index not in self.state.pending_files:
# This is a blobhash for a file we already failed to read and logged as
# below, check here to avoid logg... | def CheckHash(self, responses):
"""Adds the block hash to the file tracker responsible for this vfs URN."""
index = responses.request_data["index"]
if index not in self.state.pending_files:
# This is a blobhash for a file we already failed to read and logged as
# below, check here to avoid logg... | [
"Adds",
"the",
"block",
"hash",
"to",
"the",
"file",
"tracker",
"responsible",
"for",
"this",
"vfs",
"URN",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L739-L762 | [
"def",
"CheckHash",
"(",
"self",
",",
"responses",
")",
":",
"index",
"=",
"responses",
".",
"request_data",
"[",
"\"index\"",
"]",
"if",
"index",
"not",
"in",
"self",
".",
"state",
".",
"pending_files",
":",
"# This is a blobhash for a file we already failed to r... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.FetchFileContent | Fetch as much as the file's content as possible.
This drains the pending_files store by checking which blobs we already have
in the store and issuing calls to the client to receive outstanding blobs. | grr/server/grr_response_server/flows/general/transfer.py | def FetchFileContent(self):
"""Fetch as much as the file's content as possible.
This drains the pending_files store by checking which blobs we already have
in the store and issuing calls to the client to receive outstanding blobs.
"""
if not self.state.pending_files:
return
# Check what ... | def FetchFileContent(self):
"""Fetch as much as the file's content as possible.
This drains the pending_files store by checking which blobs we already have
in the store and issuing calls to the client to receive outstanding blobs.
"""
if not self.state.pending_files:
return
# Check what ... | [
"Fetch",
"as",
"much",
"as",
"the",
"file",
"s",
"content",
"as",
"possible",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L764-L803 | [
"def",
"FetchFileContent",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"state",
".",
"pending_files",
":",
"return",
"# Check what blobs we already have in the blob store.",
"blob_hashes",
"=",
"[",
"]",
"for",
"file_tracker",
"in",
"itervalues",
"(",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | MultiGetFileLogic.WriteBuffer | Write the hash received to the blob image. | grr/server/grr_response_server/flows/general/transfer.py | def WriteBuffer(self, responses):
"""Write the hash received to the blob image."""
index = responses.request_data["index"]
if index not in self.state.pending_files:
return
# Failed to read the file - ignore it.
if not responses.success:
self._FileFetchFailed(index, responses.request.re... | def WriteBuffer(self, responses):
"""Write the hash received to the blob image."""
index = responses.request_data["index"]
if index not in self.state.pending_files:
return
# Failed to read the file - ignore it.
if not responses.success:
self._FileFetchFailed(index, responses.request.re... | [
"Write",
"the",
"hash",
"received",
"to",
"the",
"blob",
"image",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L805-L894 | [
"def",
"WriteBuffer",
"(",
"self",
",",
"responses",
")",
":",
"index",
"=",
"responses",
".",
"request_data",
"[",
"\"index\"",
"]",
"if",
"index",
"not",
"in",
"self",
".",
"state",
".",
"pending_files",
":",
"return",
"# Failed to read the file - ignore it.",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | LegacyFileStoreCreateFile.ProcessMessages | Process the new file and add to the file store. | grr/server/grr_response_server/flows/general/transfer.py | def ProcessMessages(self, msgs=None, token=None):
"""Process the new file and add to the file store."""
if not data_store.AFF4Enabled():
return
filestore_fd = aff4.FACTORY.Create(
legacy_filestore.FileStore.PATH,
legacy_filestore.FileStore,
mode="w",
token=token)
... | def ProcessMessages(self, msgs=None, token=None):
"""Process the new file and add to the file store."""
if not data_store.AFF4Enabled():
return
filestore_fd = aff4.FACTORY.Create(
legacy_filestore.FileStore.PATH,
legacy_filestore.FileStore,
mode="w",
token=token)
... | [
"Process",
"the",
"new",
"file",
"and",
"add",
"to",
"the",
"file",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/transfer.py#L962-L978 | [
"def",
"ProcessMessages",
"(",
"self",
",",
"msgs",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"not",
"data_store",
".",
"AFF4Enabled",
"(",
")",
":",
"return",
"filestore_fd",
"=",
"aff4",
".",
"FACTORY",
".",
"Create",
"(",
"legacy_filesto... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | CreateGenericHuntFlow.Start | Create the hunt, in the paused state. | grr/server/grr_response_server/hunts/standard.py | def Start(self):
"""Create the hunt, in the paused state."""
# Anyone can create the hunt but it will be created in the paused
# state. Permissions are required to actually start it.
with implementation.StartHunt(
runner_args=self.args.hunt_runner_args,
args=self.args.hunt_args,
... | def Start(self):
"""Create the hunt, in the paused state."""
# Anyone can create the hunt but it will be created in the paused
# state. Permissions are required to actually start it.
with implementation.StartHunt(
runner_args=self.args.hunt_runner_args,
args=self.args.hunt_args,
... | [
"Create",
"the",
"hunt",
"in",
"the",
"paused",
"state",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/standard.py#L90-L102 | [
"def",
"Start",
"(",
"self",
")",
":",
"# Anyone can create the hunt but it will be created in the paused",
"# state. Permissions are required to actually start it.",
"with",
"implementation",
".",
"StartHunt",
"(",
"runner_args",
"=",
"self",
".",
"args",
".",
"hunt_runner_arg... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | SampleHunt.StoreResults | Stores the responses. | grr/server/grr_response_server/hunts/standard.py | def StoreResults(self, responses):
"""Stores the responses."""
client_id = responses.request.client_id
if responses.success:
logging.info("Client %s has a file %s.", client_id, self.args.filename)
else:
logging.info("Client %s has no file %s.", client_id, self.args.filename)
self.MarkC... | def StoreResults(self, responses):
"""Stores the responses."""
client_id = responses.request.client_id
if responses.success:
logging.info("Client %s has a file %s.", client_id, self.args.filename)
else:
logging.info("Client %s has no file %s.", client_id, self.args.filename)
self.MarkC... | [
"Stores",
"the",
"responses",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/standard.py#L173-L182 | [
"def",
"StoreResults",
"(",
"self",
",",
"responses",
")",
":",
"client_id",
"=",
"responses",
".",
"request",
".",
"client_id",
"if",
"responses",
".",
"success",
":",
"logging",
".",
"info",
"(",
"\"Client %s has a file %s.\"",
",",
"client_id",
",",
"self",... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GenericHunt.GetLaunchedFlows | Returns the session IDs of all the flows we launched.
Args:
flow_type: The type of flows to fetch. Can be "all", "outstanding" or
"finished".
Returns:
A list of flow URNs. | grr/server/grr_response_server/hunts/standard.py | def GetLaunchedFlows(self, flow_type="outstanding"):
"""Returns the session IDs of all the flows we launched.
Args:
flow_type: The type of flows to fetch. Can be "all", "outstanding" or
"finished".
Returns:
A list of flow URNs.
"""
result = None
all_clients = set(self.ListA... | def GetLaunchedFlows(self, flow_type="outstanding"):
"""Returns the session IDs of all the flows we launched.
Args:
flow_type: The type of flows to fetch. Can be "all", "outstanding" or
"finished".
Returns:
A list of flow URNs.
"""
result = None
all_clients = set(self.ListA... | [
"Returns",
"the",
"session",
"IDs",
"of",
"all",
"the",
"flows",
"we",
"launched",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/standard.py#L276-L302 | [
"def",
"GetLaunchedFlows",
"(",
"self",
",",
"flow_type",
"=",
"\"outstanding\"",
")",
":",
"result",
"=",
"None",
"all_clients",
"=",
"set",
"(",
"self",
".",
"ListAllClients",
"(",
")",
")",
"finished_clients",
"=",
"set",
"(",
"self",
".",
"ListFinishedCl... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GenericHunt.MarkDone | Mark a client as done. | grr/server/grr_response_server/hunts/standard.py | def MarkDone(self, responses):
"""Mark a client as done."""
client_id = responses.request.client_id
self.AddResultsToCollection(responses, client_id)
self.MarkClientDone(client_id) | def MarkDone(self, responses):
"""Mark a client as done."""
client_id = responses.request.client_id
self.AddResultsToCollection(responses, client_id)
self.MarkClientDone(client_id) | [
"Mark",
"a",
"client",
"as",
"done",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/standard.py#L304-L308 | [
"def",
"MarkDone",
"(",
"self",
",",
"responses",
")",
":",
"client_id",
"=",
"responses",
".",
"request",
".",
"client_id",
"self",
".",
"AddResultsToCollection",
"(",
"responses",
",",
"client_id",
")",
"self",
".",
"MarkClientDone",
"(",
"client_id",
")"
] | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | VariableGenericHunt.ManuallyScheduleClients | Schedule all flows without using the Foreman.
Since we know all the client ids to run on we might as well just schedule
all the flows and wait for the results.
Args:
token: A datastore access token. | grr/server/grr_response_server/hunts/standard.py | def ManuallyScheduleClients(self, token=None):
"""Schedule all flows without using the Foreman.
Since we know all the client ids to run on we might as well just schedule
all the flows and wait for the results.
Args:
token: A datastore access token.
"""
client_ids = set()
for flow_re... | def ManuallyScheduleClients(self, token=None):
"""Schedule all flows without using the Foreman.
Since we know all the client ids to run on we might as well just schedule
all the flows and wait for the results.
Args:
token: A datastore access token.
"""
client_ids = set()
for flow_re... | [
"Schedule",
"all",
"flows",
"without",
"using",
"the",
"Foreman",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/standard.py#L359-L374 | [
"def",
"ManuallyScheduleClients",
"(",
"self",
",",
"token",
"=",
"None",
")",
":",
"client_ids",
"=",
"set",
"(",
")",
"for",
"flow_request",
"in",
"self",
".",
"args",
".",
"flows",
":",
"for",
"client_id",
"in",
"flow_request",
".",
"client_ids",
":",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetCloudVMMetadata.IsCloud | Test to see if we're on a cloud machine. | grr/client/grr_response_client/client_actions/cloud.py | def IsCloud(self, request, bios_version, services):
"""Test to see if we're on a cloud machine."""
if request.bios_version_regex and bios_version:
if re.match(request.bios_version_regex, bios_version):
return True
if request.service_name_regex and services:
if re.search(request.service_n... | def IsCloud(self, request, bios_version, services):
"""Test to see if we're on a cloud machine."""
if request.bios_version_regex and bios_version:
if re.match(request.bios_version_regex, bios_version):
return True
if request.service_name_regex and services:
if re.search(request.service_n... | [
"Test",
"to",
"see",
"if",
"we",
"re",
"on",
"a",
"cloud",
"machine",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/cloud.py#L34-L42 | [
"def",
"IsCloud",
"(",
"self",
",",
"request",
",",
"bios_version",
",",
"services",
")",
":",
"if",
"request",
".",
"bios_version_regex",
"and",
"bios_version",
":",
"if",
"re",
".",
"match",
"(",
"request",
".",
"bios_version_regex",
",",
"bios_version",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetCloudVMMetadata.GetMetaData | Get metadata from local metadata server.
Any failed URL check will fail the whole action since our bios/service
checks may not always correctly identify cloud machines. We don't want to
wait on multiple DNS timeouts.
Args:
request: CloudMetadataRequest object
Returns:
rdf_cloud.CloudMe... | grr/client/grr_response_client/client_actions/cloud.py | def GetMetaData(self, request):
"""Get metadata from local metadata server.
Any failed URL check will fail the whole action since our bios/service
checks may not always correctly identify cloud machines. We don't want to
wait on multiple DNS timeouts.
Args:
request: CloudMetadataRequest obje... | def GetMetaData(self, request):
"""Get metadata from local metadata server.
Any failed URL check will fail the whole action since our bios/service
checks may not always correctly identify cloud machines. We don't want to
wait on multiple DNS timeouts.
Args:
request: CloudMetadataRequest obje... | [
"Get",
"metadata",
"from",
"local",
"metadata",
"server",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/cloud.py#L44-L73 | [
"def",
"GetMetaData",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"timeout",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Requests library can't handle timeout of 0\"",
")",
"result",
"=",
"requests",
".",
"request",
"(",
"\"GET\"",
",",
"re... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuseDatastoreOnly.MakePartialStat | Try and give a 'stat' for something not in the data store.
Args:
fd: The object with no stat.
Returns:
A dictionary corresponding to what we'll say the 'stat' is
for objects which are not actually files, so have no OS level stat. | grr/server/grr_response_server/bin/fuse_mount.py | def MakePartialStat(self, fd):
"""Try and give a 'stat' for something not in the data store.
Args:
fd: The object with no stat.
Returns:
A dictionary corresponding to what we'll say the 'stat' is
for objects which are not actually files, so have no OS level stat.
"""
is_dir = "... | def MakePartialStat(self, fd):
"""Try and give a 'stat' for something not in the data store.
Args:
fd: The object with no stat.
Returns:
A dictionary corresponding to what we'll say the 'stat' is
for objects which are not actually files, so have no OS level stat.
"""
is_dir = "... | [
"Try",
"and",
"give",
"a",
"stat",
"for",
"something",
"not",
"in",
"the",
"data",
"store",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L136-L165 | [
"def",
"MakePartialStat",
"(",
"self",
",",
"fd",
")",
":",
"is_dir",
"=",
"\"Container\"",
"in",
"fd",
".",
"behaviours",
"return",
"{",
"\"pathspec\"",
":",
"fd",
".",
"Get",
"(",
"fd",
".",
"Schema",
".",
"PATHSPEC",
",",
"\"\"",
")",
",",
"\"st_ati... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuseDatastoreOnly.Readdir | Reads a directory given by path.
Args:
path: The path to list children of.
fh: A file handler. Not used.
Yields:
A generator of filenames.
Raises:
FuseOSError: If we try and list a file. | grr/server/grr_response_server/bin/fuse_mount.py | def Readdir(self, path, fh=None):
"""Reads a directory given by path.
Args:
path: The path to list children of.
fh: A file handler. Not used.
Yields:
A generator of filenames.
Raises:
FuseOSError: If we try and list a file.
"""
del fh
# We can't read a path if it... | def Readdir(self, path, fh=None):
"""Reads a directory given by path.
Args:
path: The path to list children of.
fh: A file handler. Not used.
Yields:
A generator of filenames.
Raises:
FuseOSError: If we try and list a file.
"""
del fh
# We can't read a path if it... | [
"Reads",
"a",
"directory",
"given",
"by",
"path",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L171-L204 | [
"def",
"Readdir",
"(",
"self",
",",
"path",
",",
"fh",
"=",
"None",
")",
":",
"del",
"fh",
"# We can't read a path if it's a file.",
"if",
"not",
"self",
".",
"_IsDir",
"(",
"path",
")",
":",
"raise",
"fuse",
".",
"FuseOSError",
"(",
"errno",
".",
"ENOTD... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuseDatastoreOnly.Getattr | Performs a stat on a file or directory.
Args:
path: The path to stat.
fh: A file handler. Not used.
Returns:
A dictionary mapping st_ names to their values.
Raises:
FuseOSError: When a path is supplied that grr doesn't know about, ie an
invalid file path.
ValueError: I... | grr/server/grr_response_server/bin/fuse_mount.py | def Getattr(self, path, fh=None):
"""Performs a stat on a file or directory.
Args:
path: The path to stat.
fh: A file handler. Not used.
Returns:
A dictionary mapping st_ names to their values.
Raises:
FuseOSError: When a path is supplied that grr doesn't know about, ie an
... | def Getattr(self, path, fh=None):
"""Performs a stat on a file or directory.
Args:
path: The path to stat.
fh: A file handler. Not used.
Returns:
A dictionary mapping st_ names to their values.
Raises:
FuseOSError: When a path is supplied that grr doesn't know about, ie an
... | [
"Performs",
"a",
"stat",
"on",
"a",
"file",
"or",
"directory",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L206-L267 | [
"def",
"Getattr",
"(",
"self",
",",
"path",
",",
"fh",
"=",
"None",
")",
":",
"del",
"fh",
"if",
"not",
"path",
":",
"raise",
"fuse",
".",
"FuseOSError",
"(",
"errno",
".",
"ENOENT",
")",
"if",
"path",
"!=",
"self",
".",
"root",
":",
"full_path",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuseDatastoreOnly.Read | Reads data from a file.
Args:
path: The path to the file to read.
length: How many bytes to read.
offset: Offset in bytes from which reading should start.
fh: A file handler. Not used.
Returns:
A string containing the file contents requested.
Raises:
FuseOSError: If we... | grr/server/grr_response_server/bin/fuse_mount.py | def Read(self, path, length=None, offset=0, fh=None):
"""Reads data from a file.
Args:
path: The path to the file to read.
length: How many bytes to read.
offset: Offset in bytes from which reading should start.
fh: A file handler. Not used.
Returns:
A string containing the f... | def Read(self, path, length=None, offset=0, fh=None):
"""Reads data from a file.
Args:
path: The path to the file to read.
length: How many bytes to read.
offset: Offset in bytes from which reading should start.
fh: A file handler. Not used.
Returns:
A string containing the f... | [
"Reads",
"data",
"from",
"a",
"file",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L269-L304 | [
"def",
"Read",
"(",
"self",
",",
"path",
",",
"length",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"fh",
"=",
"None",
")",
":",
"del",
"fh",
"if",
"self",
".",
"_IsDir",
"(",
"path",
")",
":",
"raise",
"fuse",
".",
"FuseOSError",
"(",
"errno",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuse.DataRefreshRequired | True if we need to update this path from the client.
Args:
path: The path relative to the root to check freshness of.
last: An aff4:last attribute to check freshness of.
At least one of path or last must be supplied.
Returns:
True if the path hasn't been updated in the last
self... | grr/server/grr_response_server/bin/fuse_mount.py | def DataRefreshRequired(self, path=None, last=None):
"""True if we need to update this path from the client.
Args:
path: The path relative to the root to check freshness of.
last: An aff4:last attribute to check freshness of.
At least one of path or last must be supplied.
Returns:
... | def DataRefreshRequired(self, path=None, last=None):
"""True if we need to update this path from the client.
Args:
path: The path relative to the root to check freshness of.
last: An aff4:last attribute to check freshness of.
At least one of path or last must be supplied.
Returns:
... | [
"True",
"if",
"we",
"need",
"to",
"update",
"this",
"path",
"from",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L402-L444 | [
"def",
"DataRefreshRequired",
"(",
"self",
",",
"path",
"=",
"None",
",",
"last",
"=",
"None",
")",
":",
"# If we didn't get given a last attribute, use the path to get one from the",
"# object.",
"if",
"last",
"is",
"None",
":",
"if",
"path",
"is",
"None",
":",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuse._RunAndWaitForVFSFileUpdate | Runs a flow on the client, and waits for it to finish. | grr/server/grr_response_server/bin/fuse_mount.py | def _RunAndWaitForVFSFileUpdate(self, path):
"""Runs a flow on the client, and waits for it to finish."""
client_id = rdf_client.GetClientURNFromPath(path)
# If we're not actually in a directory on a client, no need to run a flow.
if client_id is None:
return
flow_utils.UpdateVFSFileAndWait... | def _RunAndWaitForVFSFileUpdate(self, path):
"""Runs a flow on the client, and waits for it to finish."""
client_id = rdf_client.GetClientURNFromPath(path)
# If we're not actually in a directory on a client, no need to run a flow.
if client_id is None:
return
flow_utils.UpdateVFSFileAndWait... | [
"Runs",
"a",
"flow",
"on",
"the",
"client",
"and",
"waits",
"for",
"it",
"to",
"finish",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L446-L459 | [
"def",
"_RunAndWaitForVFSFileUpdate",
"(",
"self",
",",
"path",
")",
":",
"client_id",
"=",
"rdf_client",
".",
"GetClientURNFromPath",
"(",
"path",
")",
"# If we're not actually in a directory on a client, no need to run a flow.",
"if",
"client_id",
"is",
"None",
":",
"re... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuse.Readdir | Updates the directory listing from the client.
Args:
path: The path to the directory to update. Client is inferred from this.
fh: A file handler. Not used.
Returns:
A list of filenames. | grr/server/grr_response_server/bin/fuse_mount.py | def Readdir(self, path, fh=None):
"""Updates the directory listing from the client.
Args:
path: The path to the directory to update. Client is inferred from this.
fh: A file handler. Not used.
Returns:
A list of filenames.
"""
if self.DataRefreshRequired(path):
self._RunAn... | def Readdir(self, path, fh=None):
"""Updates the directory listing from the client.
Args:
path: The path to the directory to update. Client is inferred from this.
fh: A file handler. Not used.
Returns:
A list of filenames.
"""
if self.DataRefreshRequired(path):
self._RunAn... | [
"Updates",
"the",
"directory",
"listing",
"from",
"the",
"client",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L461-L475 | [
"def",
"Readdir",
"(",
"self",
",",
"path",
",",
"fh",
"=",
"None",
")",
":",
"if",
"self",
".",
"DataRefreshRequired",
"(",
"path",
")",
":",
"self",
".",
"_RunAndWaitForVFSFileUpdate",
"(",
"path",
")",
"return",
"super",
"(",
"GRRFuse",
",",
"self",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GRRFuse.GetMissingChunks | Return which chunks a file doesn't have.
Specifically, we return a list of the chunks specified by a
length-offset range which are not in the datastore.
Args:
fd: The database object to read chunks from.
length: Length to read.
offset: File offset to read from.
Returns:
A list... | grr/server/grr_response_server/bin/fuse_mount.py | def GetMissingChunks(self, fd, length, offset):
"""Return which chunks a file doesn't have.
Specifically, we return a list of the chunks specified by a
length-offset range which are not in the datastore.
Args:
fd: The database object to read chunks from.
length: Length to read.
offse... | def GetMissingChunks(self, fd, length, offset):
"""Return which chunks a file doesn't have.
Specifically, we return a list of the chunks specified by a
length-offset range which are not in the datastore.
Args:
fd: The database object to read chunks from.
length: Length to read.
offse... | [
"Return",
"which",
"chunks",
"a",
"file",
"doesn",
"t",
"have",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/bin/fuse_mount.py#L477-L501 | [
"def",
"GetMissingChunks",
"(",
"self",
",",
"fd",
",",
"length",
",",
"offset",
")",
":",
"start_chunk",
"=",
"offset",
"//",
"fd",
".",
"chunksize",
"end_chunk",
"=",
"(",
"offset",
"+",
"length",
"-",
"1",
")",
"//",
"fd",
".",
"chunksize",
"relevan... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | FindProxies | This reads the OSX system configuration and gets the proxies. | grr/client/grr_response_client/client_utils_osx.py | def FindProxies():
"""This reads the OSX system configuration and gets the proxies."""
sc = objc.SystemConfiguration()
# Get the dictionary of network proxy settings
settings = sc.dll.SCDynamicStoreCopyProxies(None)
if not settings:
return []
try:
cf_http_enabled = sc.CFDictRetrieve(settings, "kS... | def FindProxies():
"""This reads the OSX system configuration and gets the proxies."""
sc = objc.SystemConfiguration()
# Get the dictionary of network proxy settings
settings = sc.dll.SCDynamicStoreCopyProxies(None)
if not settings:
return []
try:
cf_http_enabled = sc.CFDictRetrieve(settings, "kS... | [
"This",
"reads",
"the",
"OSX",
"system",
"configuration",
"and",
"gets",
"the",
"proxies",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L34-L72 | [
"def",
"FindProxies",
"(",
")",
":",
"sc",
"=",
"objc",
".",
"SystemConfiguration",
"(",
")",
"# Get the dictionary of network proxy settings",
"settings",
"=",
"sc",
".",
"dll",
".",
"SCDynamicStoreCopyProxies",
"(",
"None",
")",
"if",
"not",
"settings",
":",
"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetMountpoints | List all the filesystems mounted on the system. | grr/client/grr_response_client/client_utils_osx.py | def GetMountpoints():
"""List all the filesystems mounted on the system."""
devices = {}
for filesys in GetFileSystems():
devices[filesys.f_mntonname] = (filesys.f_mntfromname, filesys.f_fstypename)
return devices | def GetMountpoints():
"""List all the filesystems mounted on the system."""
devices = {}
for filesys in GetFileSystems():
devices[filesys.f_mntonname] = (filesys.f_mntfromname, filesys.f_fstypename)
return devices | [
"List",
"all",
"the",
"filesystems",
"mounted",
"on",
"the",
"system",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L75-L82 | [
"def",
"GetMountpoints",
"(",
")",
":",
"devices",
"=",
"{",
"}",
"for",
"filesys",
"in",
"GetFileSystems",
"(",
")",
":",
"devices",
"[",
"filesys",
".",
"f_mntonname",
"]",
"=",
"(",
"filesys",
".",
"f_mntfromname",
",",
"filesys",
".",
"f_fstypename",
... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | GetFileSystems | Make syscalls to get the mounted filesystems.
Returns:
A list of Struct objects.
Based on the information for getfsstat
http://developer.apple.com/library/mac/#documentation/Darwin/
Reference/ManPages/man2/getfsstat.2.html | grr/client/grr_response_client/client_utils_osx.py | def GetFileSystems():
"""Make syscalls to get the mounted filesystems.
Returns:
A list of Struct objects.
Based on the information for getfsstat
http://developer.apple.com/library/mac/#documentation/Darwin/
Reference/ManPages/man2/getfsstat.2.html
"""
version = OSXVersion()
major, minor = ve... | def GetFileSystems():
"""Make syscalls to get the mounted filesystems.
Returns:
A list of Struct objects.
Based on the information for getfsstat
http://developer.apple.com/library/mac/#documentation/Darwin/
Reference/ManPages/man2/getfsstat.2.html
"""
version = OSXVersion()
major, minor = ve... | [
"Make",
"syscalls",
"to",
"get",
"the",
"mounted",
"filesystems",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L134-L171 | [
"def",
"GetFileSystems",
"(",
")",
":",
"version",
"=",
"OSXVersion",
"(",
")",
"major",
",",
"minor",
"=",
"version",
".",
"VersionAsMajorMinor",
"(",
")",
"libc",
"=",
"ctypes",
".",
"cdll",
".",
"LoadLibrary",
"(",
"ctypes",
".",
"util",
".",
"find_li... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
train | ParseFileSystemsStruct | Take the struct type and parse it into a list of structs. | grr/client/grr_response_client/client_utils_osx.py | def ParseFileSystemsStruct(struct_class, fs_count, data):
"""Take the struct type and parse it into a list of structs."""
results = []
cstr = lambda x: x.split(b"\x00", 1)[0]
for count in range(0, fs_count):
struct_size = struct_class.GetSize()
s_data = data[count * struct_size:(count + 1) * struct_size... | def ParseFileSystemsStruct(struct_class, fs_count, data):
"""Take the struct type and parse it into a list of structs."""
results = []
cstr = lambda x: x.split(b"\x00", 1)[0]
for count in range(0, fs_count):
struct_size = struct_class.GetSize()
s_data = data[count * struct_size:(count + 1) * struct_size... | [
"Take",
"the",
"struct",
"type",
"and",
"parse",
"it",
"into",
"a",
"list",
"of",
"structs",
"."
] | google/grr | python | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L174-L186 | [
"def",
"ParseFileSystemsStruct",
"(",
"struct_class",
",",
"fs_count",
",",
"data",
")",
":",
"results",
"=",
"[",
"]",
"cstr",
"=",
"lambda",
"x",
":",
"x",
".",
"split",
"(",
"b\"\\x00\"",
",",
"1",
")",
"[",
"0",
"]",
"for",
"count",
"in",
"range"... | 5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.