From d99a6370a0db4eb0da11693102f0103ee9533172 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Wed, 14 Jan 2026 09:46:32 +0000 Subject: [PATCH] Add JSON escaping for multi-line content strings --- scenarios/m03_ghost_in_the_machine/scenario.json.erb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scenarios/m03_ghost_in_the_machine/scenario.json.erb b/scenarios/m03_ghost_in_the_machine/scenario.json.erb index 4f0ecfd..0332a91 100644 --- a/scenarios/m03_ghost_in_the_machine/scenario.json.erb +++ b/scenarios/m03_ghost_in_the_machine/scenario.json.erb @@ -1,6 +1,7 @@ <% # ERB Helper Methods for Mission 3: Ghost in the Machine require 'base64' +require 'json' # Encoding helper functions def rot13(text) @@ -15,6 +16,10 @@ def hex_encode(text) text.unpack('H*').first end +def json_escape(text) + text.to_json[1..-2] # Remove surrounding quotes from .to_json output +end + # Narrative content variables whiteboard_message_encoded = rot13("MEET WITH THE ARCHITECT - PRIORITIZE INFRASTRUCTURE EXPLOITS") @@ -410,7 +415,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr "id": "lore_fragment_2_doc", "name": "Q3 2024 Exploit Catalog", "type": "lore_document", - "content": "<%= lore_fragment_2 %>", + "content": "<%= json_escape(lore_fragment_2) %>", "completes_task": "lore_fragment_2" } ] @@ -488,7 +493,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr "name": "Operational Logs", "type": "document", "position": {"x": 4, "y": 4}, - "content": "<%= operational_log_content %>", + "content": "<%= json_escape(operational_log_content) %>", "completes_task": "find_operational_logs" } }, @@ -549,7 +554,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr "id": "lore_fragment_1_doc", "name": "Zero Day: A Brief History", "type": "lore_document", - "content": "<%= lore_fragment_1 %>", + "content": "<%= json_escape(lore_fragment_1) %>", "completes_task": "lore_fragment_1" } ]