mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* feat(usage-export): include key and user metadata objects in daily activity export rows
* fix(usage-export): only populate key and user metadata for admin view and strip credential and SCIM slots
* feat(usage-export): redact credential-named values inside exported key and user metadata
* test(usage-export): freeze e2e models, compare raw non-admin metadata, mark query locals Final
* test(usage-export): mark redaction test locals Final
* fix(usage-export): drop callback and SCIM slots from both metadata objects at any depth and mask camelCase credential names
* fix(masker): keep odd-cased plain names like sEt-CoOkIe sensitive alongside the camelCase split
* test(masker): mark new test locals Final
* fix(masker): make the camelCase split opt-in and enable it only for the usage export masker
* fix(usage-export): mask acronym-cased and unseparated credential names in exported metadata
* test(e2e): assert acronym-cased and upper-case credential names are masked in the usage export
* test(integration): cover usage export metadata across routes, callers and a worker kill
* test(integration): retry burst calls dropped by the worker kill and fail on any chat error
* fix(usage-export): redact credential-shaped metadata values whatever their key is called
The export masked key and user metadata by key name only, so secrets under
names the masker does not know (tokens, apiKeys, passphrase, database_url,
sentry_dsn, slackWebhookUrl) or under ordinary names (an sk- key in a note,
a postgres URL with a password, a Bearer header, a JWT, a Slack or Discord
webhook URL), including inside lists, were exported verbatim to admin-view
callers. redact_credentials_in_payload gains an opt-in is_credential hook,
and the export passes one that matches those key names and credential value
shapes.
* fix(usage-export): mask password-only credential URLs and bound the value scan
The URL branch required a username, so redis://:pw@host reached exports. The sk- lookahead and the URL scheme prefix scanned the rest of the string at every match attempt, which made a long metadata string quadratic (54s for 150k chars locally, 0.2s now).
* fix(usage-export): make every credential pattern linear, including JWTs
Builds on the bounded sk- and URL scan. The JWT branch still rescanned to the
end of the string at every eyJ, so eyJ- repeated 30k times took seconds. JWTs
now match on their eyJ header run, the sk- digit check moved out of the
lookahead into one pass over the sk- runs, and URL userinfo is length bounded.
The adversarial-input test covers sk-, JWT, scheme and userinfo runs.
* fix(usage-export): redact credential URLs whatever the username or password length
The 256-character userinfo bounds let a longer generated password through
unredacted. The username and password classes already stop at the next
separator, so the scan stays linear without them.
* fix(usage-export): redact credential URLs with any scheme casing and embedded Authorization headers
Postgresql:// and HTTPS:// userinfo passwords passed through because the
scheme class was lowercase only, and an Authorization: Bearer line inside a
longer string missed the anchored header pattern.
* fix(usage-export): redact quoted Authorization keys in serialized metadata strings
* fix(usage-export): redact padded Bearer values and prefixed or escaped Authorization keys
* fix(usage-export): redact prefixed key shapes and webhook URL variants
Key prefixes now only need a non-alphanumeric character before them, so
id_AKIA..., stripe_sk_live_... and my_ghp_... are redacted while risk-2024 and
disk-1234 stay intact. Slack and Discord webhooks match any scheme casing,
http, Discord subdomains and versioned /api/vN/webhooks/ paths.
* feat(usage-export): make key and user metadata opt-in with include_metadata
The export now fills key_metadata and user_metadata only when an admin-view
caller passes include_metadata=true. Without it, and for non-admins, both
columns stay '{}' so the CSV shape is unchanged. The Usage export dialog gets
an unchecked "Include key and user metadata" checkbox that sends the flag.
* test(usage-export): opt the integration and e2e export calls into metadata, regenerate API types
The integration and e2e export helpers now pass include_metadata=true, and the
admin-viewer integration test also checks that an admin export without the flag
returns empty metadata objects.
* chore(usage-export): regenerate the lazy OpenAPI snapshot for include_metadata
* fix(usage-export): keep the default export shape and gate the metadata option to admins
The key_metadata and user_metadata columns and fields now appear only when an
admin-view caller passes include_metadata=true. Every other export, CSV and
JSON, keeps the merge-base shape. The Usage export dialog shows the metadata
checkbox only to proxy admins and viewers, with a note that stored metadata may
carry credentials the redaction cannot catch.
* test(usage-export): expect no metadata fields on the owner path of the export burst test
* fix(usage-export): require the metadata fields on ExportRow instead of an unpicklable default
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| fixtures | ||
| golden | ||
| __init__.py | ||
| _background_responses.py | ||
| _daily_activity_fixtures.py | ||
| _partial_stream.py | ||
| test_agent_spend.py | ||
| test_app_customer_budgets.py | ||
| test_autorouter_session_rollup.py | ||
| test_background_interaction_settlement.py | ||
| test_background_response_billed_once.py | ||
| test_background_response_billing_proxies.py | ||
| test_background_response_poll_retirement.py | ||
| test_baggage_tag_mappings.py | ||
| test_baseline_accounting.py | ||
| test_batch_completion_accounting.py | ||
| test_batch_enqueued_tokens_redis_lua.py | ||
| test_batch_observability.py | ||
| test_batch_poll_starvation.py | ||
| test_budget_limit_envelopes.py | ||
| test_cache_activity.py | ||
| test_cache_and_quota.py | ||
| test_chaos_burst_spend_once.py | ||
| test_chatgpt_subscription_usage.py | ||
| test_container_spend.py | ||
| test_customer_spend_by_team.py | ||
| test_daily_activity_aggregated_breakdowns.py | ||
| test_daily_activity_key_alias_probes.py | ||
| test_daily_activity_key_metadata_query_timeout.py | ||
| test_daily_activity_key_owner.py | ||
| test_daily_activity_key_owner_faults.py | ||
| test_daily_activity_key_owner_traffic.py | ||
| test_daily_activity_repository.py | ||
| test_daily_activity_routes.py | ||
| test_daily_rollup_retry.py | ||
| test_daily_tag_spend_retention.py | ||
| test_disable_end_user_cost_tracking.py | ||
| test_disconnected_bedrock_messages_stream_billing.py | ||
| test_end_user_budget_enforcement.py | ||
| test_end_user_spend_without_proxy_user.py | ||
| test_expired_ui_session_failure_rows.py | ||
| test_fail_closed_team_member_budget.py | ||
| test_failed_dispatch_tokens.py | ||
| test_failing_request_stored_snapshot.py | ||
| test_failure_spend_live_counters_chaos.py | ||
| test_filtered_ledger.py | ||
| test_gemini_tts_speech_billing.py | ||
| test_generate_content_endpoint_attribution.py | ||
| test_global_proxy_spend_counter.py | ||
| test_global_spend_report.py | ||
| test_global_spend_reset.py | ||
| test_google_genai_native_spend.py | ||
| test_image_generation_key_spend.py | ||
| test_key_budget_alerts.py | ||
| test_key_budget_lockout.py | ||
| test_key_metadata_recovery_dropped_connection.py | ||
| test_key_metadata_recovery_probe_bounds.py | ||
| test_key_reads_own_spend_logs.py | ||
| test_legacy_spend_logs_row_cap.py | ||
| test_messages_stream_usage_cost.py | ||
| test_model_router_selected_model.py | ||
| test_non_finite_cost_spend_writes.py | ||
| test_normalized_error_long_message.py | ||
| test_openrouter_upstream_provider.py | ||
| test_org_budget_cli_session_token.py | ||
| test_partial_stream_live_budget.py | ||
| test_passthrough_budget_reservation.py | ||
| test_passthrough_failure.py | ||
| test_passthrough_request_tags.py | ||
| test_passthrough_stream_pricing_paths_spend.py | ||
| test_passthrough_upstream_model.py | ||
| test_project_batch_enqueued_token_limit.py | ||
| test_prompt_caching_requests_pagination.py | ||
| test_ptu_share_attribution.py | ||
| test_requester_ip_address_logging.py | ||
| test_reset_budget_leader_election.py | ||
| test_responses_bridge_spend_once.py | ||
| test_responses_cache_write_itemization.py | ||
| test_responses_stream_spend_row_id.py | ||
| test_responses_websocket_turn_rows.py | ||
| test_roi_branch_spend.py | ||
| test_router_cooldown_failure_row.py | ||
| test_scoped_spend_reports.py | ||
| test_service_tier_stream_billing.py | ||
| test_session_grouped_logs_pages.py | ||
| test_session_total_spend.py | ||
| test_shutdown_flush.py | ||
| test_spend_attribution_contracts.py | ||
| test_spend_calculate.py | ||
| test_spend_capture_rate_captured_spend.py | ||
| test_spend_log_caller_session.py | ||
| test_spend_log_guardrail_index_retention.py | ||
| test_spend_log_latest_turn.py | ||
| test_spend_log_read_scope.py | ||
| test_spend_log_tool_payload_content.py | ||
| test_spend_log_write_batching.py | ||
| test_spend_logs_metadata_fields.py | ||
| test_spend_rollup_accuracy.py | ||
| test_stream_alias_billing.py | ||
| test_streamed_usage_estimate.py | ||
| test_tag_budget_enforcement.py | ||
| test_tag_spend_reset.py | ||
| test_team_budget_alerts.py | ||
| test_team_budget_enforcement.py | ||
| test_team_daily_activity_aggregated.py | ||
| test_team_member_budget_alerts.py | ||
| test_team_member_spend.py | ||
| test_team_member_spend_flush.py | ||
| test_team_member_total_spend_reconciliation.py | ||
| test_text_completion_stream_usage_cost.py | ||
| test_unmanaged_vertex_batch_deployment_routing_wire.py | ||
| test_usage_export_metadata.py | ||
| test_user_budget_on_team_keys.py | ||
| test_vertex_gemini_image_token_spend.py | ||
| test_vertex_image_regional_uplift.py | ||
| test_vertex_passthrough_regional_uplift_spend.py | ||
| test_vertex_regional_uplift_spend.py | ||