Cookie scanner: one approval for everything a scan finds
After "Scan cookies" or a site check, the new Approve cookies view (/admin/cookie-approval) lists what waits, grouped by consent category, with provider, purpose and duration and New / Changed / Needs description markers. One "Approve and add" puts every ticked cookie into Cookie banner -> Cookie list in every locale. That list feeds the cookie policy table and the detailed settings window. - Never overwrites editor text or categories, never adds a second row (a pattern and a concrete name are the same cookie), never deletes. - Unknown cookies are approved into a category that needs consent (approval.unknownCategory, default marketing) and flagged Needs description; writing a purpose clears the flag. - Cookies a scan or crawl no longer finds are flagged No longer found, for review only. - The dashboard and the crawl e-mail say how many cookies wait and link to the view; nothing is added without approval. - Optional: cookieScanner.approval false keeps per-entry review. - Migration: cookie-review gains change and needsDescription. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0e7966dfbb
commit
86ff3f5ff7
@@ -7,10 +7,11 @@ import type { ResolvedCrawlConfig } from './config.js'
|
||||
import type { CrawlResult } from './result.js'
|
||||
import type { CrawlViolation } from './violations.js'
|
||||
|
||||
import { countPendingCookies } from '../approval.js'
|
||||
import { COOKIE_REVIEW_SLUG } from '../collection.js'
|
||||
import { DEFAULT_COOKIE_INTEGRATIONS } from '../integrations.js'
|
||||
import { labelFor } from '../labels.js'
|
||||
import { applyCookieFindings, collectCookieFindings, cookieScanContext } from '../scan.js'
|
||||
import { applyCookieFindings, collectCookieFindings, cookieScanContext, flagGoneEntries } from '../scan.js'
|
||||
import { COOKIE_CRAWL_SLUG } from './config.js'
|
||||
import { sendCrawlWarning } from './notify.js'
|
||||
import { findCrawlViolations } from './violations.js'
|
||||
@@ -71,6 +72,13 @@ export async function ingestCrawlResult({
|
||||
payload,
|
||||
req,
|
||||
})
|
||||
// Accepted cookies the browser no longer saw (and nothing still declares) are flagged for review, never deleted.
|
||||
summary.gone = await flagGoneEntries({
|
||||
keep: new Set([...(seenKeys as Set<string>), ...findings.filter((f) => f.source === 'integration' || f.source === 'project').map((f) => `${f.storage}:${f.name}`)]),
|
||||
payload,
|
||||
req,
|
||||
where: { status: { equals: 'accepted' } },
|
||||
})
|
||||
|
||||
const keyOf = (o: { name: string; storage: string }) => matches.get(`${o.storage}:${o.name}`)
|
||||
const violations = findCrawlViolations({
|
||||
@@ -108,6 +116,7 @@ export async function ingestCrawlResult({
|
||||
|
||||
/** Writes the finished crawl into the `cookie-crawl` global and sends the e-mail warning when asked for. */
|
||||
export async function finishCrawl({
|
||||
approval = true,
|
||||
labels,
|
||||
payload,
|
||||
req,
|
||||
@@ -115,6 +124,8 @@ export async function finishCrawl({
|
||||
siteUrl,
|
||||
summary,
|
||||
}: {
|
||||
/** Cookie approval is on: the e-mail says how many cookies wait and links to the approval view. */
|
||||
approval?: boolean
|
||||
labels: Record<string, CookieScanLabels>
|
||||
payload: BasePayload
|
||||
req?: PayloadRequest
|
||||
@@ -150,7 +161,9 @@ export async function finishCrawl({
|
||||
})) as { notifyEmails?: null | string }
|
||||
|
||||
const to = (doc.notifyEmails ?? '').split(',').map((v) => v.trim()).filter(Boolean)
|
||||
if (to.length && (summary.violations.length || summary.newUnknown)) {
|
||||
await sendCrawlWarning({ labels, payload, siteUrl: siteUrl ?? '', summary, to })
|
||||
// Something new waits for approval, or something breaks the rules: say so. Nothing is added by itself.
|
||||
const pending = approval ? await countPendingCookies(payload) : 0
|
||||
if (to.length && (summary.violations.length || summary.newUnknown || (approval && summary.created && pending))) {
|
||||
await sendCrawlWarning({ labels, payload, pending, siteUrl: siteUrl ?? '', summary, to })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user