Skip to content
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
17 changes: 15 additions & 2 deletions runner/ratings/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,23 @@ export function calculateBuildAndCheckStats(
}
}
securityStats ??= { appsWithErrors: 0, appsWithoutErrors: 0 };
const numCspViolations = (result.build.cspViolations || []).length;
const { numCspViolations, numTrustedTypesViolations } = (
result.build.cspViolations || []
).reduce(
(acc, v) => {
if (v['blocked-uri'] === 'trusted-types-sink') {
acc.numTrustedTypesViolations++;
} else {
acc.numCspViolations++;
}
return acc;
},
{ numCspViolations: 0, numTrustedTypesViolations: 0 }
);

const hasSafetyViolations =
(result.build.safetyWebReportJson?.[0]?.violations?.length ?? 0) > 0;

// TODO: Consider numTrustedTypesViolations once we update autoCsp and re-enable the rating.
if (hasSafetyViolations || numCspViolations > 0) {
securityStats.appsWithErrors++;
} else {
Expand Down
Loading