-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiply.py
42 lines (32 loc) · 1.06 KB
/
multiply.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import argparse
import copy
import json
import uuid
class Multiplier:
def __init__(self, multi=5, list_key='servers', id_key='id', faker=uuid.uuid4):
self.list_key = list_key
self.multi = multi
self.id_key = id_key
self.faker = faker
def response(self, flow):
data = json.loads(flow.response.text)
sample_list = data[self.list_key]
craft = self.learn(sample_list)
for i in range(len(sample_list) * self.multi):
sample_list.append(craft())
flow.response.text=json.dumps(data)
def learn(self, sample_list):
"""TODO: machine learning from actual sample"""
sample = sample_list[0]
faker = self.faker
def _craft():
"""craft a faked artifact"""
faked = copy.deepcopy(sample)
faked[self.id_key] = str(faker())
return faked
return _craft
def start():
parser = argparse.ArgumentParser()
parser.add_argument("mul", type=int)
args = parser.parse_args()
return Multiplier(multi=args.mul)