Spaces:
Sleeping
Sleeping
| import requests | |
| def fetch_cve_simple(cve_id): | |
| """Fetch CVE data from NIST NVD API""" | |
| url = f"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId={cve_id}" | |
| try: | |
| response = requests.get(url, timeout=10) | |
| if response.status_code == 200: | |
| data = response.json() | |
| if 'vulnerabilities' in data and data['vulnerabilities']: | |
| return data['vulnerabilities'][0] | |
| return None | |
| except Exception as e: | |
| print(f"Error: {e}") | |
| return None | |
| # Test | |
| if __name__ == "__main__": | |
| cve_data = fetch_cve_simple("CVE-2021-44228") | |
| if cve_data: | |
| print(" API test successful") | |
| cve = cve_data['cve'] | |
| print(f"CVE ID: {cve['id']}") | |
| print(f"Description: {cve['descriptions'][0]['value'][:100]}...") | |
| else: | |
| print(" API test failed") | |