MCPcopy
hub / github.com/slimtoolkit/slim / Detected

Function Detected

pkg/app/sensor/detector/binfile/binfile.go:16–46  ·  view source on GitHub ↗
(filePath string)

Source from the content-addressed store, hash-verified

14}
15
16func Detected(filePath string) (*BinProps, error) {
17 binFile, err := elf.Open(filePath)
18 if err == nil {
19 binProps := &BinProps{
20 IsBin: true,
21 }
22
23 switch binFile.Type {
24 case elf.ET_EXEC:
25 binProps.IsExe = true
26 case elf.ET_DYN:
27 binProps.IsSO = true
28 }
29
30 binFile.Close()
31 return binProps, nil
32 }
33
34 log.Debugf("binfile.Detected(%v) - elf.Open error: %v", filePath, err)
35
36 if elfErr, ok := err.(*elf.FormatError); ok {
37 if strings.Contains(elfErr.Error(), "bad magic number") {
38 return nil, nil
39 }
40
41 log.Debugf("binfile.Detected(%v) - malformed binary file", filePath)
42 return nil, err
43 }
44
45 return nil, err
46}

Callers 5

AllDependenciesFunction · 0.92
prepareArtifactsMethod · 0.92
saveSSHClientMethod · 0.92
saveOSLibsNetworkMethod · 0.92
saveArtifactsMethod · 0.92

Calls 2

CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected