gremlin-python icon indicating copy to clipboard operation
gremlin-python copied to clipboard

GremlinNetworkAttackHelper hostname setter broken

Open davebrown-exit107 opened this issue 3 years ago • 1 comments

When using children of GremlinNetworkAttackHelper (GremlinPacketLossAttack, GremlinLatencyAttack, GremlinBlackholeAttack), the hostnames parameter behaves in an unexpected manner when given a list.

In the general case of GremlinNetworkAttackHelper will return a list consisting of only the last element of the input list.

hostnames = [
            'www.gremlin.com',
            '^api.gremlin.com',
            ]
attack = GremlinNetworkAttackHelper(hostnames=hostnames)

expected: ['www.gremlin.com', '^api.gremlin.com'] (<class 'list'>)
actual attack.hostnames: ['^api.gremlin.com'] (<class 'list'>)

In more specific cases of actual attacks (e.g. GremlinPacketLossAttack), the same behavior shows up, except that the output of the api_model() call is a list of elements of the string that was the last element of the input list.

hostnames = [
            'www.gremlin.com',
            '^api.gremlin.com',
            ]
attack = GremlinNetworkAttackHelper(hostnames=hostnames)

expected: {'type': 'packet_loss', 'commandType': 'Packet Loss', 'args': ['-l', '60', '-r', '1', '-p', '^53', '-h', 'www.gremlin.com,^api.gremlin.com']}
actual attack.hostnames: {'type': 'packet_loss', 'commandType': 'Packet Loss', 'args': ['-l', '60', '-r', '1', '-p', '^53', '-h', '^,a,p,i,.,g,r,e,m,l,i,n,.,c,o,m']}

hostnames-list-example.py.txt

davebrown-exit107 avatar Dec 14 '21 05:12 davebrown-exit107

I believe [#73 ] will fix this problem

pagbrl avatar Jun 28 '22 14:06 pagbrl