Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

fix: revert guard removal made in 9cb2744 #54

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,21 @@ extension.addBuildEventHandler(
}

if (!tempConfig) {
config = {
reportOnly: true,
reportUri: "",
unsafeEval: true,
path: ["/*"],
excludedPath: [],
};
console.log("Using default CSP config.");
// FIXME(ndhoule): This is a bug. At one point we added a default value for config, which
// means we can no longer enter this case.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!config) {
Copy link
Contributor Author

@ndhoule ndhoule Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug here is: we default config to {} where it's defined, so this condition is impossible. But I spaced and made the CSP extension always use the default config. 😶

(I have a branch that will fix various issues in the CSP extension and add some tests, so I'll add a regression test for this.)

config = {
reportOnly: true,
reportUri: "",
unsafeEval: true,
path: ["/*"],
excludedPath: [],
};
console.log("Using default CSP config.");
} else {
console.log("Using stored CSP config.");
}
}

// Ensure if path is not present, that it is set to "/*" as a default
Expand Down