Skip to content

Commit f56d7da

Browse files
committed
Merge branch '4.4.8-releng' into 4.4-trunk
2 parents a34a9a6 + 7335a09 commit f56d7da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2370
-2300
lines changed

etc/RT_Config.pm.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,26 @@ higher numbers denoting greater effort.
26332633

26342634
Set($BcryptCost, 12);
26352635

2636+
=item C<@RestrictLinkDomains>
2637+
2638+
This sets a list of external domains that RT is allowed to link to. If this
2639+
setting is empty, no external domains are allowed.
2640+
2641+
Currently, this restriction only applies to links in Format parameter for
2642+
search results. All external links whose domains are not in the list will
2643+
be removed.
2644+
2645+
E.g.
2646+
2647+
Set(@RestrictLinkDomains, ("example.com", "*.trusted.com"));
2648+
2649+
example.com # Allow links to "example.com"
2650+
*.trusted.com # Allow links to any one-level subdomain of "trusted.com"
2651+
2652+
=cut
2653+
2654+
Set(@RestrictLinkDomains, ());
2655+
26362656
=back
26372657

26382658

@@ -3150,6 +3170,9 @@ Set C<CheckRevocationDownloadTimeout> to the timeout in seconds for
31503170
downloading a CRL or an issuer certificate (the latter is used when
31513171
checking against OCSP). The default timeout is 30 seconds.
31523172

3173+
Set C<Cipher> to the encryption algorithm to use. By default, it's
3174+
C<aes-128-cbc>.
3175+
31533176
See L<RT::Crypt::SMIME> for details.
31543177

31553178
=back
@@ -3168,6 +3191,7 @@ Set( %SMIME,
31683191
CheckCRL => 0,
31693192
CheckOCSP => 0,
31703193
CheckRevocationDownloadTimeout => 30,
3194+
Cipher => 'aes-128-cbc',
31713195
);
31723196

31733197
=head2 GnuPG configuration

lib/RT/Crypt/SMIME.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ sub _SignEncrypt {
430430
$key = $key_file;
431431
}
432432
push @commands, [
433-
$self->OpenSSLPath, qw(smime -encrypt -des3),
433+
$self->OpenSSLPath, qw(smime -encrypt), '-' . ( $opts->{Cipher} || 'aes-128-cbc' ),
434434
map { $_->filename } @keys
435435
];
436436
}

lib/RT/Interface/Web.pm

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,12 +4611,20 @@ Removes unsafe and undesired HTML from the passed content
46114611
=cut
46124612

46134613
my $SCRUBBER;
4614+
my $RESTRICTIVE_SCRUBBER;
46144615
sub ScrubHTML {
46154616
my $Content = shift;
4616-
$SCRUBBER = _NewScrubber() unless $SCRUBBER;
4617+
my %args = @_;
46174618

46184619
$Content = '' if !defined($Content);
4619-
return $SCRUBBER->scrub($Content);
4620+
if ( $args{Restrictive} ) {
4621+
$RESTRICTIVE_SCRUBBER = _NewScrubber(Restrictive => 1) unless $RESTRICTIVE_SCRUBBER;
4622+
return $RESTRICTIVE_SCRUBBER->scrub($Content);
4623+
}
4624+
else {
4625+
$SCRUBBER = _NewScrubber() unless $SCRUBBER;
4626+
return $SCRUBBER->scrub($Content);
4627+
}
46204628
}
46214629

46224630
=head2 _NewScrubber
@@ -4698,7 +4706,45 @@ if (RT->Config->Get('ShowTransactionImages') or RT->Config->Get('ShowRemoteImage
46984706
$SCRUBBER_RULES{'img'}->{'src'} = join "|", @src;
46994707
}
47004708

4709+
our %RESTRICTIVE_SCRUBBER_RULES = (
4710+
a => {
4711+
%SCRUBBER_ALLOWED_ATTRIBUTES,
4712+
href => sub {
4713+
my ( $self, $tag, $attr, $href ) = @_;
4714+
return $href unless $href;
4715+
4716+
# Allow internal RT macros like __WebPath__, etc.
4717+
return $href if $href !~ /^\w+:/ && $href =~ $SCRUBBER_ALLOWED_ATTRIBUTES{'href'};
4718+
4719+
my $uri = URI->new($href);
4720+
unless ( $uri->can("host") && $uri->host ) {
4721+
RT->Logger->warn("Unknown link: $href");
4722+
return '';
4723+
}
4724+
4725+
my $rt_host = RT::Interface::Web::_NormalizeHost( RT->Config->Get('WebBaseURL') )->host;
4726+
my $host = lc $uri->host;
4727+
for my $allowed_domain ( $rt_host, @{ RT->Config->Get('RestrictLinkDomains') || [] } ) {
4728+
if ( $allowed_domain =~ /\*/ ) {
4729+
4730+
# Turn a literal * into a domain component or partial component match.
4731+
my $regex = join "[a-zA-Z0-9\-]*", map { quotemeta($_) }
4732+
split /\*/, $allowed_domain;
4733+
return $href if $host =~ /^$regex$/i;
4734+
}
4735+
else {
4736+
return $href if $host eq lc($allowed_domain);
4737+
}
4738+
}
4739+
4740+
RT->Logger->warning("Blocked link: $href");
4741+
return '';
4742+
},
4743+
},
4744+
);
4745+
47014746
sub _NewScrubber {
4747+
my %args = @_;
47024748
require HTML::Scrubber;
47034749
my $scrubber = HTML::Scrubber->new();
47044750

@@ -4726,7 +4772,7 @@ sub _NewScrubber {
47264772
);
47274773
$scrubber->deny(qw[*]);
47284774
$scrubber->allow(@SCRUBBER_ALLOWED_TAGS);
4729-
$scrubber->rules(%SCRUBBER_RULES);
4775+
$scrubber->rules( %SCRUBBER_RULES, $args{Restrictive} ? %RESTRICTIVE_SCRUBBER_RULES : () );
47304776

47314777
# Scrubbing comments is vital since IE conditional comments can contain
47324778
# arbitrary HTML and we'd pass it right on through.

share/html/Asset/Elements/TSVExport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ require HTML::Entities;
5858

5959
$r->content_type('application/vnd.ms-excel');
6060

61-
my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format);
61+
my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format, Restrictive => 1);
6262

6363
my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
6464

share/html/Elements/CollectionList

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ $Collection->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
9393
$DisplayFormat ||= $Format;
9494

9595
# Scrub the html of the format string to remove any potential nasties.
96-
$Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
97-
$DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat);
96+
$Format = $m->comp('/Elements/ScrubHTML', Content => $Format, Restrictive => 1);
97+
$DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat, Restrictive => 1);
9898

9999
my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
100100

share/html/Elements/ScrubHTML

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
%#
4747
%# END BPS TAGGED BLOCK }}}
4848
<%init>
49-
return ScrubHTML($Content);
49+
return ScrubHTML($Content, %ARGS);
5050
</%init>
5151
<%args>
5252
$Content => undef

share/html/Elements/TSVExport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ $Class ||= $Collection->ColumnMapClassName;
6262
$r->content_type('application/vnd.ms-excel');
6363
$r->header_out( 'Content-disposition' => "attachment; filename=$Filename" ) if $Filename;
6464

65-
my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format);
65+
my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format, Restrictive => 1);
6666

6767
my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
6868

share/html/Search/Build.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
}
160160
if ( $query{'Format'} ) {
161161
# Clean unwanted junk from the format
162-
$query{'Format'} = $m->comp( '/Elements/ScrubHTML', Content => $query{'Format'} );
162+
$query{'Format'} = $m->comp( '/Elements/ScrubHTML', Content => $query{'Format'}, Restrictive => 1 );
163163
}
164164
}
165165

share/html/Search/Edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<%INIT>
6666
my $title = loc("Edit Query");
67-
$Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
67+
$Format = $m->comp('/Elements/ScrubHTML', Content => $Format, Restrictive => 1);
6868
my $QueryString = $m->comp('/Elements/QueryString',
6969
Query => $Query,
7070
Format => $Format,

0 commit comments

Comments
 (0)