Pyre Pysa LLM вызовы в качестве источника и раковиныPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Pyre Pysa LLM вызовы в качестве источника и раковины

Сообщение Anonymous »

Я пытаюсь определить вызовы LLM, поскольку как раковины, так и источники внутри PysA (от Pyre). Мне удалось определить другие раковины и источники (например, вход , os.system и т. Д.), Но не могу выяснить это. Я тестирую на следующую программу. В идеале я не хочу вносить какие -либо изменения в анализируемых репо и рассматривать их как «читать только»: < /p>

Код: Выделить всё

import random
import openai

client = openai.Client()

def func1(x):
func2(x)

def func2(x):
client.responses.create(
model="gpt-4.1",
input=x
)

def vulnerable():
x = client.responses.create(
model="gpt-4.1",
input="Write a one-sentence bedtime story about a unicorn."
)

if random.random() > 0.5:
func2(x)
else:
func1(x)

if __name__ == "__main__":
vulnerable()
Один пример сбоя файла pysa и taint.config (я много пробовал) ...
helms.pysa:

Код: Выделить всё

# anything.chat.completions.create(...)
def __.chat.completions.create(
self,
*,
model,
messages: TaintSink[LLMInput],
**kwargs
) -> TaintSource[LLMOutput]: ...

# anything.responses.create(...)
def __.responses.create(
self,
*,
model,
input: TaintSink[LLMInput],
**kwargs
) -> TaintSource[LLMOutput]: ...

# anything.messages.create(...)
def __.messages.create(
self,
*,
model,
messages: TaintSink[LLMInput],
**kwargs
) -> TaintSource[LLMOutput]: ...
< /code>
taint.config:
{
"comment": "Pysa taint config with LLM sources/sinks",
"sources": [
{ "name": "UserControlled", "comment": "builtins.input, etc." },
{ "name": "LLMOutput",      "comment": "Values returned by any chat.responses.create / chat.completions.create / messages.create" }
],
"sinks": [
{ "name": "RemoteCodeExecution", "comment": "os.system, eval, etc." },
{ "name": "LLMInput",            "comment": "Data sent into any chat.responses.create / chat.completions.create / messages.create" }
],
"features": [],
"rules": [
{
"name": "Shell injection",
"code": 5001,
"sources": ["UserControlled"],
"sinks": ["RemoteCodeExecution"],
"message_format": "User input might reach os.system"
},
{
"name": "LLM invocation",
"code": 5002,
"sources": ["UserControlled"],
"sinks": ["LLMInput"],
"message_format": "User input might reach an LLM API call"
},
{
"name": "LLM-to-shell",
"code": 5003,
"sources": ["LLMOutput"],
"sinks": ["RemoteCodeExecution"],
"message_format": "LLM output might reach os.system"
}
]
}
Ошибка, которую я получаю при запуске Pyre Validate-models :

Код: Выделить всё

ƛ Found 3 model verification errors!
taint/llms.pysa:2:0 `__.chat.completions.create` is not part of the environment, no module `__` in search path.
taint/llms.pysa:11:0 `__.responses.create` is not part of the environment, no module `__` in search path.
taint/llms.pysa:20:0 `__.messages.create` is not part of the environment, no module `__` in search path.
< /code>
В идеале я хочу поддерживать вызовы в Openai и Anpropic, которые (они могут иметь еще несколько Kwargs): < /p>
response = client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": role_name, "content": "Hello OpenAI."}, {"role": "user", "content":
"Bye OpenAI."}]
)

response = client.responses.create(
model="gpt-4.1",
input="Hello OpenAI."
)

response = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1024,
messages=[ {"role": "user", "content": "Hello, Claude"} ]
)
Я был бы признателен за помощь, спасибо!

Подробнее здесь: https://stackoverflow.com/questions/796 ... e-and-sink
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»