fix: Sublime adapter default base URL and unbounded pagination#300
Open
pllesperance-lc wants to merge 1 commit into
Open
fix: Sublime adapter default base URL and unbounded pagination#300pllesperance-lc wants to merge 1 commit into
pllesperance-lc wants to merge 1 commit into
Conversation
Two bugs made the Sublime audit adapter unusable: 1. The default base URL was never applied. SublimeConfig.Validate() holds the fallback to https://platform.sublime.security, but nothing called it -- neither the constructor nor the general runner. An empty base_url produced requests with no scheme/host: Get "/v0/audit-log/events?...": unsupported protocol scheme "" NewSublimeAdapter now calls conf.Validate(), matching the bitwarden/ cylance/proofpoint_tap/trendmicro constructors. Validate also trims a trailing slash from base_url. 2. Every poll paged through the tenant's entire audit log history from offset 0, filtering client-side. Sublime Cloud tenants have unlimited audit retention, so high-volume tenants hit hundreds of pages per 30-second cycle until a deep-offset query exceeded the 30s HTTP timeout -- after which the next cycle restarted at offset 0, never shipping anything. Polls now pass created_at[gte] (watermark minus the existing overlap period) so the API only returns new events and pagination is bounded by new-event volume. Also fixed in passing: response bodies are now closed per page instead of deferred until all pages complete, and the non-200 path returns a real error instead of the preceding call's nil error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
The Sublime audit adapter is unusable in two ways:
1. The default base URL is never applied.
SublimeConfig.Validate()holds the fallback tohttps://platform.sublime.security, but nothing ever calls it — neither the constructor nor the general runner (containers/general/tool.go). With an emptybase_url(which the console suggests works for North America), every request fails with:2. Every poll pages through the tenant's entire audit log history.
makeOneRequestsent no time filter to the API — it started atoffset=0each 30-second cycle, walked all of history 500 events at a time, and discarded old events client-side. Sublime Cloud tenants have unlimited audit retention, so a high-volume tenant hits hundreds of pages per cycle until a deep-offset query exceeds the 30s HTTP timeout:The failed cycle is then discarded and the next one restarts at offset 0, so the adapter never ships a single event.
Fix
NewSublimeAdapternow callsconf.Validate(), matching the bitwarden/cylance/proofpoint_tap/trendmicro constructors, so the base URL default (and poll interval default) actually apply.Validate()also trims a trailing slash frombase_url.created_at[gte]=<watermark minus the existing 30s overlap>(API reference), so the server only returns new events and pagination is bounded by new-event volume instead of all-time history. Event selection semantics are otherwise unchanged (same client-side watermark filter and dedupe).deferred until all pages complete, and the non-200 path returns a real error instead of the preceding call's nilerr.Testing
TestMakeOneRequestNon200, which pinned the nil-error quirk as current behavior.TestNewSublimeAdapterValidates(constructor applies base URL default, rejects missing api key),TestMakeOneRequestSendsTimeFilter(polls carrycreated_at[gte]),TestMakeOneRequestPaginates(full page triggers next offset, results combined), and a trailing-slashValidatecase.go vet ./sublime/...,go test ./sublime/..., andgo build ./containers/...all pass.🤖 Generated with Claude Code