本文整理汇总了Python中viper.core.database.Database.delete_parent方法的典型用法代码示例。如果您正苦于以下问题:Python Database.delete_parent方法的具体用法?Python Database.delete_parent怎么用?Python Database.delete_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viper.core.database.Database
的用法示例。
在下文中一共展示了Database.delete_parent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmd_parent
# 需要导入模块: from viper.core.database import Database [as 别名]
# 或者: from viper.core.database.Database import delete_parent [as 别名]
def cmd_parent(self, *args):
parser = argparse.ArgumentParser(prog='tags', description="Set the Parent for this file.")
parser.add_argument('-a', '--add', metavar='SHA256', help="Add parent file by sha256")
parser.add_argument('-d', '--delete', action='store_true', help="Delete Parent")
parser.add_argument('-o', '--open', action='store_true', help="Open The Parent")
try:
args = parser.parse_args(args)
except:
return
# This command requires a session to be opened.
if not __sessions__.is_set():
self.log('error', "No open session")
parser.print_usage()
return
# If no arguments are specified, there's not much to do.
if args.add is None and args.delete is None and args.open is None:
parser.print_usage()
return
db = Database()
if not db.find(key='sha256', value=__sessions__.current.file.sha256):
self.log('error', "The opened file is not stored in the database. "
"If you want to add it use the `store` command.")
return
if args.add:
if not db.find(key='sha256', value=args.add):
self.log('error', "the parent file is not found in the database. ")
return
db.add_parent(__sessions__.current.file.sha256, args.add)
self.log('info', "parent added to the currently opened file")
self.log('info', "Refreshing session to update attributes...")
__sessions__.new(__sessions__.current.file.path)
if args.delete:
db.delete_parent(__sessions__.current.file.sha256)
self.log('info', "parent removed from the currently opened file")
self.log('info', "Refreshing session to update attributes...")
__sessions__.new(__sessions__.current.file.path)
if args.open:
# Open a session on the parent
if __sessions__.current.file.parent:
__sessions__.new(get_sample_path(__sessions__.current.file.parent[-64:]))
else:
self.log('info', "No parent set for this sample")
示例2: run
# 需要导入模块: from viper.core.database import Database [as 别名]
# 或者: from viper.core.database.Database import delete_parent [as 别名]
def run(self, *args):
try:
args = self.parser.parse_args(args)
except SystemExit:
return
# This command requires a session to be opened.
if not __sessions__.is_set():
self.log('error', "No open session. This command expects a file to be open.")
self.parser.print_usage()
return
# If no arguments are specified, there's not much to do.
if args.add is None and args.delete is None and args.open is None:
self.parser.print_usage()
return
db = Database()
if not db.find(key='sha256', value=__sessions__.current.file.sha256):
self.log('error', "The opened file is not stored in the database. "
"If you want to add it use the `store` command.")
return
if args.add:
if not db.find(key='sha256', value=args.add):
self.log('error', "the parent file is not found in the database. ")
return
db.add_parent(__sessions__.current.file.sha256, args.add)
self.log('info', "parent added to the currently opened file")
self.log('info', "Refreshing session to update attributes...")
__sessions__.new(__sessions__.current.file.path)
if args.delete:
db.delete_parent(__sessions__.current.file.sha256)
self.log('info', "parent removed from the currently opened file")
self.log('info', "Refreshing session to update attributes...")
__sessions__.new(__sessions__.current.file.path)
if args.open:
# Open a session on the parent
if __sessions__.current.file.parent:
__sessions__.new(get_sample_path(__sessions__.current.file.parent[-64:]))
else:
self.log('info', "No parent set for this sample")