Skip to content

Commit

Permalink
Merge branch 'main' into testsuite-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow authored Dec 10, 2021
2 parents 775d422 + cdac219 commit 23e3bd3
Show file tree
Hide file tree
Showing 85 changed files with 516 additions and 10,466 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
name: Release Tests

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# events but only for the main branch
on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -33,9 +35,11 @@ jobs:
sudo apt-get install --ignore-hold --allow-downgrades -y \
build-essential curl libssl-dev zlib1g-dev openssl \
libexpat-dev cmake git libcairo-dev libgd-dev \
default-libmysqlclient-dev unzip wget libgd3=2.2.5-5.2ubuntu2
default-libmysqlclient-dev unzip wget libgd3
- name: cpm install
run: |
perl Makefile.PL
#make cpanfile GEN_CPANFILE_ARGS='-A'
perl -I$GITHUB_WORKSPACE/.github/cpm/lib/perl5 $GITHUB_WORKSPACE/.github/cpm/bin/cpm install \
&& tar -C $GITHUB_WORKSPACE \
--exclude 'local/cache/*' \
Expand Down
30 changes: 0 additions & 30 deletions Bugzilla.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ our $VERSION = '20200805.1';
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
use Bugzilla::CGI;
use Bugzilla::Elastic;
use Bugzilla::Config;
use Bugzilla::Constants;
use Bugzilla::DB;
Expand Down Expand Up @@ -218,33 +217,9 @@ sub github_secret {
return $cache->{github_secret};
}

sub passwdqc {
my ($class) = @_;
require Data::Password::passwdqc;

my $cache = request_cache;
my $params = $class->params;

return $cache->{passwdqc} if $cache->{passwdqc};

my @min = map { $_ eq 'undef' ? undef : $_ }
split(/\s*,\s*/, $params->{passwdqc_min});

return $cache->{passwdqc} = Data::Password::passwdqc->new(
min => \@min,
max => $params->{passwdqc_max},
passphrase_words => $params->{passwdqc_passphrase_words},
match_length => $params->{passwdqc_match_length},
random_bits => $params->{passwdqc_random_bits},
);
}

sub assert_password_is_secure {
my ($class, $password1) = @_;

my $pwqc = $class->passwdqc;
ThrowUserError('password_insecure', {reason => $pwqc->reason})
unless $pwqc->validate_password($password1);
}

sub assert_passwords_match {
Expand Down Expand Up @@ -766,11 +741,6 @@ sub datadog {
}
}

sub elastic {
my ($class) = @_;
$class->process_cache->{elastic} //= Bugzilla::Elastic->new();
}

sub check_rate_limit {
my ($class, $name, $ip, $throw_error) = @_;
$throw_error //= sub { ThrowUserError("rate_limit") };
Expand Down
9 changes: 6 additions & 3 deletions Bugzilla/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Bugzilla::App::BouncedEmails;
use Bugzilla::App::CGI;
use Bugzilla::App::Main;
use Bugzilla::App::Users;
use Bugzilla::App::OAuth2::Clients;
use if Bugzilla->has_feature('oauth2_server'), 'Bugzilla::App::OAuth2::Clients';
use Bugzilla::App::SES;
use Bugzilla::App::Static;
use Mojo::Loader qw( find_modules );
Expand All @@ -52,7 +52,9 @@ sub startup {
unless $ENV{BUGZILLA_DISABLE_SIZELIMIT};
$self->plugin('ForwardedFor') if Bugzilla->has_feature('better_xff');
$self->plugin('Bugzilla::App::Plugin::Helpers');
$self->plugin('Bugzilla::App::Plugin::OAuth2');
if (Bugzilla->has_feature('oauth2_server')) {
$self->plugin('Bugzilla::App::Plugin::OAuth2');
}

push @{$self->commands->namespaces}, 'Bugzilla::App::Command';
push @{$self->renderer->paths}, @{ Bugzilla::Template::_include_path() };
Expand Down Expand Up @@ -191,7 +193,8 @@ sub setup_routes {
Bugzilla::App::CGI->setup_routes($r);
Bugzilla::App::Main->setup_routes($r);
Bugzilla::App::Users->setup_routes($r);
Bugzilla::App::OAuth2::Clients->setup_routes($r);
Bugzilla::App::OAuth2::Clients->setup_routes($r)
if Bugzilla->has_feature('oauth2_server');
Bugzilla::App::SES->setup_routes($r);

$r->static_file('/__lbheartbeat__');
Expand Down
17 changes: 0 additions & 17 deletions Bugzilla/Auth/Verify/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,6 @@ sub check_credentials {
};
}

# Force the user to change their password if it does not meet the current
# criteria. This should usually only happen if the criteria has changed.
if ( Bugzilla->usage_mode == USAGE_MODE_BROWSER
&& Bugzilla->params->{password_check_on_login})
{
my $pwqc = Bugzilla->passwdqc;
unless ($pwqc->validate_password($password)) {
my $reason = $pwqc->reason;
Bugzilla->audit(sprintf "%s logged in with a weak password (reason: %s)",
$user->login, $reason);
$user->set_password_change_required(1);
$user->set_password_change_reason(
"You must change your password for the following reason: $reason");
$user->update();
}
}

# The user's credentials are okay, so delete any outstanding
# password tokens or login failures they may have generated.
Bugzilla::Token::DeletePasswordTokens($user->id, "user_logged_in");
Expand Down
161 changes: 0 additions & 161 deletions Bugzilla/Bug.pm
Original file line number Diff line number Diff line change
Expand Up @@ -321,66 +321,6 @@ sub BUG_FILE_METHODS {
return @methods;
}

with 'Bugzilla::Elastic::Role::Object';

sub ES_TYPE {'bug'}

sub ES_INDEX { Bugzilla->params->{elasticsearch_index} }

sub ES_SETTINGS {
return {
number_of_shards => 2,
analysis => {
filter => {
asciifolding_original => {type => "asciifolding", preserve_original => \1,},
},
analyzer => {
autocomplete => {
type => 'custom',
tokenizer => 'keyword',
filter => ['lowercase', 'asciifolding_original'],
},
folding => {
tokenizer => 'standard',
filter => ['standard', 'lowercase', 'asciifolding_original'],
},
bz_text_analyzer => {
type => 'standard',
filter => ['lowercase', 'stop'],
max_token_length => '20'
},
bz_equals_analyzer =>
{type => 'custom', filter => ['lowercase'], tokenizer => 'keyword',},
whiteboard_words => {
type => 'custom',
tokenizer => 'whiteboard_words_pattern',
filter => ['stop']
},
whiteboard_shingle_words => {
type => 'custom',
tokenizer => 'whiteboard_words_pattern',
filter => ['stop', 'shingle', 'lowercase']
},
whiteboard_tokens => {
type => 'custom',
tokenizer => 'whiteboard_tokens_pattern',
filter => ['stop', 'lowercase']
},
whiteboard_shingle_tokens => {
type => 'custom',
tokenizer => 'whiteboard_tokens_pattern',
filter => ['stop', 'shingle', 'lowercase']
}
},
tokenizer => {
whiteboard_tokens_pattern =>
{type => 'pattern', pattern => '\\s*([,;]*\\[|\\][\\s\\[]*|[;,])\\s*'},
whiteboard_words_pattern => {type => 'pattern', pattern => '[\\[\\];,\\s]+'},
},
},
};
}

sub _bz_field {
my ($field, @fields) = @_;

Expand All @@ -394,107 +334,6 @@ sub _bz_field {
);
}

sub ES_PROPERTIES {
return {
_bz_field('priority'), _bz_field('bug_severity'), _bz_field('bug_status'),
_bz_field('resolution'), _bz_field('bug_type'),
status_whiteboard =>
{type => 'string', analyzer => 'whiteboard_shingle_tokens'},
delta_ts => {type => 'string', index => 'not_analyzed'},
_bz_field('product'), _bz_field('component'), _bz_field('classification'),
_bz_field('short_desc'), _bz_field('assigned_to'), _bz_field('reporter'),
};
}

sub ES_OBJECTS_AT_ONCE {4000}

sub ES_SELECT_UPDATED_SQL {
my ($class, $mtime) = @_;

my @fields = (
'keywords', 'short_desc', 'product', 'component',
'cf_crash_signature', 'alias', 'status_whiteboard', 'bug_status',
'resolution', 'priority', 'assigned_to', 'bug_type'
);
my $fields = join(', ', ("?") x @fields);

my $sql = qq{
SELECT DISTINCT
bug_id
FROM
bugs_activity
JOIN
fielddefs ON fieldid = fielddefs.id
WHERE
bug_when > FROM_UNIXTIME(?)
AND fielddefs.name IN ($fields)
UNION SELECT DISTINCT
bug_id
FROM
audit_log
JOIN
bugs ON bugs.assigned_to = object_id
WHERE
class = 'Bugzilla::User'
AND at_time > FROM_UNIXTIME(?)
UNION SELECT DISTINCT
bug_id
FROM
audit_log
JOIN
bugs ON bugs.product_id = object_id
WHERE
class = 'Bugzilla::Product'
AND field = 'name'
AND at_time > FROM_UNIXTIME(?)
UNION SELECT DISTINCT
bug_id
FROM
audit_log
JOIN
bugs ON bugs.component_id = object_id
WHERE
class = 'Bugzilla::Component'
AND field = 'name'
AND at_time > FROM_UNIXTIME(?)
UNION SELECT DISTINCT
bug_id
FROM
audit_log
JOIN
products ON classification_id = object_id
JOIN
bugs ON product_id = products.id
WHERE
class = 'Bugzilla::Classification'
AND field = 'name'
AND at_time > FROM_UNIXTIME(?)
};
return ($sql, [$mtime, @fields, $mtime, $mtime, $mtime, $mtime]);
}

sub es_document {
my ($self) = @_;
return {
bug_id => $self->id,
product => $self->product_obj->name,
alias => $self->alias,
keywords => [map { $_->name } @{$self->keyword_objects}],
priority => $self->priority,
bug_status => $self->bug_status,
resolution => $self->resolution,
component => $self->component_obj->name,
classification => $self->product_obj->classification->name,
status_whiteboard => $self->status_whiteboard,
short_desc => $self->short_desc,
assigned_to => $self->assigned_to->login,
reporter => $self->reporter->login,
delta_ts => $self->delta_ts,
bug_severity => $self->bug_severity,
bug_type => $self->bug_type,
};
}

#####################################################################

sub new {
Expand Down
50 changes: 0 additions & 50 deletions Bugzilla/Comment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,56 +82,6 @@ use constant VALIDATOR_DEPENDENCIES => {
isprivate => ['who'],
};

with 'Bugzilla::Elastic::Role::ChildObject';

use constant ES_TYPE => 'comment';
use constant ES_PARENT_CLASS => 'Bugzilla::Bug';

sub ES_OBJECTS_AT_ONCE {50}

sub ES_PROPERTIES {
return {
body => {type => "string", analyzer => 'bz_text_analyzer'},
is_private => {type => "boolean"},
tags => {type => "string"},
};
}

sub ES_SELECT_UPDATED_SQL {
my ($class, $mtime) = @_;

my $sql = q{
SELECT DISTINCT
comment_id
FROM
bugs_activity AS event
JOIN
fielddefs ON fieldid = fielddefs.id
WHERE
fielddefs.name = 'longdescs.isprivate'
AND bug_when > FROM_UNIXTIME(?)
UNION SELECT DISTINCT
comment_id
FROM
longdescs_activity
WHERE
change_when > FROM_UNIXTIME(?)
};
return ($sql, [$mtime, $mtime]);
}

sub es_parent_id {
my ($self) = @_;

return $self->ES_PARENT_CLASS->ES_TYPE . '_' . $self->bug_id,;
}

sub es_document {
my ($self) = @_;

return {body => $self->body, is_private => $self->is_private,};
}

#########################
# Database Manipulation #
#########################
Expand Down
12 changes: 12 additions & 0 deletions Bugzilla/DB/Mysql.pm
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,18 @@ sub bz_setup_database {
}
}

sub bz_server_version {
my ($self) = @_;
my $version = $self->SUPER::bz_server_version();

warn "VERSION: $version";
if ($version =~ /MariaDB/) {
(undef, $version) = split(/-/, $version);
}

return $version;
}

# When you import a MySQL 3/4 mysqldump into MySQL 5, columns that
# aren't supposed to have defaults will have defaults. This is only
# a minor issue, but it makes our tests fail, and it's good to keep
Expand Down
Loading

0 comments on commit 23e3bd3

Please sign in to comment.