Code Duplication    Length = 41-41 lines in 2 locations

gvm/protocols/gmpv208/types.py 1 location

@@ 624-664 (lines=41) @@
621
    CONSIDER_ALIVE = 'Consider Alive'
622
623
624
def get_alive_test_from_string(
625
    alive_test: Optional[str],
626
) -> Optional[AliveTest]:
627
    """Convert an alive test string into a AliveTest instance"""
628
    if not alive_test:
629
        return None
630
631
    alive_test = alive_test.lower()
632
633
    if alive_test == 'scan config default':
634
        return AliveTest.SCAN_CONFIG_DEFAULT
635
636
    if alive_test == 'icmp ping':
637
        return AliveTest.ICMP_PING
638
639
    if alive_test == 'tcp-ack service ping':
640
        return AliveTest.TCP_ACK_SERVICE_PING
641
642
    if alive_test == 'tcp-syn service ping':
643
        return AliveTest.TCP_SYN_SERVICE_PING
644
645
    if alive_test == 'arp ping':
646
        return AliveTest.ARP_PING
647
648
    if alive_test == 'icmp & tcp-ack service ping':
649
        return AliveTest.ICMP_AND_TCP_ACK_SERVICE_PING
650
651
    if alive_test == 'icmp & arp ping':
652
        return AliveTest.ICMP_AND_ARP_PING
653
654
    if alive_test == 'tcp-ack service & arp ping':
655
        return AliveTest.TCP_ACK_SERVICE_AND_ARP_PING
656
657
    if alive_test == 'icmp, tcp-ack service & arp ping':
658
        return AliveTest.ICMP_TCP_ACK_SERVICE_AND_ARP_PING
659
660
    if alive_test == 'consider alive':
661
        return AliveTest.CONSIDER_ALIVE
662
663
    raise InvalidArgument(
664
        argument='alive_test', function=get_alive_test_from_string.__name__
665
    )
666
667

gvm/protocols/gmpv7/types.py 1 location

@@ 201-241 (lines=41) @@
198
    CONSIDER_ALIVE = 'Consider Alive'
199
200
201
def get_alive_test_from_string(
202
    alive_test: Optional[str],
203
) -> Optional[AliveTest]:
204
    """Convert an alive test string into a AliveTest instance"""
205
    if not alive_test:
206
        return None
207
208
    alive_test = alive_test.lower()
209
210
    if alive_test == 'scan config default':
211
        return AliveTest.SCAN_CONFIG_DEFAULT
212
213
    if alive_test == 'icmp ping':
214
        return AliveTest.ICMP_PING
215
216
    if alive_test == 'tcp-ack service ping':
217
        return AliveTest.TCP_ACK_SERVICE_PING
218
219
    if alive_test == 'tcp-syn service ping':
220
        return AliveTest.TCP_SYN_SERVICE_PING
221
222
    if alive_test == 'arp ping':
223
        return AliveTest.ARP_PING
224
225
    if alive_test == 'icmp & tcp-ack service ping':
226
        return AliveTest.ICMP_AND_TCP_ACK_SERVICE_PING
227
228
    if alive_test == 'icmp & arp ping':
229
        return AliveTest.ICMP_AND_ARP_PING
230
231
    if alive_test == 'tcp-ack service & arp ping':
232
        return AliveTest.TCP_ACK_SERVICE_AND_ARP_PING
233
234
    if alive_test == 'icmp, tcp-ack service & arp ping':
235
        return AliveTest.ICMP_TCP_ACK_SERVICE_AND_ARP_PING
236
237
    if alive_test == 'consider alive':
238
        return AliveTest.CONSIDER_ALIVE
239
240
    raise InvalidArgument(
241
        argument='alive_test', function=get_alive_test_from_string.__name__
242
    )
243
244