-
Notifications
You must be signed in to change notification settings - Fork 8
Update newpool to add IAM auth beforeConnect #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
401e9a7
update newpool
mamundsen-specter 02903c3
update logging and variable names for coderabbit
mamundsen-specter e3bffd3
move DatabaseConfiguration from Bloodhound repo to dawgs
mamundsen-specter ef65e44
Merge branch 'main' into bi-1348-main
mamundsen-specter b66b204
update go.mod go.sum
mamundsen-specter 3e01779
urlencode password, update region call
mamundsen-specter 7d3b4dd
chore: clean up composition in config.go - make BeforeConnect in pool…
zinic 7c43cf9
Merge branch 'main' of github.com:SpecterOps/DAWGS into bi-1348-main
mamundsen-specter 96678e6
Merge branch 'main' of github.com:SpecterOps/DAWGS into bi-1348-main
mamundsen-specter b473e89
merge with main
mamundsen-specter b34cd9c
Merge branch 'main' of github.com:SpecterOps/DAWGS into bi-1348-main
mamundsen-specter 837bc43
fixup test NewPool calls
mamundsen-specter ad81ebb
move CNAME lookup to pool creation
mamundsen-specter 5d44793
Merge branch 'main' of github.com:SpecterOps/DAWGS into bi-1348-main
mamundsen-specter e3fcf9e
move CNAME lookup to before poolCfg creation
mamundsen-specter d8fedab
move back cname handling, quiet logs
mamundsen-specter c00ee81
update comments
mamundsen-specter eb97c09
Merge branch 'main' of github.com:SpecterOps/DAWGS into bi-1348-main
mamundsen-specter 7265ebc
add log for postgres connection string fallback
mamundsen-specter 7129bea
extract endpoint lookup and run before NewPool
mamundsen-specter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: SpecterOps/DAWGS
Length of output: 78
🏁 Script executed:
Repository: SpecterOps/DAWGS
Length of output: 79
🏁 Script executed:
Repository: SpecterOps/DAWGS
Length of output: 402
🏁 Script executed:
Repository: SpecterOps/DAWGS
Length of output: 3664
🏁 Script executed:
Repository: SpecterOps/DAWGS
Length of output: 3021
Cache static connection parameters during pool setup; refresh only auth tokens in
BeforeConnect.PostgreSQLConnectionString()loads AWS config (line 35 in drivers/config.go) and performs DNS lookup vianet.LookupCNAME()(line 40) on every invocation. When called insideBeforeConnectfor each new connection, this amplifies latency and failure surface under pool churn. Extract host, port, and database once duringNewPool(), then haveBeforeConnectuse onlyauth.BuildAuthToken()to generate the fresh time-limited credential.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added LookupEndpoint() to run before newpool creation and if endpoint field is empty. This should reduce the number of lookups, while still allowing IAM PostgreSQLConnectionString() calls outside of pool context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 3340
@mamundsen-specter, the fix looks good — the DNS concern from the original comment is now fully addressed. Here's the breakdown:CNAME lookup — ✅ resolved
cfg.Endpoint = cfg.LookupEndpoint()is called once before the closure is created. Sincecfgis a value type andEndpointis pre-populated,RDSIAMAuthConnectionString()will take theif s.Endpoint != ""branch (line 41–42 ofconfig.go) on every subsequentBeforeConnectcall, skipping thenet.LookupCNAMEentirely.awsConfig.LoadDefaultConfig— still called per connectionRDSIAMAuthConnectionString()still invokesawsConfig.LoadDefaultConfig(context.TODO())on everyBeforeConnect. This is the remaining overhead, but it's likely intentional and acceptable — reloading the AWS config on each call allows credential rotation (IMDS, IAM role assumption, env-var changes) to be picked up without restarting the pool. Caching it would risk using stale credentials for token generation.The fix strikes a reasonable balance: the expensive/durable operation (CNAME lookup) is cached, while the security-sensitive operation (credential + token refresh) stays live per-connection.
✏️ Learnings added
🧠 Learnings used