Commit c18ecd4
committed
fix(filesystem): resolve TOCTOU race condition in editFile
Fixes https://github.com/ai-action/code-ollama/security/code-scanning/16
CodeQL: Potential file system race condition. The file may have changed
since it was checked.
The CodeQL warning is a TOCTOU (Time-of-Check Time-of-Use) race condition
false positive for this use case.
Fix: Remove the `existsSync` check and handle `readFileSync` errors directly.
Changes:
- `filesystem.ts:180-191` - Replaced `existsSync` check with direct
`readFileSync` and inner try-catch.
This eliminates the CodeQL warning by removing the check-then-use
pattern while maintaining the same behavior.1 parent d3635cc commit c18ecd4
2 files changed
Lines changed: 25 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
| |||
194 | 198 | | |
195 | 199 | | |
196 | 200 | | |
197 | | - | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
203 | | - | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | | - | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
217 | 231 | | |
218 | | - | |
219 | 232 | | |
220 | 233 | | |
221 | | - | |
| 234 | + | |
222 | 235 | | |
223 | 236 | | |
224 | 237 | | |
225 | | - | |
226 | | - | |
| 238 | + | |
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
187 | 191 | | |
188 | 192 | | |
189 | 193 | | |
190 | | - | |
191 | | - | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| |||
0 commit comments