Skip to content

Commit

Permalink
refactor(mockserviceworker.js): replace math.random with crypto.rando…
Browse files Browse the repository at this point in the history
…muuid in service worker file

It's known that Math.Random isn't secure (see https://v8.dev/blog/math-random). Even if this file
isn't supposed to be deployed in production, some static code analysis tools may flag this as a
critical issue, breaking CI pipelines.
  • Loading branch information
Laryssa Rocha committed Oct 9, 2023
1 parent eca6a9e commit 84e2e26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ self.addEventListener('fetch', function (event) {
}

// Generate unique request ID.
const requestId = Math.random().toString(16).slice(2)
const requestId = crypto.randomUUID()
event.respondWith(handleRequest(event, requestId))
})

Expand Down

0 comments on commit 84e2e26

Please sign in to comment.