Commit baad739
committed
refactor: use crypto.randomInt for unbiased random number generation
Replaces manual rejection sampling with the more concise and modern
crypto.randomInt() method.
This change addresses a persistent CodeQL false positive that flagged
the modulo operator, even when used correctly with rejection sampling.
Using crypto.randomInt() makes the code cleaner and directly signals
the intent of generating a secure, unbiased random integer within a
specific range, which satisfies the static analysis tool.
Affected methods:
- AuthService.issueSudoToken
- UsersService.generateVerifyCode
- UsersService.generateRandomPassword1 parent f599086 commit baad739
2 files changed
+4
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 252 | + | |
| 253 | + | |
264 | 254 | | |
265 | 255 | | |
266 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 134 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 135 | + | |
144 | 136 | | |
145 | 137 | | |
146 | 138 | | |
| |||
2268 | 2260 | | |
2269 | 2261 | | |
2270 | 2262 | | |
2271 | | - | |
2272 | | - | |
2273 | | - | |
2274 | 2263 | | |
2275 | | - | |
2276 | | - | |
2277 | | - | |
2278 | | - | |
2279 | | - | |
2280 | | - | |
| 2264 | + | |
2281 | 2265 | | |
2282 | 2266 | | |
2283 | 2267 | | |
| |||
0 commit comments