MCPcopy Create free account
hub / github.com/JafarAkhondali/Morefixes / find_github_source_code_by_cve

Function find_github_source_code_by_cve

Code/giturl/github.py:40–62  ·  view source on GitHub ↗
(cve_id)

Source from the content-addressed store, hash-verified

38# print("GitHub repository not found for the given Composer PHP package.")
39
40def find_github_source_code_by_cve(cve_id):
41 # Build the GitHub Security Advisory API URL to search for the CVE
42 github_api_url = f"https://api.github.com/advisories/{cve_id}"
43
44 try:
45 # Make a GET request to the GitHub Security Advisory API
46 response = requests.get(github_api_url)
47 response.raise_for_status()
48
49 # Parse the response as JSON
50 advisory_info = response.json()
51
52 # Check if the advisory contains any references
53 if "references" in advisory_info:
54 # Extract the GitHub repository URLs from the references
55 github_urls = [ref["url"] for ref in advisory_info["references"] if "github.com" in ref["url"]]
56 return github_urls
57 else:
58 return None
59
60 except requests.exceptions.RequestException as e:
61 print(f"Error fetching GitHub information: {e}")
62 return None
63
64
65# Test the function with an example CVE identifier

Callers 1

github.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected