Files
codeql/python/ql/test/experimental/query-tests/Security/CWE-1427-PromptInjection/agent_instructions.py
Owen Mansel-Chan 5a97348e78 python: Inline expectation should have space after $
This was a regex-find-replace from `# \$(?! )` (using a negative lookahead) to `# $ `.
2026-03-04 12:45:05 +00:00

39 lines
984 B
Python

from agents import Agent, Runner
from flask import Flask, request # $ Source
app = Flask(__name__)
@app.route("/parameter-route")
def get_input1():
input = request.args.get("input")
agent = Agent(name="Assistant", instructions="This prompt is customized for " + input) # $ Alert[py/prompt-injection]
result = Runner.run_sync(agent, "This is a user message.")
print(result.final_output)
@app.route("/parameter-route")
def get_input2():
input = request.args.get("input")
agent = Agent(name="Assistant", instructions="This prompt is not customized.")
result = Runner.run_sync(
agent=agent,
input=[
{
"role": "user",
"content": input, # $ Alert[py/prompt-injection]
}
]
)
result2 = Runner.run_sync(
agent,
[
{
"role": "user",
"content": input, # $ Alert[py/prompt-injection]
}
]
)