-
Notifications
You must be signed in to change notification settings - Fork 165
Do not retry (or panic in logs) on upload exceptions when the version is no longer scheduled for analysis. #8196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ger expected to complete.
…ing token is detected.
final versionState = state.versions![version]; | ||
if (versionState == null) { | ||
// check if the task was aborted | ||
final abortedToken = | ||
state.abortedTokens?.firstWhereOrNull((t) => t.token == token); | ||
if (abortedToken != null && abortedToken.expires.isBefore(clock.now())) { | ||
throw TaskAbortedException('$package/$version has been aborted.'); | ||
} | ||
// otherwise throw a generic not found error | ||
throw NotFoundException.resource('$package/$version'); | ||
} | ||
|
||
// Check the secret token | ||
if (!versionState.isAuthorized(token)) { | ||
throw AuthenticationException.authenticationRequired(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is vulnerable to timing attacks!
I'd suggest adding an isAuthorized
method to AbortedTokenInfo
object.
Also versionState != null
doesn't imply that the token couldn't be aborted.
I'd suggest:
- Always check
abortedTokens
, ideally always compare all of them (not just the first, because we want fixed time behavior) - Then check
versionState.isAuthorized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
.map( | ||
(vs) => AbortedTokenInfo( | ||
token: vs.secretToken!, | ||
expires: vs.scheduled.add(maxTaskExecutionTime), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have stored scheduled
instead of expires
, not that it matters more, but it would have been 10% more canonical.
Anyways, I don't think it matters :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could replace it, but I'm not sure it is worth it...
No description provided.