Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_class(self):
self.patch_get = patch('passivetotal.api.Client._get', fake_request)
self.patch_set = patch('passivetotal.api.Client._send_data', fake_request)
self.patch_get.start()
self.patch_set.start()
self.client = ActionsClient('--No-User--', '--No-Key--')
def get_action(self, **kwargs):
client = ActionsClient(self.username, self.apikey)
keys = ['query', 'tags', 'classification', 'monitor', 'sinkhole',
'dynamic_dns', 'ever_compromised', 'metadata']
params = self._cleanup_params(keys, **kwargs)
res = None
if params.get('tags'):
params['tags'] = [tag.strip() for tag in params['tags'].split(',')]
if kwargs.get('add_tags'):
res = client.add_tags(**params)
elif kwargs.get('remove_tags'):
res = client.remove_tags(**params)
elif kwargs.get('set_tags'):
def call_actions(args):
"""Abstract call to actions-based queries."""
client = ActionsClient.from_config()
pruned = prune_args(
query=args.query,
tags=args.tags,
classification=args.classification,
monitor=args.monitor,
sinkhole=args.sinkhole,
dynamic_dns=args.dynamic_dns,
ever_compromised=args.ever_compromised,
metadata=args.metadata
)
if args.tags:
tag_values = [x.strip() for x in args.tags.split(',')]
pruned['tags'] = tag_values
if args.add_tags:
data = client.add_tags(**pruned)
def __init__(self, *args, **kwargs):
"""Setup the primary client instance."""
super(ActionsClient, self).__init__(*args, **kwargs)