Return a list of Reference from a list of URL reference in md format >>> get_references(["- http://1-4a.com/cgi-bin/alienform/af.cgi"]) [Reference(reference_id='', reference_type='', url='http://1-4a.com/cgi-bin/alienform/af.cgi', severities=[])] >>> get_references(["- [Mitre CVE-20
(references)
| 91 | |
| 92 | |
| 93 | def get_references(references): |
| 94 | """ |
| 95 | Return a list of Reference from a list of URL reference in md format |
| 96 | >>> get_references(["- http://1-4a.com/cgi-bin/alienform/af.cgi"]) |
| 97 | [Reference(reference_id='', reference_type='', url='http://1-4a.com/cgi-bin/alienform/af.cgi', severities=[])] |
| 98 | >>> get_references(["- [Mitre CVE-2021-42712](https://www.cve.org/CVERecord?id=CVE-2021-42712)"]) |
| 99 | [Reference(reference_id='', reference_type='', url='https://www.cve.org/CVERecord?id=CVE-2021-42712', severities=[])] |
| 100 | """ |
| 101 | urls = [] |
| 102 | for ref in references: |
| 103 | if ref.startswith("- "): |
| 104 | urls.append(matcher_url(ref[2::])) |
| 105 | else: |
| 106 | urls.append(matcher_url(ref)) |
| 107 | |
| 108 | return [Reference(url=url) for url in urls if url] |
| 109 | |
| 110 | |
| 111 | def matcher_url(ref) -> str: |