Skip to content

Commit

Permalink
fix(observatory): display some csp policy pass flags negated
Browse files Browse the repository at this point in the history
  • Loading branch information
argl committed Jun 25, 2024
1 parent c225b8e commit 32006f7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion client/src/observatory/results/csp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ export default function ObservatoryCSP({
result: ObservatoryResult;
}) {
const policy = result.tests["content-security-policy"]?.policy;

// Awkward, but so it has been on python-observatory:
// Negate some of the `pass` flags because sometimes
// a `pass` on the policy is bad, and sometimes not.
const negatedPolicies = [
"insecureBaseUri",
"insecureFormAction",
"insecureSchemeActive",
"insecureSchemePassive",
"unsafeEval",
"unsafeInline",
"unsafeInlineStyle",
"unsafeObjects",
];

return (
<table className="csp">
{policy ? (
Expand All @@ -43,7 +58,13 @@ export default function ObservatoryCSP({
}}
/>
<td data-header="Pass">
<PassIcon pass={!policy[pt].pass} />
<PassIcon
pass={
negatedPolicies.includes(pt)
? !policy[pt].pass
: policy[pt].pass
}
/>
</td>
<td
data-header="Info"
Expand Down

0 comments on commit 32006f7

Please sign in to comment.