Repository navigation
feat(api,webhooks,store,ci): implement multi-issue updates (#333, #33… - #394
Merged
Merged
Conversation
…ocol-org#333, Octo-Protocol-org#332, Octo-Protocol-org#335, Octo-Protocol-org#331) Detailed explanation of changes across all four resolved issues: 1. Propagate per-request id through logging for cross-service traceability (Closes Octo-Protocol-org#333): - Audited request handling across crates/api and implemented `request_id_middleware` in crates/api/src/lib.rs. - For every incoming HTTP request, extracts the caller-supplied `X-Request-Id` header (if valid ASCII and non-empty) or generates a new UUIDv4. - Enters an instrumented tracing span `info_span!("request", request_id = %request_id)` wrapping downstream route handling, store calls, Horizon requests, and webhook dispatch so all log lines carry the correlation id automatically. - Attaches `x-request-id` to response headers so clients can reference request IDs when reporting issues. - Added `tracing-subscriber` dev-dependency and comprehensive tests in `crates/api/tests/request_id_tests.rs`: * `every_response_carries_an_x_request_id_header` * `a_caller_supplied_x_request_id_is_echoed_back_unchanged` * `log_output_for_a_request_consistently_carries_the_same_request_id_across_nested_spans` 2. Consolidate is_safe_url into comprehensive edge-case test suite (Closes Octo-Protocol-org#332): - Hardened `is_safe_url` in crates/webhooks/src/lib.rs against SSRF vectors across all IP encoding classes: * Dotted-decimal IPv4, loopback range (127.0.0.0/8), private (RFC 1918), carrier-grade NAT (100.64.0.0/10), link-local (169.254.0.0/16), broadcast (255.255.255.255), and unspecified (0.0.0.0/8). * Alternative representations including raw decimal integer (`2130706433`), hex integer (`0x7f000001`), hex-dotted (`0x7f.0.0.1`), and octal-dotted (`0177.0.0.1`). * IPv6 loopback (`::1`), unspecified (`::`), link-local (`fe80::/10`), unique-local (`fc00::/7`), IPv4-mapped IPv6 (`::ffff:x`), and IPv4-compatible IPv6 (`::x`). - Documented explicit DNS scope boundary: `is_safe_url` handles syntactic validation and IP literal filtering, while DNS resolution and DNS rebind defense are delegated to the HTTP client and egress network policies. - Organized tests into structured test modules by encoding class: * `test_standard_public_urls` * `test_ipv4_literal_forms` * `test_ipv6_forms` * `test_ipv4_mapped_and_compatible_ipv6_forms` * `test_link_local_addresses` * `test_unspecified_addresses` * `test_hostnames_and_dns_scope_boundary` * `test_invalid_and_malformed_urls` 3. Add migration-order regression test on fresh database (Closes Octo-Protocol-org#335): - Added `migrate_applies_cleanly_from_a_genuinely_empty_database` in crates/store/tests/store_tests.rs. - Dynamically provisions a fresh, isolated PostgreSQL database from the base instance rather than reusing an existing or pre-migrated schema. - Runs `Store::connect` and `Store::migrate` (`MIGRATOR.run`) to verify all 20 sequential migrations apply cleanly in order from scratch. - Asserts key database tables exist (`wallets`, `addresses`, `transactions`, `withdrawals`, `webhook_endpoints`, `webhook_deliveries`, `_sqlx_migrations`) and drops the temporary test database upon completion. 4. Add cargo-audit and cargo-deny result caching to speed up CI (Closes Octo-Protocol-org#331): - Updated `.github/workflows/ci.yml` for both `audit` and `deny` jobs. - Added `actions/cache@v4` steps caching tool binaries (`~/.cargo/bin/cargo-audit`) and advisory databases (`~/.cargo/advisory-db` for cargo-audit, `~/.cargo/advisory-dbs` for cargo-deny). - Configured daily rotating cache keys (`${{ runner.os }}-cargo-audit-${{ steps.cache-date.outputs.date }}` and `${{ runner.os }}-cargo-deny-${{ steps.cache-date.outputs.date }}`) with prefix restore keys to prevent cache drift and ensure advisory freshness. - Preserved active advisory fetching so incremental fetches occur fast against warm caches rather than downloading full databases from scratch on every CI run.
|
@feyisaralawal Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
# Conflicts: # crates/api/src/lib.rs # crates/store/tests/store_tests.rs # crates/webhooks/src/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…2, #335, #331)
Detailed explanation of changes across all four resolved issues:
Propagate per-request id through logging for cross-service traceability (Closes Propagate a per-request id through logging for cross-service traceability #333):
request_id_middlewarein crates/api/src/lib.rs.X-Request-Idheader (if valid ASCII and non-empty) or generates a new UUIDv4.info_span!("request", request_id = %request_id)wrapping downstream route handling, store calls, Horizon requests, and webhook dispatch so all log lines carry the correlation id automatically.x-request-idto response headers so clients can reference request IDs when reporting issues.tracing-subscriberdev-dependency and comprehensive tests incrates/api/tests/request_id_tests.rs:every_response_carries_an_x_request_id_headera_caller_supplied_x_request_id_is_echoed_back_unchanged*log_output_for_a_request_consistently_carries_the_same_request_id_across_nested_spansConsolidate is_safe_url into comprehensive edge-case test suite (Closes Add a dedicated test suite for is_safe_url covering IPv6, IPv4-mapped, and loopback edge cases #332):
is_safe_urlin crates/webhooks/src/lib.rs against SSRF vectors across all IP encoding classes: * Dotted-decimal IPv4, loopback range (127.0.0.0/8), private (RFC 1918), carrier-grade NAT (100.64.0.0/10), link-local (169.254.0.0/16), broadcast (255.255.255.255), and unspecified (0.0.0.0/8). * Alternative representations including raw decimal integer (2130706433), hex integer (0x7f000001), hex-dotted (0x7f.0.0.1), and octal-dotted (0177.0.0.1). * IPv6 loopback (::1), unspecified (::), link-local (fe80::/10), unique-local (fc00::/7), IPv4-mapped IPv6 (::ffff:x), and IPv4-compatible IPv6 (::x).is_safe_urlhandles syntactic validation and IP literal filtering, while DNS resolution and DNS rebind defense are delegated to the HTTP client and egress network policies.test_standard_public_urlstest_ipv4_literal_forms*test_ipv6_forms*test_ipv4_mapped_and_compatible_ipv6_forms*test_link_local_addresses*test_unspecified_addresses*test_hostnames_and_dns_scope_boundary*test_invalid_and_malformed_urlsAdd migration-order regression test on fresh database (Closes Add a migration-order regression test asserting every migration applies cleanly on an empty database #335):
migrate_applies_cleanly_from_a_genuinely_empty_databasein crates/store/tests/store_tests.rs.Store::connectandStore::migrate(MIGRATOR.run) to verify all 20 sequential migrations apply cleanly in order from scratch.wallets,addresses,transactions,withdrawals,webhook_endpoints,webhook_deliveries,_sqlx_migrations) and drops the temporary test database upon completion.Add cargo-audit and cargo-deny result caching to speed up CI (Closes Add cargo-audit and cargo-deny result caching to speed up CI #331):
.github/workflows/ci.ymlfor bothauditanddenyjobs.actions/cache@v4steps caching tool binaries (~/.cargo/bin/cargo-audit) and advisory databases (~/.cargo/advisory-dbfor cargo-audit,~/.cargo/advisory-dbsfor cargo-deny).${{ runner.os }}-cargo-audit-${{ steps.cache-date.outputs.date }}and${{ runner.os }}-cargo-deny-${{ steps.cache-date.outputs.date }}) with prefix restore keys to prevent cache drift and ensure advisory freshness.Summary
Related step / issue
Checklist
cargo fmt --all -- --checkpassescargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepassesHow to test