| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/ContentSecurityPolicyReportOnly.pm | ||||||||||
| 3 | ## Version v0.1.0 | ||||||||||
| 4 | ## Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2022/05/07 | ||||||||||
| 7 | ## Modified 2022/05/07 | ||||||||||
| 8 | ## All rights reserved. | ||||||||||
| 9 | ## | ||||||||||
| 10 | ## | ||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||
| 14 | package HTTP::Promise::Headers::ContentSecurityPolicyReportOnly; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | ▶ | warnings::register_categories( 'HTTP::Promise' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | ▶ | use parent qw( HTTP::Promise::Headers::ContentSecurityPolicy ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | our $VERSION = 'v0.1.0'; | |||||||||
| 22 | }; | ||||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | sub init | ||||||||||
| 28 | { | ||||||||||
| 29 | 3 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 30 | 3 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 3 | $self->_field_name( 'Content-Security-Policy-Report-Only' ); | |||||||||
| 32 | 3 | return( $self ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 4 | ▶ | sub report_uri { return( shift->_set_get_property_value( 'report-uri', @_ ) ); } | ||||||||
|
Subroutine
report_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | |||||||||||
| 37 | 3 | 1; | |||||||||
| 38 | # NOTE: POD | ||||||||||
| 39 | __END__ | ||||||||||
| 40 | |||||||||||
| 41 | =encoding utf-8 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 NAME | ||||||||||
| 44 | |||||||||||
| 45 | HTTP::Promise::Headers::ContentSecurityPolicyReportOnly - Content-Security-Policy-Report-Only Header Field | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||
| 48 | |||||||||||
| 49 | use HTTP::Promise::Headers::ContentSecurityPolicyReportOnly; | ||||||||||
| 50 | my $this = HTTP::Promise::Headers::ContentSecurityPolicyReportOnly->new || die( HTTP::Promise::Headers::ContentSecurityPolicyReportOnly->error, "\n" ); | ||||||||||
| 51 | |||||||||||
| 52 | =head1 VERSION | ||||||||||
| 53 | |||||||||||
| 54 | v0.1.0 | ||||||||||
| 55 | |||||||||||
| 56 | =head1 DESCRIPTION | ||||||||||
| 57 | |||||||||||
| 58 | The following description is taken from Mozilla documentation. | ||||||||||
| 59 | |||||||||||
| 60 | This class inherits all the method from L<HTTP::Promise::Headers::ContentSecurityPolicy> and implements the additional following ones. | ||||||||||
| 61 | |||||||||||
| 62 | The CSP L</report_uri> method should be used with this header, otherwise this class will be an expensive no-op interface. | ||||||||||
| 63 | |||||||||||
| 64 | Content-Security-Policy-Report-Only: default-src https:; report-uri /csp-violation-report-endpoint/ | ||||||||||
| 65 | |||||||||||
| 66 | =head1 METHODS | ||||||||||
| 67 | |||||||||||
| 68 | =head2 report_uri | ||||||||||
| 69 | |||||||||||
| 70 | This takes an uri where the report will be sent. See L<this Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri> for an example php script to use to get those reports. | ||||||||||
| 71 | |||||||||||
| 72 | =head1 THREAD-SAFETY | ||||||||||
| 73 | |||||||||||
| 74 | This module is thread-safe for all operations, as it operates on per-object state and uses thread-safe external libraries. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 AUTHOR | ||||||||||
| 77 | |||||||||||
| 78 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 79 | |||||||||||
| 80 | =head1 SEE ALSO | ||||||||||
| 81 | |||||||||||
| 82 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only> and also L<this documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri> | ||||||||||
| 83 | |||||||||||
| 84 | L<HTTP::Promise>, L<HTTP::Promise::Request>, L<HTTP::Promise::Response>, L<HTTP::Promise::Message>, L<HTTP::Promise::Entity>, L<HTTP::Promise::Headers>, L<HTTP::Promise::Body>, L<HTTP::Promise::Body::Form>, L<HTTP::Promise::Body::Form::Data>, L<HTTP::Promise::Body::Form::Field>, L<HTTP::Promise::Status>, L<HTTP::Promise::MIME>, L<HTTP::Promise::Parser>, L<HTTP::Promise::IO>, L<HTTP::Promise::Stream>, L<HTTP::Promise::Exception> | ||||||||||
| 85 | |||||||||||
| 86 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 87 | |||||||||||
| 88 | Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 89 | |||||||||||
| 90 | All rights reserved. | ||||||||||
| 91 | |||||||||||
| 92 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 93 | |||||||||||
| 94 | =cut | ||||||||||