File size: 847 Bytes
19949cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be9311f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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")