Dateien nach "/" hochladen
This commit is contained in:
1 parent
d304b93207
commit
69436dac11
1 file changed
+34
-17
@@ -214,14 +214,11 @@ def normalize_components(raw_components: list) -> list:
|
|||||||
# getrennt von SkillSpectors eigenem Scan, nur um der KI echten Kontext für
|
# getrennt von SkillSpectors eigenem Scan, nur um der KI echten Kontext für
|
||||||
# den "Wofür ist das?"-Absatz zu geben statt nur der Sicherheitsfunde.
|
# den "Wofür ist das?"-Absatz zu geben statt nur der Sicherheitsfunde.
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
def extract_skill_context(target: str, is_zip: bool, work_dir: str) -> str:
|
def extract_skill_context(target: str, work_dir: str) -> str:
|
||||||
|
if target.startswith("http://") or target.startswith("https://"):
|
||||||
context_dir = Path(work_dir) / "context_extract"
|
context_dir = Path(work_dir) / "context_extract"
|
||||||
try:
|
try:
|
||||||
context_dir.mkdir(exist_ok=True)
|
context_dir.mkdir(exist_ok=True)
|
||||||
if is_zip:
|
|
||||||
with zipfile.ZipFile(target) as zf:
|
|
||||||
zf.extractall(context_dir)
|
|
||||||
else:
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["git", "clone", "--depth", "1", target, str(context_dir / "repo")],
|
["git", "clone", "--depth", "1", target, str(context_dir / "repo")],
|
||||||
timeout=60,
|
timeout=60,
|
||||||
@@ -233,14 +230,35 @@ def extract_skill_context(target: str, is_zip: bool, work_dir: str) -> str:
|
|||||||
or list(context_dir.rglob("skill.md"))
|
or list(context_dir.rglob("skill.md"))
|
||||||
or list(context_dir.rglob("README.md"))
|
or list(context_dir.rglob("README.md"))
|
||||||
)
|
)
|
||||||
if not candidates:
|
return candidates[0].read_text(errors="ignore")[:3000] if candidates else ""
|
||||||
return ""
|
|
||||||
return candidates[0].read_text(errors="ignore")[:3000]
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(context_dir, ignore_errors=True)
|
shutil.rmtree(context_dir, ignore_errors=True)
|
||||||
|
|
||||||
|
if target.lower().endswith(".zip"):
|
||||||
|
context_dir = Path(work_dir) / "context_extract"
|
||||||
|
try:
|
||||||
|
context_dir.mkdir(exist_ok=True)
|
||||||
|
with zipfile.ZipFile(target) as zf:
|
||||||
|
zf.extractall(context_dir)
|
||||||
|
candidates = (
|
||||||
|
list(context_dir.rglob("SKILL.md"))
|
||||||
|
or list(context_dir.rglob("skill.md"))
|
||||||
|
or list(context_dir.rglob("README.md"))
|
||||||
|
)
|
||||||
|
return candidates[0].read_text(errors="ignore")[:3000] if candidates else ""
|
||||||
|
except Exception:
|
||||||
|
return ""
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(context_dir, ignore_errors=True)
|
||||||
|
|
||||||
|
# Einzeln hochgeladene Datei (z. B. eine reine SKILL.md ohne ZIP)
|
||||||
|
try:
|
||||||
|
return Path(target).read_text(errors="ignore")[:3000]
|
||||||
|
except Exception:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Deutsche Klartext-Zusammenfassung des Reports per LLM (OpenRouter-kompatibel)
|
# Deutsche Klartext-Zusammenfassung des Reports per LLM (OpenRouter-kompatibel)
|
||||||
@@ -437,8 +455,8 @@ a{color:var(--orange)}
|
|||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<label>Git-Repository-URL</label>
|
<label>Git-Repository-URL</label>
|
||||||
<input type="text" name="git_url" placeholder="https://git.obraasch.de/olli1986/mein-skill">
|
<input type="text" name="git_url" placeholder="https://git.obraasch.de/olli1986/mein-skill">
|
||||||
<label>...oder ZIP-Datei hochladen (max. 50 MB)</label>
|
<label>...oder Datei hochladen (ZIP-Archiv oder einzelne SKILL.md, max. 50 MB)</label>
|
||||||
<input type="file" name="zip_file" accept=".zip">
|
<input type="file" name="zip_file" accept=".zip,.md">
|
||||||
<label>Wie ausführlich soll das Ergebnis sein?</label>
|
<label>Wie ausführlich soll das Ergebnis sein?</label>
|
||||||
<select name="report_level">
|
<select name="report_level">
|
||||||
<option value="quick">Nur Einschätzung (Score, Empfehlung, Fund-Anzahl – am schnellsten)</option>
|
<option value="quick">Nur Einschätzung (Score, Empfehlung, Fund-Anzahl – am schnellsten)</option>
|
||||||
@@ -577,9 +595,10 @@ def index():
|
|||||||
work_dir = tempfile.mkdtemp(dir=SCAN_TMP_DIR)
|
work_dir = tempfile.mkdtemp(dir=SCAN_TMP_DIR)
|
||||||
try:
|
try:
|
||||||
if zip_file and zip_file.filename:
|
if zip_file and zip_file.filename:
|
||||||
zip_path = Path(work_dir) / "upload.zip"
|
safe_name = Path(zip_file.filename).name or "upload"
|
||||||
zip_file.save(zip_path)
|
upload_path = Path(work_dir) / safe_name
|
||||||
target = str(zip_path)
|
zip_file.save(upload_path)
|
||||||
|
target = str(upload_path)
|
||||||
elif git_url:
|
elif git_url:
|
||||||
if not is_public_target(git_url):
|
if not is_public_target(git_url):
|
||||||
return render_template_string(
|
return render_template_string(
|
||||||
@@ -594,7 +613,7 @@ def index():
|
|||||||
PAGE,
|
PAGE,
|
||||||
allow_llm=ALLOW_LLM,
|
allow_llm=ALLOW_LLM,
|
||||||
result=None,
|
result=None,
|
||||||
error="Bitte eine Git-URL angeben oder eine ZIP-Datei hochladen.",
|
error="Bitte eine Git-URL angeben oder eine Datei hochladen.",
|
||||||
)
|
)
|
||||||
|
|
||||||
report_path = Path(work_dir) / "report.json"
|
report_path = Path(work_dir) / "report.json"
|
||||||
@@ -617,9 +636,7 @@ def index():
|
|||||||
summary_text = None
|
summary_text = None
|
||||||
summary_failed = False
|
summary_failed = False
|
||||||
if use_llm:
|
if use_llm:
|
||||||
skill_context = extract_skill_context(
|
skill_context = extract_skill_context(target, work_dir=work_dir)
|
||||||
target, is_zip=bool(zip_file and zip_file.filename), work_dir=work_dir
|
|
||||||
)
|
|
||||||
summary_text = generate_report_summary(result, skill_context)
|
summary_text = generate_report_summary(result, skill_context)
|
||||||
summary_failed = summary_text is None
|
summary_failed = summary_text is None
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user