| @@ 209-237 (lines=29) @@ | ||
| 206 | VULNERABILITY = "vuln" |
|
| 207 | ||
| 208 | ||
| 209 | def get_filter_type_from_string( |
|
| 210 | filter_type: Optional[str], |
|
| 211 | ) -> Optional[FilterType]: |
|
| 212 | """Convert a filter type string to an actual FilterType instance |
|
| 213 | ||
| 214 | Arguments: |
|
| 215 | filter_type (str): Filter type string to convert to a FilterType |
|
| 216 | """ |
|
| 217 | if not filter_type: |
|
| 218 | return None |
|
| 219 | ||
| 220 | if filter_type == 'vuln': |
|
| 221 | return FilterType.VULNERABILITY |
|
| 222 | ||
| 223 | if filter_type == 'os': |
|
| 224 | return FilterType.OPERATING_SYSTEM |
|
| 225 | ||
| 226 | if filter_type == 'config': |
|
| 227 | return FilterType.SCAN_CONFIG |
|
| 228 | ||
| 229 | if filter_type == 'secinfo': |
|
| 230 | return FilterType.ALL_SECINFO |
|
| 231 | ||
| 232 | try: |
|
| 233 | return FilterType[filter_type.upper()] |
|
| 234 | except KeyError: |
|
| 235 | raise InvalidArgument( |
|
| 236 | argument='filter_type', |
|
| 237 | function=get_filter_type_from_string.__name__, |
|
| 238 | ) from None |
|
| 239 | ||
| 240 | ||
| @@ 392-423 (lines=32) @@ | ||
| 389 | VULNERABILITY = "vuln" |
|
| 390 | ||
| 391 | ||
| 392 | def get_filter_type_from_string( |
|
| 393 | filter_type: Optional[str], |
|
| 394 | ) -> Optional[FilterType]: |
|
| 395 | """Convert a filter type string to an actual FilterType instance |
|
| 396 | ||
| 397 | Arguments: |
|
| 398 | filter_type (str): Filter type string to convert to a FilterType |
|
| 399 | """ |
|
| 400 | if not filter_type: |
|
| 401 | return None |
|
| 402 | ||
| 403 | if filter_type == 'vuln': |
|
| 404 | return FilterType.VULNERABILITY |
|
| 405 | ||
| 406 | if filter_type == 'os': |
|
| 407 | return FilterType.OPERATING_SYSTEM |
|
| 408 | ||
| 409 | if filter_type == 'config': |
|
| 410 | return FilterType.SCAN_CONFIG |
|
| 411 | ||
| 412 | if filter_type == 'secinfo': |
|
| 413 | return FilterType.ALL_SECINFO |
|
| 414 | ||
| 415 | if filter_type == 'tls_certificate': |
|
| 416 | return FilterType.TLS_CERTIFICATE |
|
| 417 | ||
| 418 | try: |
|
| 419 | return FilterType[filter_type.upper()] |
|
| 420 | except KeyError: |
|
| 421 | raise InvalidArgument( |
|
| 422 | argument='filter_type', |
|
| 423 | function=get_filter_type_from_string.__name__, |
|
| 424 | ) from None |
|
| 425 | ||
| 426 | ||
| @@ 224-255 (lines=32) @@ | ||
| 221 | VULNERABILITY = "vuln" |
|
| 222 | ||
| 223 | ||
| 224 | def get_filter_type_from_string( |
|
| 225 | filter_type: Optional[str], |
|
| 226 | ) -> Optional[FilterType]: |
|
| 227 | """Convert a filter type string to an actual FilterType instance |
|
| 228 | ||
| 229 | Arguments: |
|
| 230 | filter_type (str): Filter type string to convert to a FilterType |
|
| 231 | """ |
|
| 232 | if not filter_type: |
|
| 233 | return None |
|
| 234 | ||
| 235 | if filter_type == 'vuln': |
|
| 236 | return FilterType.VULNERABILITY |
|
| 237 | ||
| 238 | if filter_type == 'os': |
|
| 239 | return FilterType.OPERATING_SYSTEM |
|
| 240 | ||
| 241 | if filter_type == 'config': |
|
| 242 | return FilterType.SCAN_CONFIG |
|
| 243 | ||
| 244 | if filter_type == 'secinfo': |
|
| 245 | return FilterType.ALL_SECINFO |
|
| 246 | ||
| 247 | if filter_type == 'tls_certificate': |
|
| 248 | return FilterType.TLS_CERTIFICATE |
|
| 249 | ||
| 250 | try: |
|
| 251 | return FilterType[filter_type.upper()] |
|
| 252 | except KeyError: |
|
| 253 | raise InvalidArgument( |
|
| 254 | argument='filter_type', |
|
| 255 | function=get_filter_type_from_string.__name__, |
|
| 256 | ) from None |
|
| 257 | ||
| 258 | ||