MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / IsBinary

Function IsBinary

internal/sessions/transfer.go:82–93  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Binary detection --------------------------------------------------------------------------- IsBinary returns true if data contains NUL bytes or is not valid UTF-8.

(data []byte)

Source from the content-addressed store, hash-verified

80
81// IsBinary returns true if data contains NUL bytes or is not valid UTF-8.
82func IsBinary(data []byte) bool {
83 if len(data) == 0 {
84 return false
85 }
86 // Check for NUL bytes (common in binaries, never in text).
87 for _, b := range data {
88 if b == 0 {
89 return true
90 }
91 }
92 return !utf8.Valid(data)
93}
94
95// ---------------------------------------------------------------------------
96// Agent profile matching

Callers 7

TestIsBinary_PlainTextFunction · 0.85
TestIsBinary_UTF8TextFunction · 0.85
TestIsBinary_NulByteFunction · 0.85
TestIsBinary_InvalidUTF8Function · 0.85
TestIsBinary_EmptyDataFunction · 0.85
TestIsBinary_PNGHeaderFunction · 0.85
PlanUploadFunction · 0.85

Calls

no outgoing calls

Tested by 6

TestIsBinary_PlainTextFunction · 0.68
TestIsBinary_UTF8TextFunction · 0.68
TestIsBinary_NulByteFunction · 0.68
TestIsBinary_InvalidUTF8Function · 0.68
TestIsBinary_EmptyDataFunction · 0.68
TestIsBinary_PNGHeaderFunction · 0.68