Skip to content

Service workers are flagged by SonarCloud Scan with Issue #13150

Open
@jovani-io

Description

@jovani-io
    Vulnerability suggested resolution:

Compliant Solution

When sending a message:

var iframe = document.getElementById("testsecureiframe");iframe.contentWindow.postMessage("hello", "https://secure.example.com"); // Compliant

When receiving a message:

window.addEventListener("message", function(event) {
if (event.origin !== "http://example.org") // Compliant
return;

console.log(event.data)

});

Code with Issue: service-worker.js

Lines: 20 -24

self.addEventListener('message', (event) => {

if (event.data && event.data.type === 'SKIP_WAITING') {
self.skipWaiting();
}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions