Fix playbooks endpoint to return array format

- Change /tscm/playbooks to return array instead of dict
- Add id, name, category fields to each playbook for JS compatibility
- Fix tscmViewPlaybook JS to use correct field names (action/details/safety_note)
- Display when_to_escalate and documentation_required sections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-16 16:23:09 +00:00
parent 6dbf2fda01
commit 66b2f59ca0
2 changed files with 31 additions and 14 deletions

View File

@@ -3165,12 +3165,18 @@ def list_playbooks():
try:
from utils.tscm.advanced import PLAYBOOKS
# Return as array with id field for JavaScript compatibility
playbooks_list = []
for pid, pb in PLAYBOOKS.items():
pb_dict = pb.to_dict()
pb_dict['id'] = pid
pb_dict['name'] = pb_dict.get('title', pid)
pb_dict['category'] = pb_dict.get('risk_level', 'general')
playbooks_list.append(pb_dict)
return jsonify({
'status': 'success',
'playbooks': {
pid: pb.to_dict()
for pid, pb in PLAYBOOKS.items()
}
'playbooks': playbooks_list
})
except Exception as e: