{"record":{"id":"50c14061693b816d","repo":"shadow1ng/fscan","slug":"s-s-w-webscan-exec-env-error-poc-name","errorCode":null,"errorMessage":"%s %s: %w (webscan_exec_env_error, poc name)","messagePattern":"(.+?) (.+?): %w \\(webscan_exec_env_error, poc name\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webscan/lib/poc_executor.go","lineNumber":147,"sourceCode":"\t\tvalue := \"\"\n\t\tif len(item.Value) > 0 {\n\t\t\tvalue = item.Value[0]\n\t\t}\n\t\tdecls = append(decls, MakeVarDecl(item.Key, value))\n\t}\n\n\treturn decls\n}\n\n// executePoc 执行单个POC检测\nfunc executePoc(oReq *http.Request, p *Poc, pocCtx *POCContext) (bool, string, error) {\n\t// 收集POC变量声明\n\tvarDecls := collectVarDeclarations(p)\n\n\t// 从基础环境扩展（复用缓存的基础环境，仅添加变量声明）\n\tenv, err := ExtendEnvWithVars(varDecls)\n\tif err != nil {\n\t\treturn false, \"\", fmt.Errorf(\"%s %s: %w\", i18n.GetText(\"webscan_exec_env_error\"), p.Name, err)\n\t}\n\n\t// 解析请求\n\treq, err := ParseRequest(oReq)\n\tif err != nil {\n\t\treturn false, \"\", fmt.Errorf(\"%s %s: %w\", i18n.GetText(\"webscan_request_parse_error\"), p.Name, err)\n\t}\n\n\t// 初始化变量映射\n\tvariableMap := make(map[string]interface{})\n\tdefer func() { variableMap = nil }()\n\tvariableMap[\"request\"] = req\n\n\t// 处理设置项\n\tfor _, item := range p.Set {\n\t\tkey, expression := item.Key, item.Value\n\t\tif expression == \"newReverse()\" {\n\t\t\tif !pocCtx.DNSLog {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/webscan/lib/poc_executor.go#L129-L165","documentation":"executePoc builds the CEL expression environment for a POC by extending the cached base environment with the POC's variable declarations (ExtendEnvWithVars). If environment construction fails, it wraps the failure as 'webscan_exec_env_error <pocName>: <cause>'. The poc name is embedded so you know which POC's expression environment could not be built.","triggerScenarios":"Calling executePoc (via the executor's anonymous caller) with a POC whose collectVarDeclarations output causes ExtendEnvWithVars to fail — typically a variable declaration that cannot be added to the CEL environment (duplicate name, invalid identifier, or unsupported declaration type).","commonSituations":"A POC declaring variables with names that collide with built-in environment variables; malformed or exotic variable declarations in the POC expression; a corrupted or incompatible cached base environment after library/state changes; POC ported from another engine with unsupported syntax.","solutions":["Look at the wrapped cause after the poc name to see which variable declaration failed","Rename variables in the POC expression to avoid collisions with built-in env vars (e.g. 'request', 'response')","Fix or remove the offending variable declaration in the POC","Rebuild/reset the cached base environment if it was created by an older library version"],"exampleFix":"// before: POC var collides with built-in\nvars:\n  request: \"1\"\n// after\nvars:\n  reqVersion: \"1\"","handlingStrategy":"try-catch","validationCode":"names := map[string]bool{}\nfor _, d := range poc.VarDeclarations {\n    if reserved[d.Name] { return fmt.Errorf(\"var %q collides with built-in env var\", d.Name) }\n    names[d.Name] = true\n}","typeGuard":"func hasSafeVars(p *lib.Poc) bool {\n    reserved := map[string]bool{\"request\": true, \"response\": true}\n    for _, d := range p.VarDeclarations {\n        if reserved[d.Name] { return false }\n    }\n    return true\n}","tryCatchPattern":"matched, detail, err := executor.Execute(target, poc)\nif err != nil {\n    if strings.Contains(err.Error(), \"webscan_exec_env_error\") {\n        log.Warnf(\"POC env build failed, skipping: %v\", err)\n        return false, \"\", nil\n    }\n    return false, \"\", err\n}","preventionTips":["Avoid variable names in POC expressions that clash with built-ins (request, response, etc.)","Test POC expressions individually before batch execution","Rebuild the base environment cache after library upgrades","Lint POC variable declarations for uniqueness and valid identifiers"],"tags":["cel","environment","poc-execution"],"backgroundTag":"invalid-argument-value","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}