Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,26 @@ import os
|
|
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 |
-
|
11 |
-
|
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,
|
17 |
if os.path.exists(output_file):
|
18 |
return output_file
|
19 |
else:
|
20 |
-
return "Katana
|
21 |
except subprocess.CalledProcessError as e:
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
# Ensure the /tmp/flagged directory exists
|
25 |
os.makedirs("/tmp/flagged", exist_ok=True)
|
|
|
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 |
+
if not os.path.exists(config_file_path):
|
11 |
+
with open(config_file_path, 'w') as f:
|
12 |
+
f.write("# Dummy configuration\n")
|
13 |
+
|
14 |
output_file = "/tmp/urls.txt"
|
15 |
command = f"katana -config {config_file_path} -u {url} -o {output_file}"
|
16 |
+
|
17 |
try:
|
18 |
+
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
19 |
if os.path.exists(output_file):
|
20 |
return output_file
|
21 |
else:
|
22 |
+
return f"Katana ran successfully, but no output file was created. Katana output: {result.stdout}"
|
23 |
except subprocess.CalledProcessError as e:
|
24 |
+
error_message = f"Error running katana: {e.stderr}"
|
25 |
+
with open(output_file, 'w') as f:
|
26 |
+
f.write(error_message)
|
27 |
+
return output_file
|
28 |
|
29 |
# Ensure the /tmp/flagged directory exists
|
30 |
os.makedirs("/tmp/flagged", exist_ok=True)
|