Skip to content

Blasthttp mock migration#3081

Merged
liquidsec merged 4 commits intoblasthttp-integration-cleanfrom
blasthttp-mock-migration
May 7, 2026
Merged

Blasthttp mock migration#3081
liquidsec merged 4 commits intoblasthttp-integration-cleanfrom
blasthttp-mock-migration

Conversation

@liquidsec
Copy link
Copy Markdown
Contributor

No description provided.

liquidsec added 3 commits May 5, 2026 23:49
…http.mock

Rides on blasthttp 0.5.0's new httpx-style Response API
(status_code, text, content, headers as case-insensitive Headers,
cookies, raw_headers, hash, peer_ip, request, json(),
raise_for_status() raising HTTPStatusError) and the new
blasthttp.mock submodule.

Wrapper removal
---------------
Delete bbot/core/helpers/web/blast_response.py — its job (presenting
blasthttp's PyO3 Response with an httpx-shaped surface) is now done
natively by blasthttp.Response.

  - WebHelper.request: returns the native blasthttp.Response instead
    of wrapping. Same downstream surface.
  - WebHelper.request_batch_stream: same — yields the native
    blasthttp.Response.
  - download() / raise_for_status: BlasthttpHTTPError → blasthttp.HTTPStatusError.

Mock migration
--------------
bbot/test/mock_blasthttp.py is now a thin wrapper over
blasthttp.mock.BlasthttpMock. The generic mock infrastructure
(handler queue with FIFO + recycle, URL/method/header/json
predicates, sync + async callbacks, batch streaming) lives upstream.
This module keeps the bbot-specific surface:

  - handle_engine_request: WebHelper kwarg translation (auth tuple
    → Authorization header, cookies dict → Cookie header,
    json/data body assembly, raise_error → engine-style error dict,
    allow_redirects → follow_redirects).
  - handle_batch_stream(real_client, ...): per-call real_client
    splitting, since the WebHelper's blasthttp client isn't available
    at fixture construction time.

`MockRequest`, `MockResponse`, `TimeoutException`, and the
`add_response` / `add_callback` / `should_intercept` API are all
re-exported / forwarded so the 68 module tests using them keep
working unchanged.

Module-level fixes for the new Headers API
------------------------------------------
The blasthttp.Headers class iterates as Python-dict-style keys
(httpx convention), not list-of-tuples. Three places in bbot
were unpacking headers as tuples:

  - http.py: replaced manual raw_header build with
    response.raw_headers (also lazy on the blasthttp side).
    header_dict loop now uses .items().
  - web_brute.py: location lookup uses .items().
  - url_manipulation.py: subject_content now uses raw_headers
    instead of stringifying the list of tuples.

diff.py compare_headers needed no special handling — blasthttp
0.5.0 registers Headers with collections.abc.MutableMapping so
DeepDiff recognizes it natively.

Pin
---
pyproject.toml: blasthttp dep bumped >=0.3.2 → >=0.5.0.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

📊 Performance Benchmark Report

Comparing blasthttp-integration-clean (baseline) vs blasthttp-mock-migration (current)

📈 Detailed Results (All Benchmarks)

📋 Complete results for all benchmarks - includes both significant and insignificant changes

🧪 Test Name 📏 Base 📏 Current 📈 Change 🎯 Status
Bloom Filter Dns Mutation Tracking Performance 4.26ms 4.35ms +2.2%
Bloom Filter Large Scale Dns Brute Force 17.45ms 24.88ms +42.6% 🔴🔴🔴 ⚠️
Large Closest Match Lookup 336.43ms 332.08ms -1.3%
Realistic Closest Match Workload 179.59ms 181.68ms +1.2%
Event Memory Medium Scan 1784 B/event 1784 B/event +0.0%
Event Memory Large Scan 1768 B/event 1768 B/event +0.0%
Event Validation Full Scan Startup Small Batch 372.98ms 374.75ms +0.5%
Event Validation Full Scan Startup Large Batch 530.87ms 521.29ms -1.8%
Make Event Autodetection Small 25.19ms 24.91ms -1.1%
Make Event Autodetection Large 254.38ms 250.68ms -1.5%
Make Event Explicit Types 10.68ms 10.56ms -1.2%
Excavate Single Thread Small 3.461s 3.410s -1.5%
Excavate Single Thread Large 8.806s 8.736s -0.8%
Excavate Parallel Tasks Small 3.667s 3.637s -0.8%
Excavate Parallel Tasks Large 6.105s 6.066s -0.6%
Is Ip Performance 3.16ms 3.15ms -0.2%
Make Ip Type Performance 11.28ms 11.46ms +1.5%
Mixed Ip Operations 4.49ms 4.46ms -0.6%
Memory Use Web Crawl 159.3 MB 151.5 MB -4.9%
Memory Use Subdomain Enum 19.4 MB 19.4 MB +0.0%
Scan Throughput 100 3.674s 3.551s -3.3%
Scan Throughput 1000 27.796s 27.660s -0.5%
Typical Queue Shuffle 62.61µs 63.10µs +0.8%
Priority Queue Shuffle 717.32µs 712.22µs -0.7%

🎯 Performance Summary

! 1 regression ⚠️
  23 unchanged ✅

🔍 Significant Changes (>10%)

  • Bloom Filter Large Scale Dns Brute Force: 42.6% 🐌 slower

🐍 Python Version 3.11.15

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 89.47368% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 91%. Comparing base (d45f5fa) to head (52dee5f).
⚠️ Report is 5 commits behind head on blasthttp-integration-clean.

Files with missing lines Patch % Lines
bbot/modules/webbrute.py 73% 3 Missing ⚠️
bbot/modules/webbrute_shortnames.py 40% 3 Missing ⚠️
bbot/core/helpers/web/web.py 60% 2 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           blasthttp-integration-clean   #3081    +/-   ##
============================================================
+ Coverage                           91%     91%    +1%     
============================================================
  Files                              440     439     -1     
  Lines                            38111   37860   -251     
============================================================
- Hits                             34374   34159   -215     
+ Misses                            3737    3701    -36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@liquidsec liquidsec merged commit ce8a832 into blasthttp-integration-clean May 7, 2026
18 checks passed
@liquidsec liquidsec deleted the blasthttp-mock-migration branch May 7, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant