File size: 474 Bytes
19949cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c73ca9d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import re

def validate_cve_id(cve_id):
    """Validate CVE ID format"""
    pattern = r'^CVE-\d{4}-\d{4,}$'
    return bool(re.match(pattern, cve_id.upper()))

# Test
if __name__ == "__main__":
    test_cases = [
        "CVE-2021-44228",  # Should pass
        "CVE-2020-1234",   # Should pass  
        "invalid",         # Should fail
    ]
    
    for cve in test_cases:
        result = validate_cve_id(cve)
        print(f"{cve}: {'Valid' if result else 'Invalid'}")