def update_db(): """ Update the database with latest files.csv """ if settings.exploitdb_path: if not os.path.exists(settings.exploitdb_path): msg = T('Exploit DB directory in kvasir.yaml not valid') if request.extension in ['load', 'json']: return dict(status='fail', message=msg) redirect(URL('default', 'error', vars={'msg': msg})) indexfile = os.path.join(settings.exploitdb_path, 'files.csv') if not os.path.exists(indexfile): session.flash = T('Exploit DB files.csv not found') redirect(URL('index')) dialog = FORM.confirm(T('Update'), {T('Cancel'): URL('index')}) if dialog.accepted: msg = exploitdb_update(indexfile) session.flash = msg redirect(URL('index')) return dict(dialog=dialog)
def git_pull(): """ Git Pull handler """ if not have_git: session.flash = GIT_MISSING redirect(URL('index')) if settings.exploitdb_path: if not os.path.exists(settings.exploitdb_path): msg = T('Exploit DB directory in kvasir.yaml not valid') redirect(URL('default', 'error', vars={'msg': msg})) dialog = FORM.confirm(T('Pull'), {T('Cancel'): URL('index')}) if dialog.accepted: try: repo = git.Repo(settings.exploitdb_path) origin = repo.remotes.origin origin.fetch() origin.pull() msg = T("Exploit-database updated. ") indexfile = os.path.join(settings.exploitdb_path, 'files.csv') msg += exploitdb_update(indexfile) session.flash = msg except git.CheckoutError: session.flash = T( "Pull failed, certain files could not be checked out. Check logs for details.") except git.UnmergedEntriesError: session.flash = T( "Pull is not possible because you have unmerged files. Fix them up in the work tree, and then try again.") except git.GitCommandError: session.flash = T( "Pull failed, git exited abnormally. See logs for details.") except AssertionError: session.flash = T( "Pull is not possible because you have unmerged files. Fix them up in the work tree, and then try again.") except Exception as e: session.flash = T( "Error: %s" % (e) ) redirect(URL('index')) return dict(dialog=dialog)
def git_pull(): """ Git Pull handler """ if not have_git: session.flash = GIT_MISSING redirect(URL('index')) if settings.exploitdb_path: if not os.path.exists(settings.exploitdb_path): msg = T('Exploit DB directory in kvasir.yaml not valid') redirect(URL('default', 'error', vars={'msg': msg})) dialog = FORM.confirm(T('Pull'), {T('Cancel'): URL('index')}) if dialog.accepted: try: repo = git.Repo(settings.exploitdb_path) origin = repo.remotes.origin origin.fetch() origin.pull() msg = T("Exploit-database updated. ") indexfile = os.path.join(settings.exploitdb_path, 'files.csv') msg += exploitdb_update(indexfile) session.flash = msg except git.CheckoutError: session.flash = T( "Pull failed, certain files could not be checked out. Check logs for details.") except git.UnmergedEntriesError: session.flash = T( "Pull is not possible because you have unmerged files. Fix them up in the work tree, and then try again.") except git.GitCommandError: session.flash = T( "Pull failed, git exited abnormally. See logs for details.") except AssertionError: session.flash = T( "Pull is not possible because you have unmerged files. Fix them up in the work tree, and then try again.") except Exception, e: session.flash = T( "Error: %s" % (e) ) redirect(URL('index'))