MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / ValidateStdinInput

Function ValidateStdinInput

cmd/gosqlx/cmd/stdin_utils.go:135–155  ·  view source on GitHub ↗

ValidateStdinInput validates stdin content for security This is a wrapper around existing security validation

(content []byte)

Source from the content-addressed store, hash-verified

133// ValidateStdinInput validates stdin content for security
134// This is a wrapper around existing security validation
135func ValidateStdinInput(content []byte) error {
136 // Basic validation: check if content looks like SQL
137 if len(content) == 0 {
138 return fmt.Errorf("empty input")
139 }
140
141 // Size check (already done in ReadFromStdin, but double-check)
142 if len(content) > MaxStdinSize {
143 return fmt.Errorf("input too large: %d bytes (max %d)", len(content), MaxStdinSize)
144 }
145
146 // Additional validation: ensure it's not binary data
147 // Check for null bytes (common in binary files)
148 for i := 0; i < len(content) && i < 512; i++ {
149 if content[i] == 0 {
150 return fmt.Errorf("binary data detected in input")
151 }
152 }
153
154 return nil
155}
156
157// DetectInputMode determines the input mode based on arguments and stdin state
158// Returns: (useStdin bool, inputArg string, error)

Callers 9

lintFromStdinFunction · 0.70
TestInputValidationFunction · 0.70
ReadInputWithFallbackFunction · 0.70
validateFromStdinFunction · 0.70
analyzeFromStdinFunction · 0.70
formatFromStdinFunction · 0.70
parseFromStdinFunction · 0.70
TestValidateStdinInputFunction · 0.70

Calls 1

ErrorfMethod · 0.65

Tested by 3

TestInputValidationFunction · 0.56
TestValidateStdinInputFunction · 0.56