MCPcopy Create free account
hub / github.com/codeyourweb/irma / quarantineContent

Function quarantineContent

analysis.go:161–182  ·  view source on GitHub ↗

quarantineContent copy and encrypt suspicious content

(content []byte, filename string, quarantinePath string)

Source from the content-addressed store, hash-verified

159
160// quarantineContent copy and encrypt suspicious content
161func quarantineContent(content []byte, filename string, quarantinePath string) (err error) {
162 _, err = os.Stat(quarantinePath)
163 if os.IsNotExist(err) {
164 if err := os.MkdirAll(quarantinePath, 0600); err != nil {
165 return err
166 }
167 }
168
169 c, err := rc4.NewCipher([]byte(quarantineKey))
170 if err != nil {
171 return err
172 }
173
174 xPE := make([]byte, len(content))
175 c.XORKeyStream(xPE, content)
176 err = os.WriteFile(quarantinePath+"/"+filename+".irma", []byte(b64.StdEncoding.EncodeToString(xPE)), 0644)
177 if err != nil {
178 return err
179 }
180
181 return nil
182}

Callers 2

QuarantineProcessFunction · 0.85
QuarantineFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected