@@ 206-237 (lines=32) @@ | ||
203 | VULNERABILITY = "vuln" |
|
204 | ||
205 | ||
206 | def get_filter_type_from_string( |
|
207 | filter_type: Optional[str], |
|
208 | ) -> Optional[FilterType]: |
|
209 | """ Convert a filter type string to an actual FilterType instance |
|
210 | ||
211 | Arguments: |
|
212 | filter_type (str): Filter type string to convert to a FilterType |
|
213 | """ |
|
214 | if not filter_type: |
|
215 | return None |
|
216 | ||
217 | if filter_type == 'vuln': |
|
218 | return FilterType.VULNERABILITY |
|
219 | ||
220 | if filter_type == 'os': |
|
221 | return FilterType.OPERATING_SYSTEM |
|
222 | ||
223 | if filter_type == 'config': |
|
224 | return FilterType.SCAN_CONFIG |
|
225 | ||
226 | if filter_type == 'secinfo': |
|
227 | return FilterType.ALL_SECINFO |
|
228 | ||
229 | if filter_type == 'tls_certificate': |
|
230 | return FilterType.TLS_CERTIFICATE |
|
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 | ) |
|
239 | ||
240 |
@@ 201-229 (lines=29) @@ | ||
198 | VULNERABILITY = "vuln" |
|
199 | ||
200 | ||
201 | def get_filter_type_from_string( |
|
202 | filter_type: Optional[str], |
|
203 | ) -> Optional[FilterType]: |
|
204 | """ Convert a filter type string to an actual FilterType instance |
|
205 | ||
206 | Arguments: |
|
207 | filter_type (str): Filter type string to convert to a FilterType |
|
208 | """ |
|
209 | if not filter_type: |
|
210 | return None |
|
211 | ||
212 | if filter_type == 'vuln': |
|
213 | return FilterType.VULNERABILITY |
|
214 | ||
215 | if filter_type == 'os': |
|
216 | return FilterType.OPERATING_SYSTEM |
|
217 | ||
218 | if filter_type == 'config': |
|
219 | return FilterType.SCAN_CONFIG |
|
220 | ||
221 | if filter_type == 'secinfo': |
|
222 | return FilterType.ALL_SECINFO |
|
223 | ||
224 | try: |
|
225 | return FilterType[filter_type.upper()] |
|
226 | except KeyError: |
|
227 | raise InvalidArgument( |
|
228 | argument='filter_type', |
|
229 | function=get_filter_type_from_string.__name__, |
|
230 | ) |
|
231 | ||
232 |
@@ 341-372 (lines=32) @@ | ||
338 | VULNERABILITY = "vuln" |
|
339 | ||
340 | ||
341 | def get_filter_type_from_string( |
|
342 | filter_type: Optional[str], |
|
343 | ) -> Optional[FilterType]: |
|
344 | """ Convert a filter type string to an actual FilterType instance |
|
345 | ||
346 | Arguments: |
|
347 | filter_type (str): Filter type string to convert to a FilterType |
|
348 | """ |
|
349 | if not filter_type: |
|
350 | return None |
|
351 | ||
352 | if filter_type == 'vuln': |
|
353 | return FilterType.VULNERABILITY |
|
354 | ||
355 | if filter_type == 'os': |
|
356 | return FilterType.OPERATING_SYSTEM |
|
357 | ||
358 | if filter_type == 'config': |
|
359 | return FilterType.SCAN_CONFIG |
|
360 | ||
361 | if filter_type == 'secinfo': |
|
362 | return FilterType.ALL_SECINFO |
|
363 | ||
364 | if filter_type == 'tls_certificate': |
|
365 | return FilterType.TLS_CERTIFICATE |
|
366 | ||
367 | try: |
|
368 | return FilterType[filter_type.upper()] |
|
369 | except KeyError: |
|
370 | raise InvalidArgument( |
|
371 | argument='filter_type', |
|
372 | function=get_filter_type_from_string.__name__, |
|
373 | ) |
|
374 | ||
375 |