|
17 | 17 | from urllib.parse import urlparse |
18 | 18 |
|
19 | 19 | from security.models import CVE, CWE, Reference |
| 20 | +from util.logging import warning_message |
20 | 21 |
|
21 | 22 |
|
22 | 23 | def get_cve_reference(cve_id): |
@@ -111,22 +112,32 @@ def fixup_reference(ref): |
111 | 112 | url = fixup_bugzilla_url(url) |
112 | 113 | url = fixup_rhn_url(url) |
113 | 114 | if url.hostname == 'access.redhat.com': |
114 | | - if 'l1d-cache-eviction-and-vector-register-sampling' in url.path or \ |
115 | | - 'security/vulnerabilities/speculativeexecution' in url.path or \ |
116 | | - 'security/vulnerabilities/stackguard' in url.path: |
117 | | - ref_type = 'Link' |
118 | | - elif 'security/cve' in url.path: |
| 115 | + processed = False |
| 116 | + old_ref = url.path.split('/')[-1] |
| 117 | + if 'security/cve' in url.path: |
119 | 118 | return |
120 | | - else: |
121 | | - old_ref = url.path.split('/')[-1] |
| 119 | + elif url.path.startswith('/solutions/') or url.path.startswith('/articles/'): |
| 120 | + ref_type = 'Link' |
| 121 | + processed = True |
| 122 | + elif url.path.startswith('/security/vulnerabilities/'): |
| 123 | + if old_ref.isdigit() or old_ref.isalpha(): |
| 124 | + ref_type = 'Link' |
| 125 | + processed = True |
| 126 | + elif old_ref.startswith('cve'): |
| 127 | + ref_type = 'Link' |
| 128 | + processed = True |
| 129 | + if not processed: |
122 | 130 | refs = old_ref.split('-') |
123 | 131 | if ':' not in url.path: |
124 | 132 | try: |
125 | | - new_ref = f'{refs[0]}-{refs[1]}:{refs[2]}' |
| 133 | + if refs[0].upper() == 'RHSB': |
| 134 | + new_ref = f'{refs[0]}-{refs[1]}-{refs[2]}' |
| 135 | + else: |
| 136 | + new_ref = f'{refs[0]}-{refs[1]}:{refs[2]}' |
126 | 137 | path = url.path.replace(old_ref, new_ref) |
127 | 138 | url = url._replace(path=path) |
128 | 139 | except IndexError: |
129 | | - pass |
| 140 | + warning_message(f'Unable to process reference URL: {url}') |
130 | 141 | ref_type = refs[0].upper() |
131 | 142 | final_url = url.geturl() |
132 | 143 | if final_url in ['https://launchpad.net/bugs/', 'https://launchpad.net/bugs/XXXXXX']: |
|
0 commit comments