MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / IsSOPSEncrypted

Function IsSOPSEncrypted

internal/config/files.go:225–241  ·  view source on GitHub ↗

IsSOPSEncrypted checks if a file is SOPS-encrypted.

(path string, data []byte)

Source from the content-addressed store, hash-verified

223
224// IsSOPSEncrypted checks if a file is SOPS-encrypted.
225func IsSOPSEncrypted(path string, data []byte) bool {
226 // Check for SOPS header patterns in the entire content
227 content := string(data)
228 // Check for "sops:" YAML key (most common) or "\"sops\":" JSON key
229 hasSopsKey := contains(content, "sops:") || contains(content, "\"sops\":")
230 // Check for ENC[ marker which is specific to SOPS/Age
231 hasEnc := contains(content, "ENC[")
232
233 if DebugEnabled {
234 // Use global logger for debug output to avoid UI corruption
235 if globalLogger := logger.GetGlobalLogger(); globalLogger != nil {
236 globalLogger.Debug("SOPS detection for %s: hasSopsKey=%v, hasEnc=%v", path, hasSopsKey, hasEnc)
237 }
238 }
239
240 return hasSopsKey || hasEnc
241}
242
243// contains checks if a string contains a substring (case-insensitive).
244func contains(s, substr string) bool {

Callers 8

autoEncryptConfigFunction · 0.92
isSOPSEncryptedFunction · 0.92
SaveConfigToFileFunction · 0.92
showDeleteGroupDialogMethod · 0.92
showEditGroupDialogMethod · 0.92
SaveConfigFileFunction · 0.85
MergeWithFileMethod · 0.85

Calls 3

GetGlobalLoggerFunction · 0.92
containsFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected