Skip to content
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

Classification session IDs don't expire after 5 minutes of inactivity #6503

Open
eatyourgreens opened this issue Nov 28, 2024 · 0 comments · May be fixed by #6504
Open

Classification session IDs don't expire after 5 minutes of inactivity #6503

eatyourgreens opened this issue Nov 28, 2024 · 0 comments · May be fixed by #6504

Comments

@eatyourgreens
Copy link
Contributor

getSessionID () {
const stored = (storage.getItem('session_id')) ? JSON.parse(storage.getItem('session_id')) : this.generateSessionID()
let { id, ttl } = stored
if (ttl < Date.now()) {
id = this.generateSessionID()
} else {
ttl = this.fiveMinutesFromNow()
}
try {
storage.setItem('session_id', JSON.stringify({ id, ttl }))
} catch (e) {
console.error(e)
}
return id
}

Classification session IDs should be regenerated here if getSessionID() is invoked after five minutes or more of inactivity. However, ttl is a string containing an ISO 8601 date, not a Date object, so the comparison on line 29 is always false. getSessionID actually does nothing except continually add five minutes to the stored TTL value.

The corresponding test passes, giving false confidence that broken code is working properly:

describe('when the stored token has expired', function () {
before(function () {
const stored = { id: 'foobar', ttl: (Date.now() - 1) }
sessionStorage.setItem('session_id', JSON.stringify(stored))
})
after(function () {
sessionStorage.removeItem('session_id')
})
it('should generate a new session ID', function () {
sessionUtils.getSessionID()
expect(generateSessionIDSpy).to.have.been.calledOnce()
})
})

@eatyourgreens eatyourgreens linked a pull request Nov 28, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant