{
  "id": "08",
  "content": [
    {
      "type": "heading",
      "text": "Security: Taint Mode, Validation & Sanitization"
    },
    {
      "type": "text",
      "html": "Run scripts with taint mode (<code>-T</code>) to force validation of external data. Always validate inputs before using them in file paths, system calls, or SQL."
    },
    {
      "type": "text",
      "html": "<pre><code>#!/usr/bin/env perl -T\nuse strict; use warnings; use CGI qw(:standard);\nmy $name = param('name') // '';\n$name =~ /^([A-Za-z\\s]{1,40})$/ or die \"Bad name\";\nmy $safe = $1; # untainted\n</code></pre>"
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "What does Perl taint mode do?",
        "options": [
          {
            "id": "a",
            "text": "Requires you to validate external data before using it in sensitive operations"
          },
          {
            "id": "b",
            "text": "Speeds up scripts"
          },
          {
            "id": "c",
            "text": "Adds colors to output"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Which is safer when dealing with user input?",
        "options": [
          {
            "id": "a",
            "text": "Validate and sanitize input"
          },
          {
            "id": "b",
            "text": "Trust all input"
          },
          {
            "id": "c",
            "text": "Assume admin users are safe"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}