How to use _print_header method in gabbi

Best Python code snippet using gabbi_python

html.py

Source:html.py Github

copy

Full Screen

...103 margin-bottom: 10px;104 margin-top: 10px;105 }106 </style></head><body>''')107 self._print_header('Very Readable Output Bot')108 self._print_para('Let\'s see what\'s up with this machine.')109 if self._group_by_iocs:110 self.summarize_by_ioc()111 else:112 self.summarize_by_threat_indicator()113 self._print_para('Very Readable Output Bot')114 self._print_para('#kaythanksbye')115 self._write('</body></html>')116 return []117 def summarize_by_ioc(self):118 if self._group_key:119 self._print_header('Table of contents (sorted by {0})'.format(self._group_key), level=2)120 self._write('<ul id="toc">')121 for ioc_key, ioc_value in six.iteritems(self._iocs_by_key):122 self._print_section_link(123 ioc_key, ioc_key, len(ioc_value),124 )125 self._print_section_link('iocs', 'Remaining IOCs not tagged by key', len(self._iocs))126 self._write('</ul>')127 for ioc_key, ioc_value in six.iteritems(self._iocs_by_key):128 self._write('<div id="{0}">'.format(ioc_key))129 self._print_header('{0}'.format(ioc_key), level=2)130 self._print_para('Here is the analysis for the IOC {0}.'.format(ioc_key))131 self._summarize_blobs(ioc_value)132 self._print_para('Hopefully that was helpful.')133 self._write('</div>')134 self._write('<div id="iocs">')135 if (self._group_key):136 self._print_header('Remaining IOCs ({0})'.format(self._iocs), level=2)137 else:138 self._print_header('All IOCs ({0})'.format(len(self._iocs)), level=2)139 if (self._group_key):140 self._print_para('Here is a list of remaining IOCs that were not tagged by your key, just in case!')141 else:142 self._print_para('Get ready to analyze a bunch of IOCs!')143 self._summarize_blobs(self._iocs)144 self._print_para('Hopefully that was helpful.')145 self._write('</div>')146 def summarize_by_threat_indicator(self):147 self._print_header('Table of contents', level=2)148 self._write('<ul id="toc">')149 if len(self._vthash):150 self._print_section_link(151 'vthash', 'VirusTotal bad hash hits', len(self._vthash),152 )153 if len(self._vtdomain):154 self._print_section_link(155 'vtdomain', 'VirusTotal bad domain hits', len(self._vtdomain),156 )157 if len(self._opendns):158 self._print_section_link(159 'opendns', 'OpenDNS Investigate hits', len(self._opendns),160 )161 if len(self._blacklist):162 self._print_section_link(163 'blacklist', 'Blacklist hits', len(self._blacklist),164 )165 if len(self._related):166 self._print_section_link(167 'related', 'Related hits', len(self._related),168 )169 if len(self._signature_chain):170 self._print_section_link(171 'signature_chain', 'Signature chain',172 len(self._signature_chain),173 )174 if len(self._extensions):175 self._print_section_link(176 'extensions', 'Extensions', len(self._extensions),177 )178 if len(self._add_to_blacklist):179 self._print_section_link(180 'add_to_blacklist', 'Blacklist update suggestions',181 len(self._add_to_blacklist),182 )183 self._write('</ul>')184 if len(self._vthash):185 self._write('<div id="vthash">')186 self._print_header('VirusTotal bad hash hits', level=2)187 self._print_para('Dang! You\'ve got known malware on this machine. Hope it\'s commodity stuff')188 self._summarize_blobs(self._vthash)189 self._print_para('Sheesh! This is why we can\'t have nice things!')190 self._write('</div>')191 if len(self._vtdomain):192 self._write('<div id="vtdomain">')193 self._print_header('VirusTotal bad domain hits', level=2)194 self._print_para('I see you\'ve been visiting some \'questionable\' sites. If you trust VirusTotal that is.')195 self._summarize_blobs(self._vtdomain)196 self._print_para('I hope it was worth it!')197 self._write('</div>')198 if len(self._opendns):199 self._write('<div id="opendns">')200 self._print_header('OpenDNS Investigate hits', level=2)201 self._print_para('Well, here\'s some domains OpenDNS wouldn\'t recommend.')202 self._summarize_blobs(self._opendns)203 self._print_para('You know you shouldn\'t just click every link you see? #truth')204 self._write('</div>')205 if len(self._blacklist):206 self._write('<div id="blacklist">')207 self._print_header('Blacklist hits', level=2)208 self._print_para('We put stuff on a blacklist for a reason. Mostly so you don\'t do this.')209 self._summarize_blobs(self._blacklist)210 self._print_para('SMH')211 self._write('</div>')212 if len(self._related):213 self._write('<div id="related">')214 self._print_header('Related hits', level=2)215 self._print_para('This whole things started with just a few clues. Now look what I found.')216 self._summarize_blobs(self._related)217 self._print_para('Nothing hides from Very Readable Output Bot')218 self._write('</div>')219 if len(self._signature_chain):220 self._write('<div id="signature_chain">')221 self._print_header('Signature chain', level=2)222 self._print_para('If these binaries were signed by \'Apple Root CA\' I\'d trust them more.')223 self._summarize_blobs(self._signature_chain)224 self._print_para('Let\'s just try and stick with some safe software')225 self._write('</div>')226 if len(self._extensions):227 self._write('<div id="extensions">')228 self._print_header('Extensions', level=2)229 self._print_para('Let\'s see what\'s hiding in the browser, shall we.')230 self._summarize_blobs(self._extensions)231 self._print_para('You know these things have privileges galore.')232 self._write('</div>')233 if len(self._add_to_blacklist):234 self._write('<div id="add_to_blacklist">')235 self._add_to_blacklist = list(set(self._add_to_blacklist))236 self._print_header('Blacklist update suggestions', level=2)237 self._print_para('If I were you, I\'d probably update my blacklists to include:')238 for key, val in self._add_to_blacklist:239 self._summarize_val(key, val)240 self._print_para('That might just help things, Skippy!')241 self._write('</div>')242 def _print_section_link(self, section, title, size):243 self._write(244 '<li><a href="#{0}">{1}</a> ({2})</li>'.format(245 section, title, size,246 ),247 )248 def _summarize_blobs(self, blobs):249 self._write('<ol class="blobs">')250 for blob in blobs:251 self._write('<li>')252 section = blob.get('osxcollector_section')253 subsection = blob.get('osxcollector_subsection', '')254 self._print_header(u'{0} {1}'.format(section, subsection), level=3)255 self._write('<dl class="list">')256 self._summarize_general(blob)257 add_to_blacklist = False258 if 'osxcollector_vthash' in blob:259 self._summarize_vthash(blob)260 add_to_blacklist = True261 if 'osxcollector_vtdomain' in blob:262 self._summarize_vtdomain(blob)263 if 'osxcollector_alexa_rank' in blob:264 self._summarize_alexa_rank(blob)265 if 'osxcollector_opendns' in blob:266 self._summarize_opendns(blob)267 if 'osxcollector_blacklist' in blob:268 self._summarize_blacklist(blob)269 if 'osxcollector_related' in blob:270 self._summarize_related(blob)271 if 'md5' in blob and '' == blob['md5']:272 add_to_blacklist = True273 if add_to_blacklist:274 blacklists = blob.get('osxcollector_blacklist', {})275 values_on_blacklist = blacklists.get('hashes', [])276 for key in ['md5', 'sha1', 'sha2']:277 val = blob.get(key, '')278 if len(val) and val not in values_on_blacklist:279 self._add_to_blacklist.append((key, val))280 values_on_blacklist = blacklists.get('domains', [])281 for domain in blob.get('osxcollector_domains', []):282 if domain not in values_on_blacklist:283 self._add_to_blacklist.append(('domain', domain))284 self._write('</dl>') # this is the end of the list started by "_summarize_line"285 self._write('</li>')286 self._write('</ol>')287 def _summarize_general(self, blob):288 self._write(u'<dt>General</dt>')289 for key in sorted(blob):290 if not key.startswith('osxcollector') and blob.get(key):291 val = blob.get(key)292 self._summarize_val(key, val, etype='dd')293 def _summarize_vthash(self, blob):294 self._write(u'<dt>Virustotal Hash</dt>')295 for blob in blob['osxcollector_vthash']:296 for key in ['positives', 'total', 'scan_date']:297 val = blob.get(key)298 self._summarize_val(key, val, 'vthash', etype='dd')299 permalink = blob.get('permalink')300 self._write(u'<li><a href="{0}" target="_blank">{0}</a></li>'.format(permalink))301 def _summarize_vtdomain(self, blob):302 self._write(u'<dt>Virustotal Domain</dt>')303 for blob in blob['osxcollector_vtdomain']:304 for key in ['domain', 'detections']:305 val = blob.get(key)306 self._summarize_val(key, val, 'vtdomain', etype='dd')307 def _summarize_alexa_rank(self, blob):308 for blob in blob['osxcollector_alexa_rank']:309 for key in ['attributes']:310 val = blob.get(key)311 self._summarize_val(key, val, 'alexarank')312 def _summarize_opendns(self, blob):313 self._write(u'<dt>OpenDNS</dt>')314 for blob in blob['osxcollector_opendns']:315 for key in ['domain', 'categorization', 'security']:316 val = blob.get(key)317 self._summarize_val(key, val, 'opendns', etype='dd')318 link = blob.get('link')319 self._write(u'<dd><a href="{0}" target="_blank">{0}</a></dd>'.format(link))320 def _summarize_blacklist(self, blob):321 self._write(u'<dt>Blacklist</dt>')322 for key in blob['osxcollector_blacklist']:323 self._summarize_val(u'blacklist-{0}'.format(key), blob['osxcollector_blacklist'][key])324 def _summarize_related(self, blob):325 self._write(u'<dt>Related</dt>')326 for key in blob['osxcollector_related']:327 self._summarize_val(u'related-{0}'.format(key), blob['osxcollector_related'][key])328 def _summarize_val(self, key, val, prefix=None, etype='li'):329 self._write('<{0}>'.format(etype))330 self._print_key(key, prefix)331 self._print_val(val)332 self._write('</{0}>'.format(etype))333 def _print_header(self, text, level=1):334 self._write(u'<h{0}>{1}</h{0}>'.format(level, text))335 def _print_para(self, text):336 self._write(u'<p>{0}</p>'.format(text))337 def _print_list_item(self, item):338 self._write('<li>')339 self._print_val(item)340 self._write('</li>')341 def _print_key(self, key, prefix=None):342 if not prefix:343 prefix = ''344 else:345 prefix += '-'346 self._write(u'<span class="key">{0}{1}</span>: '.format(prefix, key))347 def _print_val(self, val):...

Full Screen

Full Screen

dirtypipe.py

Source:dirtypipe.py Github

copy

Full Screen

...17 return False18 Session.task = structs.Task(gdb.parse_and_eval("$lx_current()").address)19 Session.fmap = structs.AddrSpace(Session.file.get_member("f_mapping"))20 Session.page = structs.Page(Session.fmap.get_member("i_pages")["xa_head"])21 self._print_header("Stage 1: open the target file")22 Session.task.print_info()23 Session.file.print_info()24 Session.fmap.print_info()25 Session.page.print_info()26 return False27class PipeFcntlBP(breakpoints.GenericContextBP):28 def _stop(self):29 Session.pipe = structs.Pipe(gdb.parse_and_eval("file")["private_data"])30 Session.buf = structs.PipeBuffer(Session.pipe.get_member("bufs"))31 self._print_header("Stage 2: create pipe")32 Session.pipe.print_info()33 Session.buf.print_info()34 return False35class PipeWriteBP(breakpoints.GenericContextBP):36 def _stop(self):37 if int(Session.buf.get_member("len")) not in {8, 18, 4096}:38 return False39 else:40 buf_page = structs.Page(Session.buf.get_member("page"))41 if int(Session.buf.get_member("len")) == 8:42 self._print_header("Stage 3.1: init pipe buffer with write")43 elif int(Session.buf.get_member("len")) == 4096:44 self._print_header("Stage 3.2: filled pipe buffer")45 else:46 self._print_header("Stage 7: writing into page cache")47 Session.fmap.print_info()48 Session.pipe.print_info()49 Session.buf.print_info()50 buf_page.print_info()51 return False52class PipeReadBP(breakpoints.GenericContextBP):53 def _stop(self):54 if int(Session.buf.get_member("len")) != 0:55 return False56 self._print_header("Stage 4: release drained pipe buffer")57 Session.pipe.print_info()58 Session.buf.print_info()59 return False60class SpliceToPipeBP(breakpoints.GenericContextBP):61 def _stop(self):62 self._print_header("Stage 5: splicing file to pipe")63 Session.pipe.print_info()64 Session.buf.print_info()65 Session.fmap.print_info()66 Session.page.print_info()67 return False68def main():69 # the name of the poc binary70 comm = "poc"71 OpenBP("fs/open.c:1220", comm=comm)72 PipeFcntlBP("fs/pipe.c:1401", comm=comm)73 PipeWriteBP("fs/pipe.c:597", comm=comm)74 PipeReadBP("fs/pipe.c:393", comm=comm)75 SpliceToPipeBP("fs/splice.c:1106", comm=comm)76 gdb.execute("c")...

Full Screen

Full Screen

log_print.py

Source:log_print.py Github

copy

Full Screen

...3@author: SuzukiRyota4'''5import logging6class PrintHeaderMiddleware(object):7 def _print_header(self, key):8 try:9 logging.warning('HEADER %s: %s' % (key, str(self.meta[key])))10 except KeyError:11 logging.warning('NOT FOUND: %s' % key)12 def _print_fav(self):13 self._print_header('REQUEST_METHOD')14 self._print_header('USER')15 self._print_header('HTTP_HOST')16 self._print_header('HTTP_USER_AGENT')17 self._print_header('HTTP_COOKIE')18 self._print_header('HTTP_REFERER')19 20 def _print_all(self):21 for k in self.meta:22 self._print_header(k)23 24 25 def process_view(self, request, callback, callback_args, callback_kwargs):26 self.meta = request.META27 self._print_fav()28 # self._print_all()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run gabbi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful