From 414a10f5e34fd55b83e2af5a5ae8287759f42f86 Mon Sep 17 00:00:00 2001 From: gt Date: Tue, 14 Mar 2023 10:24:43 -0400 Subject: [PATCH 1/3] added custom http/https and ssh port moved prompts folder --- Dockerfile | 7 ++--- app/app.py | 26 ++++++++++++++++--- .../performance/high_memory.txt | 0 .../vpn/tunnel_down.txt | 0 .../performance/debug_memory.txt | 0 .../vpn/debug_tunnel_down.txt | 0 startup.sh | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) rename {app/chatgpt_prompts => chatgpt_prompts}/performance/high_memory.txt (100%) rename {app/chatgpt_prompts => chatgpt_prompts}/vpn/tunnel_down.txt (100%) rename {app/debug_commands => debug_commands}/performance/debug_memory.txt (100%) rename {app/debug_commands => debug_commands}/vpn/debug_tunnel_down.txt (100%) diff --git a/Dockerfile b/Dockerfile index 282881e..99c22e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,13 +6,14 @@ WORKDIR /app # Copy the requirements.txt file to the working directory COPY requirements.txt . +# Make sure requests is installed RUN pip install requests # Install the required Python packages RUN pip install --no-cache-dir -r requirements.txt -# Copy the entire contents of the app folder to the working directory -COPY app/ . +# Copy the entire app folder to the working directory +COPY app/ /app/ # Copy the startup script to the working directory COPY startup.sh . @@ -21,4 +22,4 @@ COPY startup.sh . RUN chmod +x startup.sh # Start the Streamlit app using the startup script -CMD ["/bin/bash", "startup.sh"] \ No newline at end of file +CMD ["/bin/bash", "startup.sh"] diff --git a/app/app.py b/app/app.py index 9869994..e716627 100644 --- a/app/app.py +++ b/app/app.py @@ -21,6 +21,21 @@ def main(): st.sidebar.write("Please fill in the following information to get started:") device_type = st.sidebar.selectbox("Device Type", ["FortiGate"]) device_ip = st.sidebar.text_input("Device IP Address") + scheme = st.sidebar.radio( + "HTTP or HTTPS?", + ( + "http", + "https", + ), + horizontal=True, + ) + scheme_port = st.sidebar.text_input( + "HTTP/HTTPS Port", + placeholder="Empty for HTTP Default: 80, HTTPS Default: 443", + ) + ssh_port = st.sidebar.text_input("SSH Port", placeholder="Empty for Default: 22") + if not ssh_port: + ssh_port = 22 device_username = st.sidebar.text_input("Device Username") device_password = st.sidebar.text_input("Device Password", type="password") # ********************************************************************************************************************** @@ -34,6 +49,8 @@ def main(): host=device_ip, username=device_username, password=device_password, + scheme=scheme, + port=scheme_port, ) fgt.login() if fgt.is_connected: @@ -94,7 +111,7 @@ def get_phase2_name(vpn_tunnel_name) -> str: # ********************************************************************************************************************** if problem_type == "Tunnel Down": debug_prompt_path = os.path.join( - "debug_commands", "vpn", "debug_tunnel_down.txt" + "..", "debug_commands", "vpn", "debug_tunnel_down.txt" ) with open(debug_prompt_path, "r") as f: debug_commands = f.read() @@ -108,7 +125,7 @@ def get_phase2_name(vpn_tunnel_name) -> str: f"diag vpn tunnel up {phase2_name} {vpn_tunnel} 1" ) chatgpt_prompt_path = os.path.join( - "chatgpt_prompts", "vpn", "tunnel_down.txt" + "..", "chatgpt_prompts", "vpn", "tunnel_down.txt" ) with open(chatgpt_prompt_path, "r") as f: chatgpt_prompt = f.read() @@ -126,13 +143,13 @@ def get_phase2_name(vpn_tunnel_name) -> str: if problem_type == "High Memory": debug_prompt_path = os.path.join( - "debug_commands", "performance", "debug_memory.txt" + "..", "debug_commands", "performance", "debug_memory.txt" ) with open(debug_prompt_path, "r") as f: debug_commands = f.read() debug_commands = debug_commands.splitlines() chatgpt_prompt_path = os.path.join( - "chatgpt_prompts", "performance", "high_memory.txt" + "..", "chatgpt_prompts", "performance", "high_memory.txt" ) with open(chatgpt_prompt_path, "r") as f: chatgpt_prompt = f.read() @@ -151,6 +168,7 @@ def get_phase2_name(vpn_tunnel_name) -> str: "username": device_username, "password": device_password, "fast_cli": False, + "port": ssh_port, } try: with st.spinner("Connecting to device..."): diff --git a/app/chatgpt_prompts/performance/high_memory.txt b/chatgpt_prompts/performance/high_memory.txt similarity index 100% rename from app/chatgpt_prompts/performance/high_memory.txt rename to chatgpt_prompts/performance/high_memory.txt diff --git a/app/chatgpt_prompts/vpn/tunnel_down.txt b/chatgpt_prompts/vpn/tunnel_down.txt similarity index 100% rename from app/chatgpt_prompts/vpn/tunnel_down.txt rename to chatgpt_prompts/vpn/tunnel_down.txt diff --git a/app/debug_commands/performance/debug_memory.txt b/debug_commands/performance/debug_memory.txt similarity index 100% rename from app/debug_commands/performance/debug_memory.txt rename to debug_commands/performance/debug_memory.txt diff --git a/app/debug_commands/vpn/debug_tunnel_down.txt b/debug_commands/vpn/debug_tunnel_down.txt similarity index 100% rename from app/debug_commands/vpn/debug_tunnel_down.txt rename to debug_commands/vpn/debug_tunnel_down.txt diff --git a/startup.sh b/startup.sh index b57f26f..d15eb19 100644 --- a/startup.sh +++ b/startup.sh @@ -4,4 +4,4 @@ pip install netmiko==3.4.0 # Start the Streamlit app -streamlit run --server.port 8501 app.py +streamlit run --server.port 8501 app/app.py From 6615bc030d306be7640033609b381f668a3c6abc Mon Sep 17 00:00:00 2001 From: gt Date: Tue, 14 Mar 2023 10:36:54 -0400 Subject: [PATCH 2/3] update --- app/app.py | 8 ++++---- .../chatgpt_prompts}/performance/high_memory.txt | 0 .../chatgpt_prompts}/vpn/tunnel_down.txt | 0 .../debug_commands}/performance/debug_memory.txt | 0 .../debug_commands}/vpn/debug_tunnel_down.txt | 0 startup.sh | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename {chatgpt_prompts => app/chatgpt_prompts}/performance/high_memory.txt (100%) rename {chatgpt_prompts => app/chatgpt_prompts}/vpn/tunnel_down.txt (100%) rename {debug_commands => app/debug_commands}/performance/debug_memory.txt (100%) rename {debug_commands => app/debug_commands}/vpn/debug_tunnel_down.txt (100%) diff --git a/app/app.py b/app/app.py index e716627..5f5be5a 100644 --- a/app/app.py +++ b/app/app.py @@ -111,7 +111,7 @@ def get_phase2_name(vpn_tunnel_name) -> str: # ********************************************************************************************************************** if problem_type == "Tunnel Down": debug_prompt_path = os.path.join( - "..", "debug_commands", "vpn", "debug_tunnel_down.txt" + "debug_commands", "vpn", "debug_tunnel_down.txt" ) with open(debug_prompt_path, "r") as f: debug_commands = f.read() @@ -125,7 +125,7 @@ def get_phase2_name(vpn_tunnel_name) -> str: f"diag vpn tunnel up {phase2_name} {vpn_tunnel} 1" ) chatgpt_prompt_path = os.path.join( - "..", "chatgpt_prompts", "vpn", "tunnel_down.txt" + "chatgpt_prompts", "vpn", "tunnel_down.txt" ) with open(chatgpt_prompt_path, "r") as f: chatgpt_prompt = f.read() @@ -143,13 +143,13 @@ def get_phase2_name(vpn_tunnel_name) -> str: if problem_type == "High Memory": debug_prompt_path = os.path.join( - "..", "debug_commands", "performance", "debug_memory.txt" + "debug_commands", "performance", "debug_memory.txt" ) with open(debug_prompt_path, "r") as f: debug_commands = f.read() debug_commands = debug_commands.splitlines() chatgpt_prompt_path = os.path.join( - "..", "chatgpt_prompts", "performance", "high_memory.txt" + "chatgpt_prompts", "performance", "high_memory.txt" ) with open(chatgpt_prompt_path, "r") as f: chatgpt_prompt = f.read() diff --git a/chatgpt_prompts/performance/high_memory.txt b/app/chatgpt_prompts/performance/high_memory.txt similarity index 100% rename from chatgpt_prompts/performance/high_memory.txt rename to app/chatgpt_prompts/performance/high_memory.txt diff --git a/chatgpt_prompts/vpn/tunnel_down.txt b/app/chatgpt_prompts/vpn/tunnel_down.txt similarity index 100% rename from chatgpt_prompts/vpn/tunnel_down.txt rename to app/chatgpt_prompts/vpn/tunnel_down.txt diff --git a/debug_commands/performance/debug_memory.txt b/app/debug_commands/performance/debug_memory.txt similarity index 100% rename from debug_commands/performance/debug_memory.txt rename to app/debug_commands/performance/debug_memory.txt diff --git a/debug_commands/vpn/debug_tunnel_down.txt b/app/debug_commands/vpn/debug_tunnel_down.txt similarity index 100% rename from debug_commands/vpn/debug_tunnel_down.txt rename to app/debug_commands/vpn/debug_tunnel_down.txt diff --git a/startup.sh b/startup.sh index d15eb19..47641a3 100644 --- a/startup.sh +++ b/startup.sh @@ -4,4 +4,4 @@ pip install netmiko==3.4.0 # Start the Streamlit app -streamlit run --server.port 8501 app/app.py +streamlit run --server.port 8501 /app/app.py From 28c79b4c2e6d5dbfc5b61583e6fb0b2adea2d011 Mon Sep 17 00:00:00 2001 From: gt Date: Tue, 14 Mar 2023 11:00:31 -0400 Subject: [PATCH 3/3] update readme --- README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba2155f..a8a0282 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,30 @@ FortiGPT Troubleshooting Assistant requires no dependencies to be installed. Ins ## Installation -To install FortiGPT Troubleshooting Assistant, simply run the following command: +To run FortiGPT Troubleshooting Assistant, simply follow the steps below: +Clone the repo ``` -docker run -p 8501:8501 -e OPENAI_API_KEY=XXXXXXXXXXXXXXX gt732/fortigpt +git clone https://github.com/gt732/FortiGPT.git +``` +Change into the app directory +``` +cd FortiGPT/app/ +``` +Run the docker command. Local volumes allows you to modify the chatgpt prompts and debug commands. +This will be synced to the container. +``` +docker run -d \ + -p 8501:8501 \ + -v $(pwd)/chatgpt_prompts:/app/chatgpt_prompts \ + -v $(pwd)/debug_commands:/app/debug_commands \ + -e OPENAI_API_KEY=your_api_key \ + gt732/fortigpt ``` ## Login Screen -![alt text](https://i.imgur.com/p5kirWy.png) +![alt text](https://i.imgur.com/4Je8TrR.png) ## Demo VPN Phase1 Settings mis-match ![alt text](https://i.imgur.com/CJnhDhJ.png)