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 6, 2023
1 parent 2f72152 commit bc2ebe0
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 @@ -112,7 +112,7 @@ self.addEventListener('fetch', function (event) {
}

// Generate unique request ID.
const requestId = Math.random().toString(16).slice(2)
const requestId = crypto.randomUUID().slice(0, 8)

event.respondWith(
handleRequest(event, requestId).catch((error) => {
Expand Down

0 comments on commit bc2ebe0

Please sign in to comment.