From 54e5040348a374e60ebcfc4e6b91c2aa3fd82936 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Thu, 10 Feb 2022 19:38:09 +0100 Subject: [PATCH] Adjust conditions for unlawful cookies --- report-window/generate-survey-questions.ts | 3 +- report-window/parse-answers.ts | 99 ++++++++++--------- report-window/problems/unlawful-cookies.tsx | 29 +++--- report-window/raw-answers.ts | 100 ++++++++++---------- 4 files changed, 117 insertions(+), 114 deletions(-) diff --git a/report-window/generate-survey-questions.ts b/report-window/generate-survey-questions.ts index 1045834..12fc78b 100644 --- a/report-window/generate-survey-questions.ts +++ b/report-window/generate-survey-questions.ts @@ -22,6 +22,7 @@ function generateHostPage( isRequired: true, title: `Cel ujawnienia danych właścicielowi domeny ${host}`, ...defaultValue('present'), + visibleIf: '{popup_type} != "none"', choices: [ { value: 'not_mentioned', @@ -140,7 +141,7 @@ function generateHostPage( ...defaultValue('was_processing_necessary'), visibleIf: `{${f('legal_basis_type')}} = "legitimate_interest" or {${f( 'present' - )}} = "not_mentioned"`, + )}} = "not_mentioned" or {popup_type} = "none"`, choices: [ { value: 'yes', text: 'Tak, było konieczne' }, { value: 'no', text: 'Nie, nie było konieczne' }, diff --git a/report-window/parse-answers.ts b/report-window/parse-answers.ts index 4f7b0d2..0005559 100644 --- a/report-window/parse-answers.ts +++ b/report-window/parse-answers.ts @@ -3,66 +3,65 @@ import RawAnswers, { BasicRawAnswers, HostRawAnswers } from './raw-answers'; export type RecordValue = T extends Record ? R : any; export type ParsedHostAnswers = ({ - present: - | 'not_mentioned' - | 'not_before_making_a_choice' - | 'mentioned_in_policy' - | 'mentioned_in_popup'; - legal_basis_type: 'consent' | 'legitimate_interes' | 'not_mentioned'; - popup_action: 'none' | 'closed_popup' | 'accept_all' | 'deny_all' | 'other'; - was_processing_necessary: 'yes' | 'no' | 'not_sure'; + present: + | 'not_mentioned' + | 'not_before_making_a_choice' + | 'mentioned_in_policy' + | 'mentioned_in_popup'; + legal_basis_type: 'consent' | 'legitimate_interes' | 'not_mentioned'; + was_processing_necessary: 'yes' | 'no' | 'not_sure'; } & ( - | { - consent_problems: - | 'claims_consent_but_sends_before_consent' - | 'claims_consent_but_there_was_no_easy_refuse'; - } - | { consent_problems: 'none'; outside_eu: 'yes' | 'no' | 'not_sure' } + | { + consent_problems: + | 'claims_consent_but_sends_before_consent' + | 'claims_consent_but_there_was_no_easy_refuse'; + } + | { consent_problems: 'none'; outside_eu: 'yes' | 'no' | 'not_sure' } )) & { - legitimate_interest_activity_specified: 'no' | 'precise' | 'vague'; - outside_eu: 'yes' | 'no' | 'not_sure'; - legitimate_interest_description?: string; + legitimate_interest_activity_specified: 'no' | 'precise' | 'vague'; + outside_eu: 'yes' | 'no' | 'not_sure'; + legitimate_interest_description?: string; }; export type ParsedAnswers = BasicRawAnswers & { hosts: Record }; function parseHostAnswers( - raw_answers: Record + raw_answers: Record ): Record { - const result: Record> = {}; - for (const [key, value] of Object.entries(raw_answers)) { - const [masked_host, attr] = key.split('|'); - const host = masked_host.replace(/_/g, '.'); - if (!result[host]) { - result[host] = {} as ParsedHostAnswers; - } - result[host][attr] = value; - } - return result as Record; + const result: Record> = {}; + for (const [key, value] of Object.entries(raw_answers)) { + const [masked_host, attr] = key.split('|'); + const host = masked_host.replace(/_/g, '.'); + if (!result[host]) { + result[host] = {} as ParsedHostAnswers; + } + result[host][attr] = value; + } + return result as Record; } export function parseAnswers({ - zaimek, - is_incognito_different, - policy_readable, - popup_type, - cookie_wall, - passive_consent_description, - mentions_passive_consent, - rejection_is_hard, - administrator_identity_available_before_choice, - ...rest + zaimek, + is_incognito_different, + policy_readable, + popup_type, + cookie_wall, + passive_consent_description, + mentions_passive_consent, + rejection_is_hard, + administrator_identity_available_before_choice, + ...rest }: RawAnswers): ParsedAnswers { - return { - zaimek, - is_incognito_different, - policy_readable, - popup_type, - cookie_wall, - passive_consent_description, - mentions_passive_consent, - rejection_is_hard, - administrator_identity_available_before_choice, - hosts: parseHostAnswers(rest), - } as ParsedAnswers; + return { + zaimek, + is_incognito_different, + policy_readable, + popup_type, + cookie_wall, + passive_consent_description, + mentions_passive_consent, + rejection_is_hard, + administrator_identity_available_before_choice, + hosts: parseHostAnswers(rest), + } as ParsedAnswers; } diff --git a/report-window/problems/unlawful-cookies.tsx b/report-window/problems/unlawful-cookies.tsx index f631cdc..50a8c27 100644 --- a/report-window/problems/unlawful-cookies.tsx +++ b/report-window/problems/unlawful-cookies.tsx @@ -8,6 +8,22 @@ export class UnlawfulCookieAccess extends Problem { getNecessaryExplainers(): ExplainerKey[] { return []; } + + static qualifies(answers: ParsedAnswers, clusters: RequestCluster[]): boolean { + // są cookiesy, nie było zgody, nie są konieczne do działania strony + const cookie_clusters = Object.values(clusters).filter((c) => c.hasMarkedCookies()); + return cookie_clusters.some((cluster) => { + const hostAnswers = answers.hosts[cluster.id]; + return ( + (hostAnswers.present == 'not_mentioned' || + hostAnswers.present == 'not_before_making_a_choice' || + ['none', 'closed_popup', 'deny_all'].includes(answers.popup_action) || + answers.popup_type === 'none') && + hostAnswers.was_processing_necessary != 'yes' + ); + }); + } + getEmailContent() { const cookie_clusters = Object.values(this.clusters).filter((c) => c.hasMarkedCookies()); const unnecessary_hosts = Object.entries(this.answers.hosts) @@ -152,17 +168,4 @@ export class UnlawfulCookieAccess extends Problem { ); } - static qualifies(answers: ParsedAnswers, clusters: RequestCluster[]): boolean { - // są cookiesy, nie było zgody, nie są konieczne do działania strony - const cookie_clusters = Object.values(clusters).filter((c) => c.hasMarkedCookies()); - return cookie_clusters.some((cluster) => { - const hostAnswers = answers.hosts[cluster.id]; - return ( - (hostAnswers.present == 'not_mentioned' || - hostAnswers.present == 'not_before_making_a_choice' || - ['none', 'closed_popup', 'deny_all'].includes(hostAnswers.popup_action)) && - hostAnswers.was_processing_necessary != 'yes' - ); - }); - } } diff --git a/report-window/raw-answers.ts b/report-window/raw-answers.ts index a1e9e08..b93775e 100644 --- a/report-window/raw-answers.ts +++ b/report-window/raw-answers.ts @@ -1,58 +1,58 @@ export type HostRawAnswers = { - [key: `${string}|present`]: - | 'not_mentioned' - | 'not_before_making_a_choice' - | 'mentioned_in_policy' - | 'mentioned_in_popup'; - [key: `${string}|legal_basis_type`]: 'consent' | 'legitimate_interest' | 'not_mentioned'; - [key: `${string}|consent`]: - | 'claims_consent_but_sends_before_consent' - | 'claims_consent_but_there_was_no_easy_refuse' - | 'none'; - [key: `${string}|legitimate_interest_activity_specified`]: 'precise' | 'vague' | 'no'; - [key: `${string}|legitimate_interest_description`]: string; - [key: `${string}|outside_eu`]: 'yes' | 'no' | 'not_sure'; + [key: `${string}|present`]: + | 'not_mentioned' + | 'not_before_making_a_choice' + | 'mentioned_in_policy' + | 'mentioned_in_popup'; + [key: `${string}|legal_basis_type`]: 'consent' | 'legitimate_interest' | 'not_mentioned'; + [key: `${string}|consent`]: + | 'claims_consent_but_sends_before_consent' + | 'claims_consent_but_there_was_no_easy_refuse' + | 'none'; + [key: `${string}|legitimate_interest_activity_specified`]: 'precise' | 'vague' | 'no'; + [key: `${string}|legitimate_interest_description`]: string; + [key: `${string}|outside_eu`]: 'yes' | 'no' | 'not_sure'; }; export type BasicRawAnswers = { - zaimek: 0 | 1 | 2 | 3; - is_incognito_different: [] | ['incognito_is_the_same']; - policy_readable: 'yes' | 'vague' | 'cant_find'; - popup_action: 'none' | 'closed_popup' | 'accept_all' | 'deny_all' | 'other'; - popup_closed_how: string; - popup_deny_all_how: string; + zaimek: 0 | 1 | 2 | 3; + is_incognito_different: [] | ['incognito_is_the_same']; + policy_readable: 'yes' | 'vague' | 'cant_find'; + popup_action: 'none' | 'closed_popup' | 'accept_all' | 'deny_all' | 'other'; + popup_closed_how: string; + popup_deny_all_how: string; } & ( - | ({ - popup_type: 'passive_popup'; - cookie_wall: 'yes' | 'no'; - rejection_is_hard: undefined; - administrator_identity_available_before_choice: undefined; - } & ( - | { - mentions_passive_consent?: 'yes'; - passive_consent_description: string; - } - | { - mentions_passive_consent?: 'no'; - passive_consent_description: undefined; - } - )) - | { - popup_type: 'some_choice'; - rejection_is_hard: 'yes' | 'no'; - administrator_identity_available_before_choice: 'yes' | 'no'; - cookie_wall: undefined; - passive_consent_description: undefined; - mentions_passive_consent: undefined; - } - | { - popup_type: 'none' | 'page'; - cookie_wall: undefined; - passive_consent_description: undefined; - mentions_passive_consent: undefined; - rejection_is_hard: undefined; - administrator_identity_available_before_choice: undefined; - } + | ({ + popup_type: 'passive_popup'; + cookie_wall: 'yes' | 'no'; + rejection_is_hard: undefined; + administrator_identity_available_before_choice: undefined; + } & ( + | { + mentions_passive_consent?: 'yes'; + passive_consent_description: string; + } + | { + mentions_passive_consent?: 'no'; + passive_consent_description: undefined; + } + )) + | { + popup_type: 'some_choice'; + rejection_is_hard: 'yes' | 'no'; + administrator_identity_available_before_choice: 'yes' | 'no'; + cookie_wall: undefined; + passive_consent_description: undefined; + mentions_passive_consent: undefined; + } + | { + popup_type: 'none' | 'page'; + cookie_wall: undefined; + passive_consent_description: undefined; + mentions_passive_consent: undefined; + rejection_is_hard: undefined; + administrator_identity_available_before_choice: undefined; + } ); type RawAnswers = BasicRawAnswers & HostRawAnswers;