Return the list of CWE IDs as integers from a list of weakness summaries, e.g., [379]. >>> get_weaknesses([ ... "CWE-379: Creation of Temporary File in Directory with Insecure Permissions", ... "CWE-362: Concurrent Execution using Shared Resource with Improper Synchroni
(cwe_data)
| 148 | |
| 149 | |
| 150 | def get_weaknesses(cwe_data): |
| 151 | """ |
| 152 | Return the list of CWE IDs as integers from a list of weakness summaries, e.g., [379]. |
| 153 | |
| 154 | >>> get_weaknesses([ |
| 155 | ... "CWE-379: Creation of Temporary File in Directory with Insecure Permissions", |
| 156 | ... "CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')" |
| 157 | ... ]) |
| 158 | [379, 362] |
| 159 | """ |
| 160 | cwe_list = [] |
| 161 | for line in cwe_data: |
| 162 | cwe_ids = re.findall(cwe_regex, line) |
| 163 | cwe_list.extend(cwe_ids) |
| 164 | |
| 165 | weaknesses = create_weaknesses_list(cwe_list) |
| 166 | return weaknesses |