MCPcopy Create free account
hub / github.com/PostHog/duckgres / queryHasCreateSecret

Function queryHasCreateSecret

server/usersecrets/redact.go:80–95  ·  view source on GitHub ↗

queryHasCreateSecret reports whether query contains a CREATE SECRET at its head or in any top-level statement. It shares the tokenizer with RedactForLog (parseSecretDDLHead / splitTopLevel) so the query and error redactors can never drift apart. DROP SECRET (which carries only a name) is not a match

(query string)

Source from the content-addressed store, hash-verified

78// (parseSecretDDLHead / splitTopLevel) so the query and error redactors can
79// never drift apart. DROP SECRET (which carries only a name) is not a match.
80func queryHasCreateSecret(query string) bool {
81 if st, _, ok := parseSecretDDLHead(query); ok && st.Kind == KindCreate {
82 return true
83 }
84 // A single top-level statement whose head is not CREATE SECRET cannot hide
85 // secret DDL; only multi-statement strings need the per-segment scan.
86 if !hasTrailingStatement(query) {
87 return false
88 }
89 for _, seg := range splitTopLevel(query) {
90 if st, _, ok := parseSecretDDLHead(seg); ok && st.Kind == KindCreate {
91 return true
92 }
93 }
94 return false
95}

Callers 2

RedactForLogFunction · 0.85
RedactErrorForLogFunction · 0.85

Calls 3

parseSecretDDLHeadFunction · 0.85
hasTrailingStatementFunction · 0.85
splitTopLevelFunction · 0.85

Tested by

no test coverage detected