| @@ 136-161 (lines=26) @@ | ||
| 133 | VULNERABILITY = "vuln" |
|
| 134 | ||
| 135 | ||
| 136 | def get_entity_type_from_string( |
|
| 137 | entity_type: Optional[str] |
|
| 138 | ) -> Optional[EntityType]: |
|
| 139 | """ Convert a entity type string to an actual EntityType instance |
|
| 140 | ||
| 141 | Arguments: |
|
| 142 | entity_type: Entity type string to convert to a EntityType |
|
| 143 | """ |
|
| 144 | if not entity_type: |
|
| 145 | return None |
|
| 146 | ||
| 147 | if entity_type == 'vuln': |
|
| 148 | return EntityType.VULNERABILITY |
|
| 149 | ||
| 150 | if entity_type == 'os': |
|
| 151 | return EntityType.OPERATING_SYSTEM |
|
| 152 | ||
| 153 | if entity_type == 'config': |
|
| 154 | return EntityType.SCAN_CONFIG |
|
| 155 | ||
| 156 | try: |
|
| 157 | return EntityType[entity_type.upper()] |
|
| 158 | except KeyError: |
|
| 159 | raise InvalidArgument( |
|
| 160 | argument='entity_type', |
|
| 161 | function=get_entity_type_from_string.__name__, |
|
| 162 | ) |
|
| 163 | ||
| 164 | ||
| @@ 326-347 (lines=22) @@ | ||
| 323 | USER = "user" |
|
| 324 | ||
| 325 | ||
| 326 | def get_entity_type_from_string( |
|
| 327 | entity_type: Optional[str] |
|
| 328 | ) -> Optional[EntityType]: |
|
| 329 | """ Convert a entity type string to an actual EntityType instance |
|
| 330 | ||
| 331 | Arguments: |
|
| 332 | entity_type: Resource type string to convert to a EntityType |
|
| 333 | """ |
|
| 334 | if not entity_type: |
|
| 335 | return None |
|
| 336 | ||
| 337 | if entity_type == 'config': |
|
| 338 | return EntityType.SCAN_CONFIG |
|
| 339 | if entity_type == 'os': |
|
| 340 | return EntityType.OPERATING_SYSTEM |
|
| 341 | ||
| 342 | try: |
|
| 343 | return EntityType[entity_type.upper()] |
|
| 344 | except KeyError: |
|
| 345 | raise InvalidArgument( |
|
| 346 | argument='entity_type', |
|
| 347 | function=get_entity_type_from_string.__name__, |
|
| 348 | ) |
|
| 349 | ||
| 350 | ||