@@ 189-217 (lines=29) @@ | ||
186 | VULNERABILITY = "vuln" |
|
187 | ||
188 | ||
189 | def get_entity_type_from_string( |
|
190 | entity_type: Optional[str], |
|
191 | ) -> Optional[EntityType]: |
|
192 | """Convert a entity type string to an actual EntityType instance |
|
193 | ||
194 | Arguments: |
|
195 | entity_type: Entity type string to convert to a EntityType |
|
196 | """ |
|
197 | if not entity_type: |
|
198 | return None |
|
199 | ||
200 | if entity_type == 'vuln': |
|
201 | return EntityType.VULNERABILITY |
|
202 | ||
203 | if entity_type == 'os': |
|
204 | return EntityType.OPERATING_SYSTEM |
|
205 | ||
206 | if entity_type == 'config': |
|
207 | return EntityType.SCAN_CONFIG |
|
208 | ||
209 | if entity_type == 'tls_certificate': |
|
210 | return EntityType.TLS_CERTIFICATE |
|
211 | ||
212 | try: |
|
213 | return EntityType[entity_type.upper()] |
|
214 | except KeyError: |
|
215 | raise InvalidArgument( |
|
216 | argument='entity_type', |
|
217 | function=get_entity_type_from_string.__name__, |
|
218 | ) from None |
|
219 | ||
220 |
@@ 118-146 (lines=29) @@ | ||
115 | VULNERABILITY = "vuln" |
|
116 | ||
117 | ||
118 | def get_entity_type_from_string( |
|
119 | entity_type: Optional[str], |
|
120 | ) -> Optional[EntityType]: |
|
121 | """Convert a entity type string to an actual EntityType instance |
|
122 | ||
123 | Arguments: |
|
124 | entity_type: Entity type string to convert to a EntityType |
|
125 | """ |
|
126 | if not entity_type: |
|
127 | return None |
|
128 | ||
129 | if entity_type == 'vuln': |
|
130 | return EntityType.VULNERABILITY |
|
131 | ||
132 | if entity_type == 'os': |
|
133 | return EntityType.OPERATING_SYSTEM |
|
134 | ||
135 | if entity_type == 'config': |
|
136 | return EntityType.SCAN_CONFIG |
|
137 | ||
138 | if entity_type == 'tls_certificate': |
|
139 | return EntityType.TLS_CERTIFICATE |
|
140 | ||
141 | try: |
|
142 | return EntityType[entity_type.upper()] |
|
143 | except KeyError: |
|
144 | raise InvalidArgument( |
|
145 | argument='entity_type', |
|
146 | function=get_entity_type_from_string.__name__, |
|
147 | ) from None |
|
148 | ||
149 |