Skip to content

Commit 9b1dfcb

Browse files
committed
fixed the public to authenticated vulnerability
Signed-off-by: Vedansh Saini <[email protected]>
1 parent 94302db commit 9b1dfcb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/scripts/scrumHelper.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ function allIncluded(outputTarget = 'email') {
235235
cacheKey: githubCache.cacheKey,
236236
timestamp: githubCache.timestamp,
237237
subject: subject,
238+
usedToken: !!githubToken,
238239
}
239240
log(`Saving data to storage:`, {
240241
cacheKey: githubCache.cacheKey,
@@ -283,6 +284,7 @@ function allIncluded(outputTarget = 'email') {
283284
githubCache.cacheKey = cache.cacheKey;
284285
githubCache.timestamp = cache.timestamp;
285286
githubCache.subject = cache.subject;
287+
githubCache.usedToken = cache.usedToken || false;
286288

287289
if(cache.subject && scrumSubject) {
288290
scrumSubject.value = cache.subject;
@@ -323,11 +325,18 @@ function allIncluded(outputTarget = 'email') {
323325
const now = Date.now();
324326
const isCacheFresh = (now - githubCache.timestamp) < githubCache.ttl;
325327
const isCacheKeyMatch = githubCache.cacheKey === cacheKey;
328+
const needsToken = !!githubToken;
329+
const cacheUsedToken = !!githubCache.usedToken;
326330

327331
if(githubCache.data && isCacheFresh & isCacheKeyMatch) {
328-
log('Using cached data - cache is fresh and key matches');
329-
processGithubData(githubCache.data);
330-
return Promise.resolve();
332+
if(needsToken & !cacheUsedToken) {
333+
log('Cache was fetched without token, but user now has a token. Invalidating cache.');
334+
githubCache.data = null;
335+
} else {
336+
log('Using cached data - cache is fresh and key matches');
337+
processGithubData(githubCache.data);
338+
return Promise.resolve();
339+
}
331340
}
332341
// if cache key does not match our cache is stale, fetch new data
333342
if(!isCacheKeyMatch) {

0 commit comments

Comments
 (0)