This commit is contained in:
2026-09-23 21:20:11 +02:00
parent 4567df7ebb
commit c187b0c45e
14 changed files with 743 additions and 10 deletions
+47 -4
View File
@@ -518,8 +518,11 @@ def analyze_file(path: Path, token: str, size: int, sha256: str) -> dict[str, An
embedded_switches = [marker.decode("ascii") for marker in SWITCH_MARKERS if marker.decode("ascii").lower() in found_markers]
identity_text = f"{filename} {product_name} {manufacturer}".casefold()
suppress_browser_default = "greenshot" in identity_text
process_names_default = "Greenshot.exe" if "greenshot" in identity_text else ""
is_greenshot = "greenshot" in identity_text
suppress_browser_default = is_greenshot
process_names_default = "Greenshot.exe" if is_greenshot else ""
start_application_default = is_greenshot
start_executable_default = r"C:\Program Files\Greenshot\Greenshot.exe" if is_greenshot else ""
analysis = {
"token": token,
"filename": filename,
@@ -543,6 +546,9 @@ def analyze_file(path: Path, token: str, size: int, sha256: str) -> dict[str, An
"embedded_switches": embedded_switches,
"suppress_browser_default": suppress_browser_default,
"process_names_default": process_names_default,
"start_application_default": start_application_default,
"start_executable_default": start_executable_default,
"start_arguments_default": "",
"warning_keys": warning_keys,
"analyzed_at": datetime.now(timezone.utc).isoformat(),
"msiinfo_available": shutil.which("msiinfo") is not None,
@@ -715,6 +721,11 @@ def _export_values(
reboot_codes: str,
suppress_browser: bool = False,
process_names: str = "",
start_application: bool = False,
start_executable: str = "",
start_arguments: str = "",
start_only_if_user_logged_on: bool = True,
start_fail_job_on_error: bool = False,
) -> dict[str, Any]:
return {
"product_name": _form_value(product_name, meta.get("product_name", "")),
@@ -728,6 +739,11 @@ def _export_values(
"reboot_codes": _parse_codes(reboot_codes, meta.get("reboot_codes") or []),
"suppress_browser": bool(suppress_browser),
"process_names": normalize_process_names(process_names),
"start_application": bool(start_application),
"start_executable": _form_value(start_executable, meta.get("start_executable_default", ""))[:1024],
"start_arguments": str(start_arguments or "").strip()[:2048],
"start_only_if_user_logged_on": bool(start_only_if_user_logged_on),
"start_fail_job_on_error": bool(start_fail_job_on_error),
}
@@ -767,6 +783,13 @@ def _build_package_manifest(
"grace_seconds": 5,
"force_close": True,
},
"post_install": {
"start_application": values["start_application"],
"executable": values["start_executable"],
"arguments": values["start_arguments"],
"only_if_user_logged_on": values["start_only_if_user_logged_on"],
"fail_job_on_error": values["start_fail_job_on_error"],
},
"detection": {
"script": "detect.ps1",
"method": detection_method,
@@ -811,10 +834,15 @@ def register_setup_analyzer(app: Any, templates: Any, require_admin: Callable[[R
reboot_codes: str = Form(""),
suppress_browser: bool = Form(False),
process_names: str = Form(""),
start_application: bool = Form(False),
start_executable: str = Form(""),
start_arguments: str = Form(""),
start_only_if_user_logged_on: bool = Form(False),
start_fail_job_on_error: bool = Form(False),
):
require_admin(request)
target, meta = _analysis_file(token)
values = _export_values(meta, product_name, product_version, manufacturer, architecture, install_arguments, timeout_seconds, run_as, success_codes, reboot_codes, suppress_browser, process_names)
values = _export_values(meta, product_name, product_version, manufacturer, architecture, install_arguments, timeout_seconds, run_as, success_codes, reboot_codes, suppress_browser, process_names, start_application, start_executable, start_arguments, start_only_if_user_logged_on, start_fail_job_on_error)
package = _build_package_manifest(target, meta, values)
package, _profile_notes = normalize_package_manifest(package)
script = build_generated_install_script(package)
@@ -837,10 +865,15 @@ def register_setup_analyzer(app: Any, templates: Any, require_admin: Callable[[R
reboot_codes: str = Form(""),
suppress_browser: bool = Form(False),
process_names: str = Form(""),
start_application: bool = Form(False),
start_executable: str = Form(""),
start_arguments: str = Form(""),
start_only_if_user_logged_on: bool = Form(False),
start_fail_job_on_error: bool = Form(False),
):
require_admin(request)
target, meta = _analysis_file(token)
values = _export_values(meta, product_name, product_version, manufacturer, architecture, install_arguments, timeout_seconds, run_as, success_codes, reboot_codes, suppress_browser, process_names)
values = _export_values(meta, product_name, product_version, manufacturer, architecture, install_arguments, timeout_seconds, run_as, success_codes, reboot_codes, suppress_browser, process_names, start_application, start_executable, start_arguments, start_only_if_user_logged_on, start_fail_job_on_error)
package = _build_package_manifest(target, meta, values)
package, _profile_notes = normalize_package_manifest(package)
install_script = build_generated_install_script(package)
@@ -878,6 +911,11 @@ def register_setup_analyzer(app: Any, templates: Any, require_admin: Callable[[R
reboot_codes: str = Form(""),
suppress_browser: bool = Form(False),
process_names: str = Form(""),
start_application: bool = Form(False),
start_executable: str = Form(""),
start_arguments: str = Form(""),
start_only_if_user_logged_on: bool = Form(False),
start_fail_job_on_error: bool = Form(False),
db: Session = Depends(get_db),
):
require_admin(request)
@@ -895,6 +933,11 @@ def register_setup_analyzer(app: Any, templates: Any, require_admin: Callable[[R
reboot_codes,
suppress_browser,
process_names,
start_application,
start_executable,
start_arguments,
start_only_if_user_logged_on,
start_fail_job_on_error,
)
manifest = _build_package_manifest(target, meta, values)
manifest, _profile_notes = normalize_package_manifest(manifest)