[{"data":1,"prerenderedAt":453},["ShallowReactive",2],{"doc:\u002Fguides\u002Fsecurity":3,"nav:guides":405},{"doc":4,"source":404},{"id":5,"title":6,"body":7,"description":17,"extension":397,"meta":398,"navigation":399,"path":400,"seo":401,"stem":402,"__hash__":403},"guides\u002Fguides\u002Fsecurity.md","Security",{"type":8,"value":9,"toc":391},"minimark",[10,14,18,23,108,118,142,165,169,296,307,324,328,344,348,377,387],[11,12,6],"h1",{"id":13},"security",[15,16,17],"p",{},"Pkl modules can import other modules and read resources: files, environment variables, system properties, HTTP URLs, and packages. Every evaluator carries allow lists that decide which of those it may touch. Choose them for the least trusted module the evaluator will see.",[19,20,22],"h2",{"id":21},"restricted-and-preconfigured-settings","Restricted and preconfigured settings",[24,25,26,46],"table",{},[27,28,29],"thead",{},[30,31,32,35,41],"tr",{},[33,34],"th",{},[33,36,37],{},[38,39,40],"code",{},"Options.restricted()",[33,42,43],{},[38,44,45],{},"Options.preconfigured()",[47,48,49,82],"tbody",{},[30,50,51,55,64],{},[52,53,54],"td",{},"Modules",[52,56,57,60,61],{},[38,58,59],{},"pkl:",", ",[38,62,63],{},"repl:",[52,65,66,60,68,60,70,60,73,60,76,60,79],{},[38,67,59],{},[38,69,63],{},[38,71,72],{},"file:",[38,74,75],{},"modulepath:",[38,77,78],{},"package:",[38,80,81],{},"projectpackage:",[30,83,84,87,90],{},[52,85,86],{},"Resources",[52,88,89],{},"none",[52,91,92,60,94,60,96,60,98,60,100,60,102,60,105],{},[38,93,59],{},[38,95,72],{},[38,97,75],{},[38,99,78],{},[38,101,81],{},[38,103,104],{},"env:",[38,106,107],{},"prop:",[15,109,110,113,114,117],{},[38,111,112],{},"restricted()"," is the right default for configuration you did not write. ",[38,115,116],{},"preconfigured()"," adds local files, module paths, and packages but no HTTP, and suits trusted files on disk.",[15,119,120,121,123,124,126,127,123,130,133,134,137,138,141],{},"Neither passes the program's environment variables or system properties to Pkl. ",[38,122,104],{}," and ",[38,125,107],{}," reads see only what you put in ",[38,128,129],{},"Options.env",[38,131,132],{},"Options.properties",", so ",[38,135,136],{},"read(\"env:HOME\")"," finds nothing unless you add ",[38,139,140],{},"HOME"," yourself.",[15,143,144,145,148,149,152,153,156,157,160,161,164],{},"An evaluator needs at least one module pattern, because even inline text is the module ",[38,146,147],{},"repl:text",". ",[38,150,151],{},"createEvaluator"," returns ",[38,154,155],{},"error.NoAllowedModules"," when ",[38,158,159],{},"allowed_modules"," is null or empty; Pkl 0.30 and newer would exit instead of rejecting the request. A null ",[38,162,163],{},"allowed_resources"," denies every resource.",[19,166,168],{"id":167},"granting-exactly-what-a-module-needs","Granting exactly what a module needs",[170,171,176],"pre",{"className":172,"code":173,"language":174,"meta":175,"style":175},"language-zig shiki shiki-themes github-light github-dark","var options = zig_pkl.Options.restricted();\noptions.allowed_resources = &.{\"env:\"};\noptions.env = &.{.{ .key = \"REGION\", .value = \"eu-west-1\" }};\noptions.timeout_seconds = 5;\n","zig","",[38,177,178,213,238,277],{"__ignoreMap":175},[179,180,183,187,191,194,197,201,204,206,210],"span",{"class":181,"line":182},"line",1,[179,184,186],{"class":185},"szBVR","var",[179,188,190],{"class":189},"s4XuR"," options",[179,192,193],{"class":185}," =",[179,195,196],{"class":189}," zig_pkl",[179,198,200],{"class":199},"sVt8B",".",[179,202,203],{"class":189},"Options",[179,205,200],{"class":199},[179,207,209],{"class":208},"sScJk","restricted",[179,211,212],{"class":199},"();\n",[179,214,216,219,221,223,225,228,231,235],{"class":181,"line":215},2,[179,217,218],{"class":189},"options",[179,220,200],{"class":199},[179,222,163],{"class":189},[179,224,193],{"class":185},[179,226,227],{"class":185}," &",[179,229,230],{"class":199},".{",[179,232,234],{"class":233},"sZZnC","\"env:\"",[179,236,237],{"class":199},"};\n",[179,239,241,243,245,248,250,252,255,258,260,263,266,269,271,274],{"class":181,"line":240},3,[179,242,218],{"class":189},[179,244,200],{"class":199},[179,246,247],{"class":189},"env",[179,249,193],{"class":185},[179,251,227],{"class":185},[179,253,254],{"class":199},".{.{ .",[179,256,257],{"class":189},"key",[179,259,193],{"class":185},[179,261,262],{"class":233}," \"REGION\"",[179,264,265],{"class":199},", .",[179,267,268],{"class":189},"value",[179,270,193],{"class":185},[179,272,273],{"class":233}," \"eu-west-1\"",[179,275,276],{"class":199}," }};\n",[179,278,280,282,284,287,289,293],{"class":181,"line":279},4,[179,281,218],{"class":189},[179,283,200],{"class":199},[179,285,286],{"class":189},"timeout_seconds",[179,288,193],{"class":185},[179,290,292],{"class":291},"sj4cs"," 5",[179,294,295],{"class":199},";\n",[15,297,298,299,302,303,306],{},"This evaluator can read ",[38,300,301],{},"env:REGION"," and no other variable. Allow list entries are regular expressions matched against the start of the URI, so ",[38,304,305],{},"\"https:\u002F\u002Fconfig\\\\.example\\\\.com\u002F\""," allows one host.",[15,308,309,312,313,315,316,318,319,200],{},[38,310,311],{},"root_dir"," confines ",[38,314,72],{}," modules and resources to one directory tree. ",[38,317,286],{}," makes Pkl stop an evaluation that runs too long; it is enforced by the server. For a client-side deadline, see ",[320,321,323],"a",{"href":322},"errors","Errors",[19,325,327],{"id":326},"readers-add-schemes","Readers add schemes",[15,329,330,123,333,336,337,339,340,200],{},[38,331,332],{},"Builder.moduleReaders",[38,334,335],{},"Builder.resourceReaders"," add each reader's scheme to the matching allow list, so a reader cannot be registered and then silently blocked. When you assign readers to ",[38,338,203],{}," directly, add the schemes yourself. See ",[320,341,343],{"href":342},"readers","Readers",[19,345,347],{"id":346},"what-the-client-checks","What the client checks",[349,350,351,363,370],"ul",{},[352,353,354,355,358,359,362],"li",{},"Responses are decoded with size and depth limits (",[38,356,357],{},"value.Limits","), and malformed frames fail the connection with ",[38,360,361],{},"error.Protocol"," instead of being guessed at.",[352,364,365,366,369],{},"The server runs as a child process with its own process group on POSIX. ",[38,367,368],{},"Manager.deinit"," closes its input, waits, then terminates the group; see the README limitations for Windows.",[352,371,372,373,200],{},"Code generation evaluates defaults with resource reads denied and omits defaults that depend on the generating machine. See ",[320,374,376],{"href":375},"..\u002Fcodegen#sandbox","Code generation",[15,378,379,380,386],{},"See ",[320,381,383],{"href":382},"..\u002F..\u002Fexamples\u002Frestricted\u002Fmain.zig",[38,384,385],{},"examples\u002Frestricted"," for the messages Pkl returns when a module reaches outside its allow lists.",[388,389,390],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":175,"searchDepth":215,"depth":215,"links":392},[393,394,395,396],{"id":21,"depth":215,"text":22},{"id":167,"depth":215,"text":168},{"id":326,"depth":215,"text":327},{"id":346,"depth":215,"text":347},"md",{},true,"\u002Fguides\u002Fsecurity",{"title":6,"description":17},"guides\u002Fsecurity","fa9KzeVvM1YsArxkp4boLyyLUXRKI3YY92yA21U_z_M","docs\u002Fguides\u002Fsecurity.md",[406,410,414,417,421,425,429,433,437,441,445,449,452],{"title":407,"path":408,"stem":409},"Version compatibility","\u002Fguides\u002Fcompatibility","guides\u002Fcompatibility",{"title":411,"path":412,"stem":413},"Concurrency","\u002Fguides\u002Fconcurrency","guides\u002Fconcurrency",{"title":323,"path":415,"stem":416},"\u002Fguides\u002Ferrors","guides\u002Ferrors",{"title":418,"path":419,"stem":420},"Evaluation","\u002Fguides\u002Fevaluation","guides\u002Fevaluation",{"title":422,"path":423,"stem":424},"External readers","\u002Fguides\u002Fexternal-readers","guides\u002Fexternal-readers",{"title":426,"path":427,"stem":428},"Installation","\u002Fguides\u002Finstallation","guides\u002Finstallation",{"title":430,"path":431,"stem":432},"Logging","\u002Fguides\u002Flogging","guides\u002Flogging",{"title":434,"path":435,"stem":436},"Migrating from pkl-zig","\u002Fguides\u002Fmigration","guides\u002Fmigration",{"title":438,"path":439,"stem":440},"Ownership","\u002Fguides\u002Fownership","guides\u002Fownership",{"title":442,"path":443,"stem":444},"Projects","\u002Fguides\u002Fprojects","guides\u002Fprojects",{"title":446,"path":447,"stem":448},"Quick start","\u002Fguides\u002Fquickstart","guides\u002Fquickstart",{"title":343,"path":450,"stem":451},"\u002Fguides\u002Freaders","guides\u002Freaders",{"title":6,"path":400,"stem":402},1792908673090]