MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / xjar

Function xjar

opensca/walk/zip.go:85–113  ·  view source on GitHub ↗
(ctx context.Context, filter ExtractFileFilter, input, output string)

Source from the content-addressed store, hash-verified

83}
84
85func xjar(ctx context.Context, filter ExtractFileFilter, input, output string) bool {
86
87 if !checkFileExt(input, ".jar") {
88 return false
89 }
90
91 // 生成临时文件
92 tempf := common.CreateTemp("jar")
93 defer os.Remove(tempf.Name())
94
95 data, err := os.ReadFile(input)
96 if err != nil {
97 logs.Warn(err)
98 tempf.Close()
99 return false
100 }
101
102 // 剔除可执行jar包前的bash脚本
103 i := bytes.Index(data, M_ZIP)
104 if i == -1 {
105 tempf.Close()
106 return false
107 }
108
109 tempf.Write(data[i:])
110 tempf.Close()
111
112 return xzip(ctx, filter, tempf.Name(), output)
113}

Callers 1

decompressFunction · 0.85

Calls 7

CreateTempFunction · 0.92
WarnFunction · 0.92
checkFileExtFunction · 0.85
xzipFunction · 0.85
IndexMethod · 0.80
WriteMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected