()
| 119 | |
| 120 | |
| 121 | def main(): |
| 122 | args = parse_arguments() |
| 123 | |
| 124 | # Configure output coloring |
| 125 | if hasattr(args, 'showcolor') and args.showcolor: |
| 126 | configure_color() |
| 127 | |
| 128 | # Application banner |
| 129 | print(BANNER % (colored(TITLE, 'green'), colored('%.2f' % VERSION, 'yellow'), colored(WEB_URL, 'blue'))) |
| 130 | |
| 131 | # Update definitions |
| 132 | if hasattr(args, 'perform_update') and args.perform_update: |
| 133 | print(colored('[+] Updating definitions', 'green')) |
| 134 | urlretrieve('https://raw.githubusercontent.com/bitsadmin/wesng/master/definitions.zip', 'definitions.zip') |
| 135 | cves, date = load_definitions('definitions.zip') |
| 136 | print(colored('[+] Obtained definitions created at ', 'green') + '%s' % colored(date, 'yellow')) |
| 137 | return |
| 138 | |
| 139 | # Update application |
| 140 | if hasattr(args, 'perform_wesupdate') and args.perform_wesupdate: |
| 141 | print(colored('[+] Updating wes.py', 'green')) |
| 142 | urlretrieve('https://raw.githubusercontent.com/bitsadmin/wesng/master/wes.py', 'wes.py') |
| 143 | print(colored('[+] Updated to the latest version. Relaunch wes.py to use.', 'green')) |
| 144 | return |
| 145 | |
| 146 | # Show tree of supersedes (for debugging purposes) |
| 147 | if hasattr(args, 'debugsupersedes') and args.debugsupersedes: |
| 148 | cves, date = load_definitions('definitions.zip') |
| 149 | productfilter = args.debugsupersedes[0] |
| 150 | supersedes = args.debugsupersedes[1:] |
| 151 | filtered = [] |
| 152 | for cve in cves: |
| 153 | if productfilter not in cve['AffectedProduct']: |
| 154 | continue |
| 155 | |
| 156 | filtered.append(cve) |
| 157 | |
| 158 | debug_supersedes(filtered, supersedes, 0, args.verbosesupersedes) |
| 159 | return |
| 160 | |
| 161 | # Show version |
| 162 | if hasattr(args, 'showversion') and args.showversion: |
| 163 | cves, date = load_definitions('definitions.zip') |
| 164 | print('Wes.py version: %.2f' % VERSION) |
| 165 | print('Database version: %s' % date) |
| 166 | return |
| 167 | |
| 168 | # Using the list of missing patches as a base |
| 169 | if hasattr(args, 'missingpatches') and args.missingpatches: |
| 170 | print(colored('[+] Loading definitions', 'green')) |
| 171 | cves, date = load_definitions('definitions.zip') |
| 172 | |
| 173 | # Obtain IDs of missing patches from file |
| 174 | print(colored('[+] Loading missing patches from file', 'green')) |
| 175 | missingpatches = [] |
| 176 | with open(args.missingpatches, 'r') as f: |
| 177 | missingpatches = f.read() |
| 178 | missingpatches = list(filter(None, [mp.upper().replace('KB', '') for mp in missingpatches.splitlines()])) |
no test coverage detected