帮助开发者读取、编写并调试 Pysa 的 JSON 污点模型与 .models 输出
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "pysa-json-models" 技能: 1. 下载 https://raw.githubusercontent.com/facebook/pyre-check/main/.llms/skills/pysa-json-models/SKILL.md 2. 保存为 ~/.claude/skills/pysa-json-models/SKILL.md 3. 装好后重载技能,告诉我可以用了
请解释这段 Pysa JSON model 的结构与字段含义,重点说明 sources、sinks、tito、sanitizers 和 issues 各自表示什么,并指出可能的格式错误:
{...粘贴 JSON 内容...}一份对 JSON 字段的逐项说明,以及潜在语法或建模问题的诊断建议。
根据这个 Python 函数签名和行为,为 Pysa 生成 JSON taint model:参数 user_input 是 source,参数 query 会流向 sink,返回值保留 TITO;请输出合法的 .models JSON 片段并附简要说明。 函数签名:def run_query(user_input: str, query: str) -> str
一个可用于 .models 文件的合法 JSON 模型片段,并说明 source、sink 与 TITO 的映射关系。
我在 Pysa 的 .models 输出里看到了这条 issue,但不确定为什么会触发。请结合模型内容分析污点传播路径、可能的误报原因,并给出修改模型或代码的建议:
{...粘贴 issue JSON 与相关 model JSON...}对 issue 触发原因的解释、传播路径分析,以及减少误报或修复问题的具体建议。
Pysa outputs analysis results as newline-delimited JSON (NDJSON). Each line is a self-contained JSON object with "kind" and "data" fields. There are two kinds: "model" (a callable's taint behavior) and "issue" (a detected vulnerability).
Every JSON object is wrapped as:
{"kind": "model", "data": { ... }}
{"kind": "issue", "data": { ... }}
Models and issues are separate top-level objects. Issues are never nested inside models.
{
"callable": "module.function_name",
"filename": "module.py",
"callable_line": 42,
"sources": [ ... ],
"sinks": [ ... ],
"tito": [ ... ],
"parameter_sources": [ ... ],
"global_sanitizer": { ... },
"parameters_sanitizer": { ... },
"sanitizers": [ ... ],
"modes": [ "Obscure", ... ]
}
All fields except callable are optional. Empty fields are omitted entirely — never include empty arrays [] or objects {}.
Note: "sources" represents (taint produced by the function). This is distinct from which represents sources on parameters.
"parameter_sources""module.function_name""module.ClassName.method_name""Obj{module.ClassName.attribute_name}"Available modes: Obscure, SkipObscure, SkipAnalysis, SkipOverrides, AnalyzeAllOverrides, Entrypoint, IgnoreDecorator, SkipModelBroadening, InferSelfTito, InferArgumentTito.
Each of sources, sinks, tito, and parameter_sources is a list of port entries:
{
"port": "<port>",
"taint": [ <trace_element>, ... ]
}
| Port | Meaning |
|---|---|
result | Return value |
result[field] | Return value with access path |
formal(name, position=N) | Named parameter at position N |
formal(name, position=N, positional_only) | Positional-only parameter |
formal(name, position=N)[field][subfield] | Parameter with access path |
formal(*args, position=N) | Variadic positional args |
formal(**kwargs) | Variadic keyword args |
formal(**kwargs, excluded=[x]) | Kwargs excluding named params |
formal($global, position=0) | Global/attribute model port |
Key rule: position is always included in formal() ports (e.g., formal(x, position=0), not formal(x)).
For sources/parameter_sources, the port indicates where taint is produced (typically result or result[field]).
For sinks, the port indicates where taint is consumed (typically formal(...) with optional access path).
For tito, the port indicates the input side (always formal(...)). The output side is encoded inside the taint entry via return_paths.
Each element in a "taint" list is a trace element keyed by its call info. There are four call info variants:
{
"kinds": [ { "kind": "Test" } ],
"declaration": null
}
This is the leaf of the trace — the taint is directly declared by the user, not propagated from another function.
{
"kinds": [ { "kind": "Test", "length": 0 } ],
"origin": { "line": 16, "start": 15, "end": 20 }
}
Represents a call to a function with a user-declared model. The origin location is where the call happens. "call_site" may also be present (e.g., "call_site": "16:4-16:21").
{
"kinds": [ { "kind": "Test", "length": 2 } ],
"call": {
"position": { "line": 20, "start": 8, "end": 22 },
"resolves_to": [ "module.callee_function" ],
"port": "result[a]"
}
}
…
帮助你快速理解 Pyre/Pysa 代码架构并定位关键实现位置
让大模型安全执行 pandas 数据分析并生成交互式可视化结果。