Skip to content

Commit cdcbc71

Browse files
dylanwhdklawrenglobauemceeaichLissetCuevas
authored
bmo sync - 2020-08-23 (#49)
* Bug 1646559 - Phabricator to BMO OAuth2 authentication fails to work properly due to CSP protections * Bumped version to 20200624.1 * no bug - fix broken build script when no new commits to master since last prod deploy * no bug - remove warning "Odd number of elements" The callback jwt_claims is called in list context. Without an explicit return, when the if (!...) does not match it will return a single false item. This causes the "Odd number of elements..." perl warning. Adding a `return` will prevent the warning and is also probably the intent of the code. * Bug 1645768 - Please add 'See Also' support for GitLab * no bug - Updated tasks.json to include some admin tasks * no bug - Fix build data script to help find the Mozilla CA cert * Bug 1651591 - remove preloading of fonts and ga; r=dkl Font preloading has been broken for more than a year, and doesn't appear to work correctly even when provided URLs which exist; removed. google-analytics likely does little to improve page load time performance against all the other assets, is loaded async, and exists outside of the GoogleAnalytics making it easy to miss when updating that extension (eg. the preloading doesn't honour DNT); also removed. * Bug 1535000 - Allow anyone with edit-comments to edit any bug's comment 0 * Bug 1652863 - setting the needinfo flag when filing a new bug in Core or Toolkit does not cause the textbox for user information to pop up * Bumped version 20200722.1 * Bug 1647642 - when commenting on patch or reviewing one, bugzilla clears other (review, ui-review) flags * Bumped version to 20200723.1 * Bug 1643526 - Attachment comments don't render markdown, but their preview does * Bug 1654456 - needinfo? request email enhancements (#1594) * Start WIP PR * Modify default need info text * Fix breaking bugwords.t * You have to fix all the instances of the word. * Adding conditional for needinfo to reporter * fix failing bugwords.t again * Don't divert people with questions to bmo team * don't repeat bug url * fix terms.bug * Remove 'to see question,' question is in email * Keep the link to the bug * move text into a conditional branch * link to needinfo docs * Bug 1654370 - Remove remaining code that references Firefox OS from BMO code base * Bug 1655808: send users in guided bug flow to GitHub for Android and iOS bug reports (#1600) * Move all the products to the product template * Link mobile products to GitHub * Better boilerplate text * Fix failing terms test * no bug - Use standard docker mysql for docker-compose instead of bmo-mysql * no bug - Updated docker-compose.test.yml for mysql settings in CircleCI environment. * Bumped version to 20200805.1 * Bug 1657542 - During recent bmo deployment, emails were delivered to a file instead of SES which caused interruption of email service * Bug 1658622 - "product responsibilities" on editusers should include Triage Owner * Bug 1588661 - Design for Webhooks * Bug 1659177 - Replace mozillians.org with people.mozilla.org in Reps Mentorship Form * Bug 1649841 - Include data-review? requests in notification count * Bug 1658317 - Make scopes more descriptive and user friendly when authenticating to BMO using OAuth2 * Bug 1656609: Make <html> the scrolling element * Bug 1657778 - Offer link to Bugzilla for filing security issues in Fenix and iOS * no bug - Show Bounty Attachments to the Bug Reporter This will allow most bug bounty recipients to view the amount of their bounty. It will not show it to reporters if we filed the bug for them, however those are less liekly to be repeat filers. * Bug 1658846 - Allow users to enable and disable their webhooks Co-authored-by: dklawren <dklawren@users.noreply.github.com> Co-authored-by: byron jones <byron@glob.com.au> Co-authored-by: Emma Humphries <emceeaich@users.noreply.github.com> Co-authored-by: David Lawrence <dkl@mozilla.com> Co-authored-by: Lisset Cuevas <lisset.cuevasj@gmail.com> Co-authored-by: Michael Kohler <me@michaelkohler.info> Co-authored-by: Tom Ritter <tom@ritter.vg>
1 parent 2b12b90 commit cdcbc71

File tree

72 files changed

+1550
-281
lines changed

Some content is hidden

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

72 files changed

+1550
-281
lines changed

.vscode/tasks.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
"isDefault": true
2020
},
2121
"problemMatcher": []
22-
}
22+
},
23+
{
24+
"label": "Docker: Generate new cpanfile and cpanfile.snapshot",
25+
"type": "shell",
26+
"command": "docker build -t bmo-cpanfile -f Dockerfile.cpanfile . ; docker run -it -v $(pwd):/app/result bmo-cpanfile cp cpanfile cpanfile.snapshot /app/result",
27+
"group": "none",
28+
"problemMatcher": []
29+
},
30+
{
31+
"label": "Docker: Generate mozillabteam/bmo-perl-slim image",
32+
"type": "shell",
33+
"command": "docker build -t mozillabteam/bmo-perl-slim:$(date +%Y%m%d.1) -f Dockerfile.bmo-slim .",
34+
"group": "none",
35+
"problemMatcher": []
36+
},
2337
]
2438
}

Bugzilla.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use warnings;
1313

1414
use Bugzilla::Logging;
1515

16-
our $VERSION = '20200603.1';
16+
our $VERSION = '20200805.1';
1717

1818
use Bugzilla::Auth;
1919
use Bugzilla::Auth::Persist::Cookie;

Bugzilla/App/Plugin/OAuth2.pm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sub register {
4040
if (!$args->{user_id}) {
4141
return (user_id => Bugzilla->user->id);
4242
}
43+
return;
4344
};
4445

4546
$app->helper(
@@ -81,6 +82,7 @@ sub _resource_owner_confirm_scopes {
8182
my (%args) = @_;
8283
my ($c, $client_id, $scopes_ref)
8384
= @args{qw/ mojo_controller client_id scopes /};
85+
my $dbh = Bugzilla->dbh;
8486

8587
$c->bugzilla->login(LOGIN_REQUIRED) || return undef;
8688

@@ -90,12 +92,18 @@ sub _resource_owner_confirm_scopes {
9092
# access last time, we check [again] with the user for access
9193
if (!defined $is_allowed) {
9294
my $client
93-
= Bugzilla->dbh->selectrow_hashref(
94-
'SELECT * FROM oauth2_client WHERE client_id = ?',
95+
= $dbh->selectrow_hashref('SELECT * FROM oauth2_client WHERE client_id = ?',
9596
undef, $client_id);
97+
my $scopes = $dbh->selectall_arrayref(
98+
'SELECT * FROM oauth2_scope WHERE name IN ('
99+
. join(',', map { $dbh->quote($_) } @{$scopes_ref}) . ')',
100+
{Slice => {}}
101+
);
102+
103+
96104
my $vars = {
97105
client => $client,
98-
scopes => $scopes_ref,
106+
scopes => $scopes,
99107
token => scalar issue_session_token('oauth_confirm_scopes')
100108
};
101109
$c->stash(%{$vars});

Bugzilla/Attachment.pm

100644100755
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,20 @@ sub get_attachments_by_bug {
542542
my $dbh = Bugzilla->dbh;
543543

544544
# By default, private attachments are not accessible, unless the user
545-
# is in the insider group or submitted the attachment.
545+
# is in the insider group, submitted the attachment, or it's a bounty
546+
# attachment and they reported the bug.
546547
my $and_restriction = '';
547548
my @values = ($bug->id);
548549

549550
unless ($user->is_insider) {
550-
$and_restriction = 'AND (isprivate = 0 OR submitter_id = ?)';
551+
$and_restriction = 'AND (isprivate = 0 OR submitter_id = ?';
551552
push(@values, $user->id);
553+
if ($user->id == $bug->reporter->id) {
554+
# Keep these conditions in sync with _attachment_is_bounty_attachment
555+
# in extensions/BMO/Extension.pm
556+
$and_restriction .= " OR (filename = 'bugbounty.data' AND mimetype = 'text/plain')";
557+
}
558+
$and_restriction .= ')';
552559
}
553560

554561
# BMO - allow loading of just non-obsolete attachments

Bugzilla/BugUrl/GitLab.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use base qw(Bugzilla::BugUrl);
2020
sub should_handle {
2121
my ($class, $uri) = @_;
2222

23-
# GitLab issue URLs can have the form:
24-
# https://gitlab.com/projectA/subprojectB/subprojectC/../issues/53
25-
return ($uri->path =~ m!^/.*/issues/\d+$!) ? 1 : 0;
23+
# GitLab issue and merge request URLs can have the form:
24+
# https://gitlab.com/projectA/subprojectB/subprojectC/../(issues|merge_requests)/53
25+
return ($uri->path =~ m!^/.*/(issues|merge_requests)/\d+$!) ? 1 : 0;
2626
}
2727

2828
sub _check_value {

Bugzilla/CGI.pm

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -410,26 +410,6 @@ sub header {
410410

411411
$self->{_header_done} = 1;
412412

413-
if (Bugzilla->usage_mode == USAGE_MODE_BROWSER) {
414-
my @fonts = (
415-
"skins/standard/fonts/FiraMono-Regular.woff2?v=3.202",
416-
"skins/standard/fonts/FiraSans-Bold.woff2?v=4.203",
417-
"skins/standard/fonts/FiraSans-Italic.woff2?v=4.203",
418-
"skins/standard/fonts/FiraSans-Regular.woff2?v=4.203",
419-
"skins/standard/fonts/FiraSans-SemiBold.woff2?v=4.203",
420-
"skins/standard/fonts/MaterialIcons-Regular.woff2",
421-
);
422-
$headers{'-link'} = join(
423-
", ",
424-
map {
425-
sprintf('</static/v%s/%s>; rel="preload"; as="font"', Bugzilla->VERSION, $_)
426-
} @fonts
427-
);
428-
if (Bugzilla->params->{google_analytics_tracking_id}) {
429-
$headers{'-link'}
430-
.= ', <https://www.google-analytics.com>; rel="preconnect"; crossorigin';
431-
}
432-
}
433413
my $headers = $self->SUPER::header(%headers) || '';
434414
if ($self->server_software eq 'Bugzilla::App::CGI') {
435415
my $c = $Bugzilla::App::CGI::C;

Bugzilla/Constants.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ sub DEFAULT_CSP {
789789
'https://github.com/login';
790790
}
791791

792+
# This is for Mozilla Phabricator and authentication
793+
if (Bugzilla->params->{phabricator_enabled}) {
794+
push @{$policy{form_action}}, Bugzilla->params->{phabricator_base_uri};
795+
}
796+
792797
return %policy;
793798
}
794799

Bugzilla/DB/Schema.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,12 @@ use constant ABSTRACT_SCHEMA => {
18511851
oauth2_scope => {
18521852
FIELDS => [
18531853
id => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
1854-
description => {TYPE => 'varchar(255)', NOTNULL => 1},
1854+
name => {TYPE => 'varchar(255)', NOTNULL => 1},
1855+
description => {TYPE => 'TINYTEXT', NOTNULL => 1},
1856+
],
1857+
INDEXES => [
1858+
oauth2_scope_idx =>
1859+
{FIELDS => ['name'], TYPE => 'UNIQUE'},
18551860
],
18561861
},
18571862

Bugzilla/Install/DB.pm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,8 +4262,19 @@ sub _populate_oauth2_scopes {
42624262

42634263
# if there are no scopes, then we're creating a database from scratch
42644264
my ($scope_count) = $dbh->selectrow_array('SELECT COUNT(*) FROM oauth2_scope');
4265-
return if $scope_count;
4266-
$dbh->do("INSERT INTO oauth2_scope (id, description) VALUES (1, 'user:read')");
4265+
if (!$scope_count) {
4266+
$dbh->do(
4267+
"INSERT INTO oauth2_scope (id, name, description) VALUES " .
4268+
"(1, 'user:read', 'View basic account information such as email address.')"
4269+
);
4270+
}
4271+
4272+
# Bug 1658317 - dkl@mozilla - Update column names if this is an existing DB
4273+
if (!$dbh->bz_column_info('oauth2_scope', 'name')) {
4274+
$dbh->bz_rename_column("oauth2_scope", "description", "name");
4275+
$dbh->bz_add_column('oauth2_scope', 'description',
4276+
{TYPE => 'TINYTEXT', NOTNULL => 1, DEFAULT => "'Needs Description'"});
4277+
}
42674278
}
42684279

42694280
sub _add_oauth2_jwt_support {

Bugzilla/Test/Util.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ sub create_oauth_client {
5959

6060
foreach my $scope (@{$scopes}) {
6161
my $scope_id
62-
= $dbh->selectrow_array('SELECT id FROM oauth2_scope WHERE description = ?',
62+
= $dbh->selectrow_array('SELECT id FROM oauth2_scope WHERE name = ?',
6363
undef, $scope);
6464
if (!$scope_id) {
6565
die "Scope $scope not found";

0 commit comments

Comments
 (0)