FTP
FTP integration to download or upload files to a remote FTP server. Please note that FTP transfer is insecure. Please use it with care.
Utilities · FTP
Details
| ID | FTP |
|---|---|
| Provider | Open Source |
| Category | Utilities |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.8.3296088 |
| Supported Modules | Agentix XSIAM |
README
FTP integration to download or upload files to a remote FTP server. Please note that FTP transfer is insecure. Please use it with care.
Configure FTP in Cortex
| Parameter | Required |
|---|---|
| Host | True |
| Port | False |
| Username | False |
| Password | False |
| Use system proxy settings | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
ftp-ls
List all the files under the current folder.
Base Command
ftp-ls
Input
| Argument Name | Description | Required |
|---|---|---|
| path | The path to list. | Optional |
Context Output
There is no context output for this command.
ftp-put
Upload file to FTP server.
Base Command
ftp-put
Input
| Argument Name | Description | Required |
|---|---|---|
| entry_id | The Entry ID of the file to upload. | Required |
| target | The target FTP server to upload the file to. | Required |
Context Output
There is no context output for this command.
ftp-get
Download file from FTP server.
Base Command
ftp-get
Input
| Argument Name | Description | Required |
|---|---|---|
| file_path | The path to the file to download from the FTP server. | Required |
| file_name | The file name to download from the FTP server. | Required |
Context Output
There is no context output for this command.
Configuration parameters
host— Host (required)port— Portcredentials— Usernameproxy— Use system proxy settings
Commands (3)
-
ftp-getDownload file from FTP server.
-
ftp-lsList all the files under the current folder.
-
ftp-putUpload file to FTP server.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """ IMPORT """ from ftplib import FTP """ MAIN """ def main(): HOST = demisto.params().get("host") PORT = demisto.params().get("port") if demisto.params().get("port") else "21" USER = demisto.params()["credentials"]["identifier"] PASSWD = demisto.params()["credentials"]["password"] if demisto.command() == "test-module": try: with FTP() as ftp: # noqa: S321 ftp.connect(host=HOST, port=int(PORT)) ftp.login(user=USER, passwd=PASSWD) ftp.voidcmd("NOOP") demisto.results("ok") except Exception as excp: return_error(f"Error occurred - Error: {str(excp)}") if demisto.command() == "ftp-ls": path = demisto.args().get("path") list_path = path if path else "~/" try: with FTP() as ftp: # noqa: S321 ftp.connect(host=HOST, port=int(PORT)) ftp.login(user=USER, passwd=PASSWD) outputs = CommandResults(outputs_prefix="FTP.List", outputs={"Files": ftp.nlst(f"{list_path}")}) return_results(outputs) except IndexError: return_results("There is no file or folder") except Exception as excp: return_error(f"Error occurred - Error: {str(excp)}") if demisto.command() == "ftp-put": entry_id = demisto.args().get("entry_id") target = demisto.args().get("target") try: with FTP() as ftp: # noqa: S321 ftp.connect(host=HOST, port=int(PORT)) ftp.login(user=USER, passwd=PASSWD) fileObject = demisto.getFilePath(entry_id) with open(fileObject["path"], "rb") as file: ftp.storbinary(f'STOR {target}/{fileObject["name"]}', file) return_results(f'File uploaded to {target}/{fileObject["name"]} successfully') except Exception as excp: return_error(f"Error occurred - Error: {str(excp)}") if demisto.command() == "ftp-get": file_path = demisto.args().get("file_path") file_name = demisto.args().get("file_name") try: with FTP() as ftp: # noqa: S321 ftp.connect(host=HOST, port=int(PORT)) ftp.login(user=USER, passwd=PASSWD) with open(f"/tmp/{file_name}", "wb") as file: ftp.retrbinary(f"RETR {file_path}/{file_name}", file.write) with open(f"/tmp/{file_name}") as f: data = f.read() return_results(fileResult(filename=file_name, data=data)) except Exception as excp: return_error(f"Error occurred - Error: {str(excp)}") if __name__ in ("__main__", "__builtin__", "builtins"): main()