Spaces:
Sleeping
Sleeping
Download scripts/find_hero_case.py from Nitishkumar-ai/commitguard-env: direct link, hf CLI and curl.
- Browser
- Download file 822 Bytes
-
https://huggingface.co/spaces/Nitishkumar-ai/commitguard-env/resolve/main/scripts/find_hero_case.py
- Command line
-
hf download hf://spaces/Nitishkumar-ai/commitguard-env/scripts/find_hero_case.py
-
curl -L -o find_hero_case.py https://huggingface.co/spaces/Nitishkumar-ai/commitguard-env/resolve/main/scripts/find_hero_case.py
822 Bytes
| import json | |
| from pathlib import Path | |
| def find_hero_case(): | |
| data_path = Path("data/devign_filtered.jsonl") | |
| if not data_path.exists(): | |
| print("Data not found.") | |
| return | |
| with open(data_path, "r") as f: | |
| samples = [json.loads(line) for line in f] | |
| # Filter for interesting CWEs (SQLi, Command Injection, etc.) | |
| hero_candidates = [ | |
| s for s in samples | |
| if s["is_vulnerable"] and s["cwe"] in ["CWE-89", "CWE-78", "CWE-22", "CWE-119"] | |
| ] | |
| print(f"Found {len(hero_candidates)} hero candidates.") | |
| for s in hero_candidates[:5]: | |
| print("-" * 40) | |
| print(f"Sample ID: {s['sample_id']}") | |
| print(f"CWE: {s['cwe']}") | |
| print(f"Diff Context:\n{s['diff'][:300]}...") | |
| print("-" * 40) | |
| if __name__ == "__main__": | |
| find_hero_case() | |