binuser007 commited on
Commit
f1e007e
·
verified ·
1 Parent(s): 016f93e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -3,23 +3,23 @@ import subprocess
3
  import os
4
 
5
  def run_katana(url):
6
- # Set a custom configuration directory within /tmp
7
  katana_config_dir = "/tmp/katana"
8
  os.makedirs(katana_config_dir, exist_ok=True)
9
-
10
- # Ensure the config file exists, or create a dummy one if needed
11
  config_file_path = os.path.join(katana_config_dir, "config.yaml")
12
- if not os.path.exists(config_file_path):
13
- with open(config_file_path, 'w') as f:
14
- f.write("# Dummy configuration\n")
15
-
16
- output_file = "/tmp/urls.txt" # Use /tmp for writable directory
17
- command = f"katana -config {config_file_path} -u {url} > {output_file}"
18
  try:
19
- subprocess.run(command, shell=True, check=True)
20
- return output_file
 
 
 
21
  except subprocess.CalledProcessError as e:
22
- return f"Error running katana: {e}"
23
 
24
  # Ensure the /tmp/flagged directory exists
25
  os.makedirs("/tmp/flagged", exist_ok=True)
 
3
  import os
4
 
5
  def run_katana(url):
 
6
  katana_config_dir = "/tmp/katana"
7
  os.makedirs(katana_config_dir, exist_ok=True)
8
+
 
9
  config_file_path = os.path.join(katana_config_dir, "config.yaml")
10
+ with open(config_file_path, 'w') as f:
11
+ f.write("headless: true\n") # Add a valid configuration option
12
+
13
+ output_file = "/tmp/urls.txt"
14
+ command = f"katana -config {config_file_path} -u {url} -o {output_file}"
 
15
  try:
16
+ subprocess.run(command, shell=True, check=True, stderr=subprocess.PIPE, text=True)
17
+ if os.path.exists(output_file):
18
+ return output_file
19
+ else:
20
+ return "Katana completed but no output file was created."
21
  except subprocess.CalledProcessError as e:
22
+ return f"Error running katana: {e.stderr}"
23
 
24
  # Ensure the /tmp/flagged directory exists
25
  os.makedirs("/tmp/flagged", exist_ok=True)