| @@ 197-225 (lines=29) @@ | ||
| 194 | VULNERABILITY = "vuln" |
|
| 195 | ||
| 196 | ||
| 197 | def get_filter_type_from_string( |
|
| 198 | filter_type: Optional[str] |
|
| 199 | ) -> Optional[FilterType]: |
|
| 200 | """ Convert a filter type string to an actual FilterType instance |
|
| 201 | ||
| 202 | Arguments: |
|
| 203 | filter_type (str): Filter type string to convert to a FilterType |
|
| 204 | """ |
|
| 205 | if not filter_type: |
|
| 206 | return None |
|
| 207 | ||
| 208 | if filter_type == 'vuln': |
|
| 209 | return FilterType.VULNERABILITY |
|
| 210 | ||
| 211 | if filter_type == 'os': |
|
| 212 | return FilterType.OPERATING_SYSTEM |
|
| 213 | ||
| 214 | if filter_type == 'config': |
|
| 215 | return FilterType.SCAN_CONFIG |
|
| 216 | ||
| 217 | if filter_type == 'secinfo': |
|
| 218 | return FilterType.ALL_SECINFO |
|
| 219 | ||
| 220 | try: |
|
| 221 | return FilterType[filter_type.upper()] |
|
| 222 | except KeyError: |
|
| 223 | raise InvalidArgument( |
|
| 224 | argument='filter_type', |
|
| 225 | function=get_filter_type_from_string.__name__, |
|
| 226 | ) |
|
| 227 | ||
| 228 | ||
| @@ 418-443 (lines=26) @@ | ||
| 415 | USER = "user" |
|
| 416 | ||
| 417 | ||
| 418 | def get_filter_type_from_string( |
|
| 419 | filter_type: Optional[str] |
|
| 420 | ) -> Optional[FilterType]: |
|
| 421 | """ Convert a filter type string to an actual FilterType instance |
|
| 422 | ||
| 423 | Arguments: |
|
| 424 | filter_type: Filter type string to convert to a FilterType |
|
| 425 | """ |
|
| 426 | if not filter_type: |
|
| 427 | return None |
|
| 428 | ||
| 429 | if filter_type == 'os': |
|
| 430 | return FilterType.OPERATING_SYSTEM |
|
| 431 | ||
| 432 | if filter_type == 'config': |
|
| 433 | return FilterType.SCAN_CONFIG |
|
| 434 | ||
| 435 | if filter_type == 'secinfo': |
|
| 436 | return FilterType.ALL_SECINFO |
|
| 437 | ||
| 438 | try: |
|
| 439 | return FilterType[filter_type.upper()] |
|
| 440 | except KeyError: |
|
| 441 | raise InvalidArgument( |
|
| 442 | argument='filter_type', |
|
| 443 | function=get_filter_type_from_string.__name__, |
|
| 444 | ) |
|
| 445 | ||
| 446 | ||