Skip to content

Commit

Permalink
Added a flash command to initialise pyflag main db.
Browse files Browse the repository at this point in the history
darcs-hash:20090407001118-20ca2-c86708ecf063710584b0eebc15cdac4fbaf79a4d.gz
  • Loading branch information
scudette committed Apr 7, 2009
1 parent 91424c3 commit a5b35f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/plugins/Flash/AdvancedCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import pyflag.pyflaglog as pyflaglog
import BasicCommands
import pyflag.ScannerUtils as ScannerUtils
import pyflag.conf
config=pyflag.conf.ConfObject()

class scan_path(pyflagsh.command):
""" This takes a path as an argument and runs the specified scanner on the path
Expand Down Expand Up @@ -96,6 +98,20 @@ def execute(self):

yield "Scanning complete"

import pyflag.FlagFramework as FlagFramework

class init_flag_db(pyflagsh.command):
""" Creates the main flag db if needed """
def execute(self):
try:
dbh = DB.DBO()
except:
dbh = DB.DBO('mysql')
dbh.execute("create database `%s`" % config.FLAGDB)
dbh = DB.DBO()

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

class scan(pyflagsh.command):
""" Scan a glob of inodes with a glob of scanners """
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/NetworkForensics/ProtocolHandlers/POP.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def create(self, dbh, case):
""" CREATE TABLE if not exists `passwords` (
`inode_id` INT,
`username` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`type` VARCHAR(255) NOT NULL
) """)
Expand All @@ -154,6 +155,7 @@ def process_stream(self, stream, factories):

## We open the file and scan it for emails:
fd = self.fsfd.open(inode=combined_inode)
inode_id = 0
p=POP(fd)
while 1:
try:
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/TableRenderers/PeriodicHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ def periodic(self, dbh, case):
new_table = renderer.calculate_table_stats()
if tables != new_table:
pyflaglog.log(pyflaglog.DEBUG, "Re-exporting HTML Table %s" % renderer.page_name)
renderer.real_render_table()
try:
renderer.real_render_table()
except Exception,e:
print e
pass
dbh2.execute("update reporting_jobs set tables = %r where id=%r",
cPickle.dumps(new_table), row['id'])
except Exception,e:
Expand Down

0 comments on commit a5b35f3

Please sign in to comment.