Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
command = f"katana -config {config_file_path} -u {url} > {output_file}"
|
| 18 |
try:
|
| 19 |
-
subprocess.run(command, shell=True, check=True)
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 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)
|