INNER CODE UNIT · Python
analyze
stanfrbd/cyberbro · app.py:234
def analyze() -> tuple[str, int]:
"""Handle the analyze request with caching and an option to ignore cache."""
form_data = ioc_fanger.fang(request.form.get("observables", ""))
observables: list[Observable] = extract_observables(form_data)
selected_engines: list[str] = request.form.getlist("engines")
ignore_cache: bool = request.args.get("ignore_cache", "false").lower() == "true"
# Generate a secure hash for form data and engines using SHA-256
combined_data: str = f"{form_data}|{','.join(selected_engines)}"
cache_key: str = f"web-analyze-{hashlib.sha256(combined_data.encode('utf-8')).hexdigest()}"
if not ignore_cache:
# Check cache
cached_result = cache.get(cache_key)
if cached_result:
logger.debug(f"Cache hit: {cache_key}")
logger.debug(f"Cached result: {cached_result}")
return render_template(