Skip to content

Commit

Permalink
Added a pyflash command to delete an iosource. Not complete, but func…
Browse files Browse the repository at this point in the history
…tional.

darcs-hash:20090509001509-f1522-5a2d450bda6405caa4eccb2568c757e201ab000d.gz
  • Loading branch information
scudette committed May 9, 2009
1 parent 700878c commit 68fc3d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
11 changes: 5 additions & 6 deletions examples/load_new_file.flash
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#Example Flash script for loading a filesystem
execute Case\ Management.Remove\ case remove_case=%(case)s
reset Case\ Management.Create\ new\ case create_case=%(case)s
execute Case\ Management.Create\ new\ case create_case=%(case)s
set case=%(case)s
delete_case %(case)s
create_case %(case)s
load %(case)s

execute Load\ Data.Load\ IO\ Data\ Source iosource=test subsys=sgzip io_filename=%(Image filename)s io_offset=0
execute Load\ Data.Load\ IO\ Data\ Source iosource=test subsys=Standard filename=%(Image filename)s offset=0

execute Load\ Data.Load\ Filesystem\ image iosource=test fstype=linux-ext2 scan=TypeScan scan=DeletedScan scan=MD5Scan scan=IEIndex scan=RegistryScan scan=PstScan scan=Index
scan * CompressedFile FileScanners GeneralForensics NetworkScanners
19 changes: 19 additions & 0 deletions src/plugins/Flash/AdvancedCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ def execute(self):

FlagFramework.post_event("init_default_db", None)
yield "Done"

class delete_iosource(pyflagsh.command):
""" Deletes an iosource from the current case """
def complete(self, text, state):
dbh = DB.DBO(self.environment._CASE)
dbh.execute("select substr(name,1,%r) as abbrev,name from iosources where name like '%s%%' group by abbrev limit %s,1",(len(text)+1,text,state))
return dbh.fetch()['name']

def execute(self):
for iosource in self.args:
dbh = DB.DBO(self.environment._CASE)
dbh2 = dbh.clone()
dbh.delete('inode', where=DB.expand("inode like 'I%s|%%'", iosource))
dbh.execute("select * from filesystems where iosource = %r", iosource)
for row in dbh:
dbh2.delete('file', where=DB.expand("path like '%s%%'", iosource))

dbh.delete("iosources", where=DB.expand("name=%r", iosource))
yield "Removed IOSource %s" % iosource

class scan(pyflagsh.command):
""" Scan a glob of inodes with a glob of scanners """
Expand Down

0 comments on commit 68fc3d2

Please sign in to comment.