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'}")