How to use get_playbook method in molecule

Best Python code snippet using molecule_python

Playbook Caller.py

Source:Playbook Caller.py Github

copy

Full Screen

1"""2"""3import phantom.rules as phantom4import json5from datetime import datetime, timedelta6##############################7# Start - Global Code Block8def comment_and_debug(container, comment):9 phantom.debug(comment)10 phantom.comment(container=container, comment=comment)11# End - Global Code block12##############################13def on_start(container):14 phantom.debug('on_start() called')15 16 # call 'Get_Playbook' block17 Get_Playbook(container=container)18 return19def Get_Playbook(action=None, success=None, container=None, results=None, handle=None, filtered_artifacts=None, filtered_results=None, custom_function=None, **kwargs):20 phantom.debug('Get_Playbook() called')21 22 id_value = container.get('id', None)23 container_data = phantom.collect2(container=container, datapath=['artifact:*.id', 'artifact:*.cef.data', 'artifact:*.id'])24 container_item_0 = [item[0] for item in container_data]25 container_item_1 = [item[1] for item in container_data]26 Get_Playbook__playbook_name = None27 Get_Playbook__object_key = None28 ################################################################################29 ## Custom Code Start30 ################################################################################31 Get_Playbook__playbook_name = "playbooks/Playbook Called"32 ################################################################################33 ## Custom Code End34 ################################################################################35 phantom.save_run_data(key='Get_Playbook:playbook_name', value=json.dumps(Get_Playbook__playbook_name))36 phantom.save_run_data(key='Get_Playbook:object_key', value=json.dumps(Get_Playbook__object_key))37 playbook_playbooks_Playbook_Called_1(container=container)38 return39def playbook_playbooks_Playbook_Called_1(action=None, success=None, container=None, results=None, handle=None, filtered_artifacts=None, filtered_results=None, custom_function=None, **kwargs):40 phantom.debug('playbook_playbooks_Playbook_Called_1() called')41 42 playbook_name = json.loads(phantom.get_run_data(key='Get_Playbook:playbook_name'))43 44 # call playbook "playbooks/Playbook Called", returns the playbook_run_id45 playbook_run_id = phantom.playbook(playbook=playbook_name, container=container, name="playbook_playbooks_Playbook_Called_1")46 return47def on_finish(container, summary):48 phantom.debug('on_finish() called')49 # This function is called after all actions are completed.50 # summary of all the action and/or all details of actions51 # can be collected here.52 # summary_json = phantom.get_summary()53 # if 'result' in summary_json:54 # for action_result in summary_json['result']:55 # if 'action_run_id' in action_result:56 # action_results = phantom.get_action_results(action_run_id=action_result['action_run_id'], result_data=False, flatten=False)57 # phantom.debug(action_results)...

Full Screen

Full Screen

playbook.py

Source:playbook.py Github

copy

Full Screen

...5from disarmsite.auth import login_required6from disarmsite.database import db_session7from disarmsite.models import Playbook8bp = Blueprint('playbook', __name__, url_prefix='/playbook')9def get_playbook(id, check_author=True):10 playbook = Playbook.query.filter(Playbook.id == id).first()11 if playbook is None:12 abort(404, f"Playbook id {id} doesn't exist.")13 return playbook14@bp.route('/')15def index():16 playbooks = Playbook.query.all() #.order_by("disarm_id")17 return render_template('playbook/index.html', playbooks=playbooks)18@bp.route('/create', methods=('GET', 'POST'))19@login_required20def create():21 if request.method == 'POST':22 disarm_id = request.form['disarm_id']23 object_id = request.form['object_id']24 name = request.form['name']25 summary = request.form['summary']26 error = None27 if not name:28 error = 'Name is required.'29 if error is not None:30 flash(error)31 else:32 playbook = Playbook(disarm_id, object_id, name, summary)33 db_session.add(playbook)34 db_session.commit()35 return redirect(url_for('playbook.index'))36 return render_template('playbook/create.html')37@bp.route('/<int:id>/update', methods=('GET', 'POST'))38@login_required39def update(id):40 playbook = get_playbook(id)41 if request.method == 'POST':42 name = request.form['name']43 summary = request.form['summary']44 error = None45 if not name:46 error = 'Name is required.'47 if error is not None:48 flash(error)49 else:50 playbook.name = name51 playbook.summary = summary52 db_session.add(playbook)53 db_session.commit() 54 return redirect(url_for('playbook.index'))55 return render_template('playbook/update.html', playbook=playbook)56@bp.route('/<int:id>/delete', methods=('POST',))57@login_required58def delete(id):59 playbook = get_playbook(id)60 db_session.delete(playbook)61 db_session.commit() ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful