blib/lib/GDPR/IAB/TCFv2/Validator/Reason.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 42 / 42 CC 5 SCAR 11.0
CC
5
Cov
100%
reason_string
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/GDPR/IAB/TCFv2/Publisher.pm ↑ Summary blib/lib/GDPR/IAB/TCFv2/Validator/Result.pm »
1 package GDPR::IAB::TCFv2::Validator::Reason 0.530;
2 28 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 28 require Exporter;
6 28 ▶use parent qw<Exporter>;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 28 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Successful validation: no failure to report.
12 28 ReasonNone => 0,
13  
14 # The TCF string is missing the mandatory disclosed vendors segment
15 # (TCF v2.2+ requirement).
16 ReasonMissingDisclosedVendors => 1,
17  
18 # The configured vendor ID is not present in the disclosed vendors
19 # segment.
20 ReasonVendorNotDisclosed => 2,
21  
22 # The vendor is not allowed globally (neither consent nor legitimate
23 # interest is granted for any purpose).
24 ReasonVendorNotAllowed => 3,
25  
26 # A required purpose is not allowed for the vendor.
27 ReasonPurposeNotAllowed => 4,
28  
29 # A publisher restriction of type 0 (Not Allowed) is present for a
30 # required purpose.
31 ReasonPublisherRestrictionNotAllowed => 5,
32  
33 # A publisher restriction of type 1 (Requires Consent) is present
34 # for a purpose configured under the legitimate-interest legal basis.
35 ReasonPublisherRestrictionRequireConsent => 6,
36  
37 # A publisher restriction of type 2 (Requires Legitimate Interest) is
38 # present for a purpose configured under the consent legal basis.
39 ReasonPublisherRestrictionRequireLegitimateInterest => 7,
40  
41 # The vendor is not allowed for a specific purpose under the consent
42 # legal basis (vendor consent flag and/or purpose consent flag missing).
43 ReasonVendorNotAllowedConsent => 8,
44  
45 # The vendor is not allowed for a specific purpose under the legitimate
46 # interest legal basis (vendor LI flag and/or purpose LI flag missing).
47 ReasonVendorNotAllowedLegitimateInterest => 9,
48  
49 # The TCF spec forbids the legitimate-interest legal basis for this
50 # purpose: Purpose 1 always; Purposes 3-6 on TcfPolicyVersion >= 4.
51 ReasonLegitimateInterestNotPermittedForPurpose => 10,
52  
53 # The consent string's TcfPolicyVersion is below the validator's
54 # configured minimum.
55 ReasonPolicyVersionTooLow => 11,
56  
57 # The consent string could not be decoded (malformed, empty, or
58 # unsupported version). Only emitted when explicitly requested.
59 ReasonDecodeError => 12,
60  
61 # The consent string's CMP ID is not recognized as a valid (active,
62 # non-deleted) entry in the configured CMP registry.
63 ReasonInvalidCMP => 13,
64  
65 # The CMP id is recognized but has been retired (deletedDate in the past).
66 ReasonCMPDeleted => 14,
67  
68 # The CMP id is unknown to the registry.
69 ReasonCMPUnknown => 15,
70 28 };
71  
72 28 ▶use constant ReasonDescription => {
Subroutine BEGIN: called CC=1 SCAR=0.0
73 ReasonNone => "no failure",
74 ReasonMissingDisclosedVendors => "missing disclosed vendors",
75 ReasonVendorNotDisclosed => "vendor not disclosed",
76 ReasonVendorNotAllowed => "vendor not allowed",
77 ReasonPurposeNotAllowed => "purpose not allowed",
78 ReasonPublisherRestrictionNotAllowed => "publisher restriction: not allowed",
79 ReasonPublisherRestrictionRequireConsent => "publisher restriction: requires consent",
80 ReasonPublisherRestrictionRequireLegitimateInterest => "publisher restriction: requires legitimate interest",
81 ReasonVendorNotAllowedConsent => "vendor not allowed for purpose (consent)",
82 ReasonVendorNotAllowedLegitimateInterest => "vendor not allowed for purpose (legitimate interest)",
83 ReasonLegitimateInterestNotPermittedForPurpose => "legitimate interest not permitted for purpose",
84 ReasonPolicyVersionTooLow => "tcf policy version too low",
85 ReasonDecodeError => "decode error",
86 ReasonInvalidCMP => "invalid cmp id",
87 ReasonCMPDeleted => "deleted cmp id",
88 ReasonCMPUnknown => "unknown cmp id",
89 28 };
90  
91 # Lazily built reverse map: integer code -> human-readable string.
92 28 my %_CODE_TO_STRING;
93  
94 19 ▶sub reason_string {
Subroutine reason_string: called CC=5 SCAR=16.1
Pod documented
95 19 my ($code) = @_;
96  
97 19 ▶ return "unknown validation failure" unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 1 18 19
98  
99 18 ▶ unless (%_CODE_TO_STRING) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%_CODE_TO_STRING) 1 17 18
100 1 my $desc = ReasonDescription;
101 1 for my $name (keys %{$desc}) {
102 16 my $value = __PACKAGE__->can($name)->();
103 16 $_CODE_TO_STRING{$value} = $desc->{$name};
104 }
105 }
106  
107 18 my $string = $_CODE_TO_STRING{$code};
108 18 ▶ return defined($string) ? $string : "unknown validation failure";
Branch: 1 branch
BranchTrueFalseTotal
defined $string ? : 16 2 18
109 }
110  
111 28 our @EXPORT_OK = qw<
112 ReasonNone
113 ReasonMissingDisclosedVendors
114 ReasonVendorNotDisclosed
115 ReasonVendorNotAllowed
116 ReasonPurposeNotAllowed
117 ReasonPublisherRestrictionNotAllowed
118 ReasonPublisherRestrictionRequireConsent
119 ReasonPublisherRestrictionRequireLegitimateInterest
120 ReasonVendorNotAllowedConsent
121 ReasonVendorNotAllowedLegitimateInterest
122 ReasonLegitimateInterestNotPermittedForPurpose
123 ReasonPolicyVersionTooLow
124 ReasonDecodeError
125 ReasonInvalidCMP
126 ReasonCMPDeleted
127 ReasonCMPUnknown
128 ReasonDescription
129 reason_string
130 >;
131  
132 28 our %EXPORT_TAGS = (all => \@EXPORT_OK);
133  
134 28 1;
135  
136 __END__
« blib/lib/GDPR/IAB/TCFv2/Publisher.pm ↑ Summary blib/lib/GDPR/IAB/TCFv2/Validator/Result.pm »