Adjust conditions for unlawful cookies

This commit is contained in:
Kuba Orlik 2022-02-10 19:38:09 +01:00
parent 2b6346bca0
commit 54e5040348
4 changed files with 117 additions and 114 deletions

View File

@ -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' },

View File

@ -3,66 +3,65 @@ import RawAnswers, { BasicRawAnswers, HostRawAnswers } from './raw-answers';
export type RecordValue<T> = T extends Record<any, infer R> ? 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<string, ParsedHostAnswers> };
function parseHostAnswers(
raw_answers: Record<keyof HostRawAnswers, string>
raw_answers: Record<keyof HostRawAnswers, string>
): Record<string, ParsedHostAnswers> {
const result: Record<string, Record<string, string>> = {};
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<string, ParsedHostAnswers>;
const result: Record<string, Record<string, string>> = {};
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<string, ParsedHostAnswers>;
}
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;
}

View File

@ -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'
);
});
}
}

View File

@ -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;