Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test():
"""Test some basic functionality"""
from resilient_circuits.rest_helper import get_resilient_client
from resilient_circuits.actions_component import ActionMessage
import time
opts = vars(resilient.ArgumentParser(config_file=os.environ.get("APP_CONFIG_FILE")).parse_args())
client = get_resilient_client(opts)
action_event = None
result = Disposition(client, "new_incident").call(action_event, {"name": "new test incident", "discovered_date": 0})
LOG.debug(result)
assert result["id"] > 0
print("Created incident {}".format(result["id"]))
incident = result
action_event = ActionMessage(message={"incident": incident})
result = Disposition(client, "new_task").call(action_event, {"name": "new task"})
LOG.debug(result)
assert result["id"] > 0
action_event.task = result
result = Disposition(client, "update_task").call(action_event, {"name": "updated task"})
LOG.info(result)
else:
unicode = str
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.INFO)
LOG.addHandler(logging.StreamHandler())
RESILIENT_SECTION = "resilient"
MACHINE_LEARNING_SECTION = "machine_learning"
SAMPLE_CSV_FILE = "resilient_incidents.csv"
LOG_FILE = "res-ml.log"
class OptParser(resilient.ArgumentParser):
"""
This is a subclass of resilient.ArgumentParser. resilient.ArgumentParser takes care of both
1. Reading app.config
2. Validating required command line arguments.
Here we just want app.config, we are parsing/validating commandline arguments in our main function.
"""
def __init__(self, config_file=None):
self.config_file = config_file or resilient.get_config_file()
super(OptParser, self).__init__(config_file=self.config_file)
#
# Note this is a trick used by resilient-circuits. resilient.ArgumentParser will
# validate the arguments of the command line. Since we use command line
# argument of input/output files, we don't want that validation, so we
# erase them before we call parse_args(). So parse_args() only
# reads from app.config
#
"""
Simple script to create a new incident.
"""
from __future__ import print_function
import time
import logging
import resilient
import configparser
from fn_risk_fabric.util.risk_fabric import get_risk_model_instances
logging.basicConfig()
class ExampleArgumentParser(resilient.ArgumentParser):
"""Arguments for this command-line application, extending the standard Resilient arguments"""
def __init__(self, config_file=None):
super(ExampleArgumentParser, self).__init__(config_file=config_file)
self.add_argument('--itype', '-t',
action='append',
help="The incident type(s). Multiple arguments may be supplied.")
self.add_argument('--limit', '-l',
required=True,
help="Limit imported risk model instances.")
def main():
"""
"""
Simple script to create a new incident.
"""
from __future__ import print_function
import time
import logging
import resilient
import configparser
from fn_risk_fabric.util.risk_fabric import get_action_plans, set_action_plan_comment
logging.basicConfig()
class ExampleArgumentParser(resilient.ArgumentParser):
"""Arguments for this command-line application, extending the standard Resilient arguments"""
def __init__(self, config_file=None):
super(ExampleArgumentParser, self).__init__(config_file=config_file)
self.add_argument('--itype', '-t',
action='append',
help="The incident type(s). Multiple arguments may be supplied.")
self.add_argument('--queue', '-q',
required=True,
help="The action plan queue.")
def main():
"""