Skip to content

Commit 8803ef9

Browse files
committed
Improved prompts for LINDDUN Go
1 parent 5e46a05 commit 8803ef9

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

llms/linddun_go.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def get_linddun_go(api_key, model_name, inputs, threats_to_analyze, temperature,
130130

131131
if model_name in ["gpt-4o", "gpt-4o-mini"] or lmstudio:
132132
class Threat(BaseModel):
133-
reply: bool
134133
reason: str
134+
reply: bool
135135
response = client.beta.chat.completions.parse(
136136
model=model_name,
137137
messages=messages,
@@ -296,8 +296,8 @@ def get_response_openai(client, model, temperature, system_prompt, user_prompt,
296296
]
297297
if model in ["gpt-4o", "gpt-4o-mini"] or lmstudio:
298298
class Threat(BaseModel):
299-
reply: bool
300299
reason: str
300+
reply: bool
301301
response = client.beta.chat.completions.parse(
302302
model=model,
303303
response_format=Threat,
@@ -411,8 +411,8 @@ def judge(keys, models, previous_analysis, temperature, lmstudio=False):
411411
]
412412
if models["openai_model"] in ["gpt-4o", "gpt-4o-mini"] or lmstudio:
413413
class Threat(BaseModel):
414-
reply: bool
415414
reason: str
415+
reply: bool
416416
response = client.beta.chat.completions.parse(
417417
model=models["openai_model"] if not lmstudio else models["lmstudio_model"],
418418
response_format=Threat,

llms/prompts.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ def LINDDUN_GO_USER_PROMPT(inputs, question, title, description):
157157
LINDDUN_GO_SYSTEM_PROMPT = """
158158
When providing the answer, you MUST reply with a JSON object with the following structure:
159159
{
160-
"reply": <boolean>,
161160
"reason": <string>
161+
"reply": <boolean>,
162162
}
163163
164-
When the answer to the questions is positive or indicates the presence of the threat, set the "reply" field to true. If the answer is negative or indicates the absence of the threat, set the "reply" field to false. The "reason" field should contain a string explaining why the threat is present or not.
165-
Ensure that the reason is specific to the application description and the question asked, referring to both of them in your response.
164+
When the answer to the questions is positive or indicates the presence of the
165+
threat, set the "reply" field to true. If the answer is negative or indicates
166+
the absence of the threat, set the "reply" field to false. The "reason" field
167+
should contain a string explaining extensively why the threat is present or
168+
not, and some concrete examples of how it could be exploited.
169+
BE VERY CRITICAL AND THOROUGH IN YOUR ANALYSIS: do not assume the threat is
170+
always present. ONLY set the "reply" field to true if you are mostly sure the
171+
threat is applicable to the system.
172+
Ensure that the reason is VERY SPECIFIC to the application description and the
173+
question asked, referring to both of them in your response and tailoring it
174+
accordingly.
166175
167176
168177
The input is enclosed in triple quotes.
@@ -198,17 +207,11 @@ def LINDDUN_GO_USER_PROMPT(inputs, question, title, description):
198207
]}
199208
DATA POLICY: the data policy of the application
200209
USER DATA CONTROL: the control the user has over their data
201-
QUESTIONS: the questions associated with the threat, which you need to answer
210+
QUESTIONS: the questions associated with the threat, which you need to answer to understand if the threat is present or not
202211
THREAT_TITLE: the threat title
203212
THREAT_DESCRIPTION: the threat description
204213
'''
205214
206-
Example of expected JSON response format:
207-
208-
{
209-
"reply": true,
210-
"reason": "The threat is present because the application description mentions that the application is internet facing and uses a weak authentication method."
211-
}
212215
"""
213216

214217
LINDDUN_GO_JUDGE_PROMPT="""

0 commit comments

Comments
 (0)