def mutate(self, info, host='pastebin.com', port=443, path='/', scheme="http"): url = security.strip_dangerous_characters( f"{scheme}://{host}:{port}{path}") cmd = helpers.run_cmd(f'curl --insecure {url}') owner = Owner.query.filter_by(name='DVGAUser').first() Paste.create_paste(title='Imported Paste from URL - {}'.format( helpers.generate_uuid()), content=cmd, public=False, burn=False, owner_id=owner.id, owner=owner, ip_addr=request.remote_addr, user_agent=request.headers.get('User-Agent', '')) Audit.create_audit_entry( gqloperation=helpers.get_opname(info.operation)) return ImportPaste(result=cmd)
def mutate(self, info, filename, content): result = helpers.save_file(filename, content) owner = Owner.query.filter_by(name='DVGAUser').first() Paste.create_paste( title='Imported Paste from File - {}'.format(helpers.generate_uuid()), content=content, public=False, burn=False, owner_id=owner.id, owner=owner, ip_addr=request.remote_addr, user_agent=request.headers.get('User-Agent', '') ) Audit.create_audit_entry(info) return UploadPaste(result=result)
def mutate(self, info, title, content, public, burn): owner = Owner.query.filter_by(name='DVGAUser').first() paste_obj = Paste.create_paste(title=title, content=content, public=public, burn=burn, owner_id=owner.id, owner=owner, ip_addr=request.remote_addr, user_agent=request.headers.get( 'User-Agent', '')) return CreatePaste(paste=paste_obj)
def mutate(self, info, title, content, public, burn): owner = Owner.query.filter_by(name='DVGAUser').first() paste_obj = Paste.create_paste( title='Imported Paste from File - {}'.format( helpers.generate_uuid()), content=content, public=False, burn=False, owner_id=owner.id, owner=owner, ip_addr=request.remote_addr, user_agent=request.headers.get('User-Agent', '')) Audit.create_audit_entry( gqloperation=helpers.get_opname(info.operation)) return CreatePaste(paste=paste_obj)
def pump_db(): print('Populating Database') db.create_all() admin = User(username="******", password=random_password()) operator = User(username="******", password=random_password()) db.session.add(admin) db.session.add(operator) owner = Owner(name='DVGAUser') db.session.add(owner) paste = Paste() paste.title = random_title() paste.content = "My First Paste" paste.public = False paste.owner_id = owner.id paste.owner = owner paste.ip_addr = '127.0.0.1' paste.user_agent = 'User-Agent not set' db.session.add(paste) for _ in range(0, 10): owner = Owner(name=random_owner()) paste = Paste() paste.title = random_title() paste.content = random_content() paste.public = True paste.owner_id = owner.id paste.owner = owner paste.ip_addr = random_address() paste.user_agent = random_useragent() db.session.add(owner) db.session.add(paste) db.session.commit() print('done')