ExtractDataChannel extracts file from FTP data channel
(conv *core.ConversationInfo, data []byte, conn *FTPDataConnection)
| 422 | |
| 423 | // ExtractDataChannel extracts file from FTP data channel |
| 424 | func ExtractDataChannel(conv *core.ConversationInfo, data []byte, conn *FTPDataConnection) error { |
| 425 | if len(data) == 0 { |
| 426 | return nil |
| 427 | } |
| 428 | |
| 429 | ftpLog.Info("Extracting FTP data channel file", |
| 430 | zap.String("filename", conn.Filename), |
| 431 | zap.String("command", conn.Command), |
| 432 | zap.Int("dataSize", len(data)), |
| 433 | zap.String("ident", conv.Ident), |
| 434 | ) |
| 435 | |
| 436 | // Use file extraction framework |
| 437 | extractor, ok := file.GetExtractor("FTP") |
| 438 | if !ok { |
| 439 | ftpLog.Error("FTP file extractor not registered") |
| 440 | return nil |
| 441 | } |
| 442 | |
| 443 | flowDirection := "server_to_client" |
| 444 | if conn.Command == "STOR" { |
| 445 | flowDirection = "client_to_server" |
| 446 | } |
| 447 | |
| 448 | metadata := file.FileMetadata{ |
| 449 | ConnectionUID: conv.Ident, |
| 450 | FlowDirection: flowDirection, |
| 451 | FTPCommand: conn.Command, |
| 452 | Filename: filepath.Base(conn.Filename), |
| 453 | Host: conn.IP, |
| 454 | } |
| 455 | |
| 456 | return extractor.ExtractFile(conv, data, metadata) |
| 457 | } |
no test coverage detected