Skip to content

Commit 7b978a3

Browse files
john-walkoeclaude
andcommitted
FIX: Normalize paths for cross-platform prompt injection scanning
The prompt injection scanner was failing on CI (Linux) because the baseline was created on Windows with backslash path separators. The scanner couldn't match paths between platforms, causing all findings to appear as NEW. Changes: - Normalize all file paths to use forward slashes (Path.as_posix()) - Update get_fingerprint() to use normalized paths - Update baseline_file_key generation to use normalized paths - Regenerate .prompt_injections.baseline with 63 normalized findings This fixes the CI security scan failures while maintaining full cross-platform compatibility between Windows and Linux environments. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent c3b491f commit 7b978a3

File tree

2 files changed

+265
-3
lines changed

2 files changed

+265
-3
lines changed

.prompt_injections.baseline

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,248 @@
2929
"match": "Variation Selector steganography detected (1 selectors)"
3030
}
3131
},
32+
"src/fpd_mcp/prompts/__init__.py": {
33+
"0bc0544c68e852f6": {
34+
"line": 33,
35+
"match": "prompt"
36+
},
37+
"363828ae7bc98c11": {
38+
"line": 4,
39+
"match": "prompt"
40+
},
41+
"39cfd406cf875846": {
42+
"line": 2,
43+
"match": "Prompt"
44+
},
45+
"3f63f24165879a53": {
46+
"line": 5,
47+
"match": "prompt"
48+
},
49+
"7cb5efa8e17da036": {
50+
"line": 16,
51+
"match": "Prompts"
52+
},
53+
"b5afdfedf95e766e": {
54+
"line": 8,
55+
"match": "prompts"
56+
}
57+
},
58+
"src/fpd_mcp/prompts/art_unit_quality_assessment.py": {
59+
"acb349649d6edf53": {
60+
"line": 152,
61+
"match": "Variation Selector steganography detected (1 selectors)"
62+
},
63+
"c442c8b25673b5c0": {
64+
"line": 6,
65+
"match": "prompt"
66+
}
67+
},
68+
"src/fpd_mcp/prompts/company_petition_risk_assessment_pfw.py": {
69+
"b2a5e1036fbba0b4": {
70+
"line": 266,
71+
"match": "Variation Selector steganography detected (1 selectors)"
72+
},
73+
"f536fa6e86568f7c": {
74+
"line": 6,
75+
"match": "prompt"
76+
}
77+
},
78+
"src/fpd_mcp/prompts/complete_portfolio_due_diligence_pfw_ptab.py": {
79+
"3f24e6c45cec9ec5": {
80+
"line": 311,
81+
"match": "Variation Selector steganography detected (1 selectors)"
82+
},
83+
"4d37da9345f351f6": {
84+
"line": 251,
85+
"match": "Variation Selector steganography detected (1 selectors)"
86+
},
87+
"953d39719675c08b": {
88+
"line": 172,
89+
"match": "Variation Selector steganography detected (1 selectors)"
90+
},
91+
"b5f09bc85ebb796d": {
92+
"line": 310,
93+
"match": "Variation Selector steganography detected (1 selectors)"
94+
},
95+
"e08772a36aa6b7a7": {
96+
"line": 309,
97+
"match": "Variation Selector steganography detected (1 selectors)"
98+
},
99+
"fdd27d40ecd28e75": {
100+
"line": 6,
101+
"match": "prompt"
102+
}
103+
},
104+
"src/fpd_mcp/prompts/examiner_dispute_citation_analysis.py": {
105+
"1dc8cb9ab94c6038": {
106+
"line": 6,
107+
"match": "prompt"
108+
},
109+
"4db5ee2669a08097": {
110+
"line": 277,
111+
"match": "Variation Selector steganography detected (1 selectors)"
112+
},
113+
"4fcb47246cc76789": {
114+
"line": 278,
115+
"match": "Variation Selector steganography detected (1 selectors)"
116+
},
117+
"563f4412aea9f16e": {
118+
"line": 279,
119+
"match": "Variation Selector steganography detected (1 selectors)"
120+
}
121+
},
122+
"src/fpd_mcp/prompts/litigation_research_setup_pfw.py": {
123+
"29b2ed9feb2eb14b": {
124+
"line": 6,
125+
"match": "prompt"
126+
},
127+
"9d7f120d5897f486": {
128+
"line": 168,
129+
"match": "Variation Selector steganography detected (1 selectors)"
130+
}
131+
},
132+
"src/fpd_mcp/prompts/patent_vulnerability_assessment_ptab.py": {
133+
"21b9adb7cd1bc2ca": {
134+
"line": 155,
135+
"match": "Variation Selector steganography detected (1 selectors)"
136+
},
137+
"5682b620a6d6422b": {
138+
"line": 264,
139+
"match": "Variation Selector steganography detected (1 selectors)"
140+
},
141+
"98064ba63868ff0f": {
142+
"line": 266,
143+
"match": "Variation Selector steganography detected (1 selectors)"
144+
},
145+
"ac0db517c701680c": {
146+
"line": 265,
147+
"match": "Variation Selector steganography detected (1 selectors)"
148+
},
149+
"f61dfb6aec0700d0": {
150+
"line": 6,
151+
"match": "prompt"
152+
}
153+
},
154+
"src/fpd_mcp/prompts/petition_document_research_package.py": {
155+
"a051d912cba8cd15": {
156+
"line": 6,
157+
"match": "prompt"
158+
},
159+
"ac712af16f584b87": {
160+
"line": 224,
161+
"match": "Variation Selector steganography detected (1 selectors)"
162+
},
163+
"b25466a86e914ffc": {
164+
"line": 84,
165+
"match": "Variation Selector steganography detected (1 selectors)"
166+
}
167+
},
168+
"src/fpd_mcp/prompts/petition_quality_with_citation_intelligence.py": {
169+
"39c36cbeaf0c4883": {
170+
"line": 6,
171+
"match": "prompt"
172+
},
173+
"3fc69cb5d9764e89": {
174+
"line": 230,
175+
"match": "Variation Selector steganography detected (1 selectors)"
176+
},
177+
"45c108f9b0cbfc33": {
178+
"line": 190,
179+
"match": "Variation Selector steganography detected (1 selectors)"
180+
},
181+
"4e9d81195853a41f": {
182+
"line": 207,
183+
"match": "Variation Selector steganography detected (1 selectors)"
184+
},
185+
"6ef9db203273f76a": {
186+
"line": 228,
187+
"match": "Variation Selector steganography detected (1 selectors)"
188+
},
189+
"8385fd76768f6f29": {
190+
"line": 99,
191+
"match": "Variation Selector steganography detected (1 selectors)"
192+
},
193+
"a1ade2486f23e744": {
194+
"line": 205,
195+
"match": "Variation Selector steganography detected (1 selectors)"
196+
},
197+
"ab0da65008f9e9c0": {
198+
"line": 206,
199+
"match": "Variation Selector steganography detected (1 selectors)"
200+
},
201+
"b90684d5a2be9dce": {
202+
"line": 204,
203+
"match": "Variation Selector steganography detected (1 selectors)"
204+
},
205+
"f36dc32ee99b93c7": {
206+
"line": 229,
207+
"match": "Variation Selector steganography detected (1 selectors)"
208+
}
209+
},
210+
"src/fpd_mcp/prompts/prosecution_quality_correlation_pfw.py": {
211+
"0c2b4e6c3f167bcc": {
212+
"line": 246,
213+
"match": "Variation Selector steganography detected (1 selectors)"
214+
},
215+
"1fe3d80d3b5827b6": {
216+
"line": 199,
217+
"match": "Variation Selector steganography detected (1 selectors)"
218+
},
219+
"2eed5fbeaf3013e6": {
220+
"line": 247,
221+
"match": "Variation Selector steganography detected (1 selectors)"
222+
},
223+
"4217679f71c0e740": {
224+
"line": 221,
225+
"match": "Variation Selector steganography detected (1 selectors)"
226+
},
227+
"b2aba2209130c705": {
228+
"line": 223,
229+
"match": "Variation Selector steganography detected (1 selectors)"
230+
},
231+
"c43920f518fa994d": {
232+
"line": 245,
233+
"match": "Variation Selector steganography detected (1 selectors)"
234+
},
235+
"c483f6f12521a5ba": {
236+
"line": 6,
237+
"match": "prompt"
238+
},
239+
"ccbeadf50f448d47": {
240+
"line": 222,
241+
"match": "Variation Selector steganography detected (1 selectors)"
242+
}
243+
},
244+
"src/fpd_mcp/prompts/revival_petition_analysis.py": {
245+
"9d9e91c7658e4484": {
246+
"line": 6,
247+
"match": "prompt"
248+
},
249+
"b9ee15bb9aa6bb03": {
250+
"line": 236,
251+
"match": "system"
252+
},
253+
"c28328c977cc1e78": {
254+
"line": 158,
255+
"match": "Variation Selector steganography detected (1 selectors)"
256+
}
257+
},
258+
"src/fpd_mcp/shared/health_check.py": {
259+
"9e29b5aca2f1a849": {
260+
"line": 2,
261+
"match": "system"
262+
},
263+
"fe25b2b9efa8509d": {
264+
"line": 4,
265+
"match": "system"
266+
}
267+
},
268+
"src/fpd_mcp/shared/internal_auth.py": {
269+
"afe1f6628c635b89": {
270+
"line": 2,
271+
"match": "System"
272+
}
273+
},
32274
"src\\fpd_mcp\\prompts\\__init__.py": {
33275
"31237e17f9a93fa5": {
34276
"line": 5,
@@ -271,6 +513,22 @@
271513
"match": "System"
272514
}
273515
},
516+
"tests/test_unified_key_management.py": {
517+
"1f36b10fab2027a5": {
518+
"line": 6,
519+
"match": "system"
520+
}
521+
},
522+
"tests/test_unified_storage.py": {
523+
"4c3035e3df3d3f24": {
524+
"line": 5,
525+
"match": "system"
526+
},
527+
"732c8e9bfc82c41c": {
528+
"line": 248,
529+
"match": "system"
530+
}
531+
},
274532
"tests\\test_unified_key_management.py": {
275533
"5921ffae2852892a": {
276534
"line": 6,

.security/check_prompt_injections.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939

4040
def get_fingerprint(filepath: Path, line_number: int, match: str) -> str:
4141
"""Create a unique fingerprint for a finding."""
42-
content = f"{filepath}:{line_number}:{match}"
42+
# Normalize path to use forward slashes for cross-platform compatibility
43+
normalized_path = filepath.as_posix()
44+
content = f"{normalized_path}:{line_number}:{match}"
4345
return hashlib.sha256(content.encode()).hexdigest()[:16]
4446

4547

@@ -249,7 +251,8 @@ def main():
249251

250252
# Filter findings against baseline
251253
if baseline or args.update_baseline:
252-
baseline_file_key = str(file_path)
254+
# Normalize path to use forward slashes for cross-platform compatibility
255+
baseline_file_key = file_path.as_posix()
253256
if baseline_file_key not in baseline:
254257
baseline[baseline_file_key] = {}
255258

@@ -286,7 +289,8 @@ def main():
286289
print(f"\n[!] Prompt injection patterns found in {file_path}:")
287290
for line_num, match in findings:
288291
fingerprint = get_fingerprint(file_path, line_num, match)
289-
in_baseline = baseline and fingerprint in baseline.get(str(file_path), {})
292+
# Use normalized path for cross-platform compatibility
293+
in_baseline = baseline and fingerprint in baseline.get(file_path.as_posix(), {})
290294
status = " [BASELINE]" if in_baseline else " [NEW]" if (baseline or args.update_baseline) else ""
291295

292296
if args.verbose:

0 commit comments

Comments
 (0)