[Rt-commit] rt branch 5.0/validator-ace-principal-check created. rt-5.0.4-20-g25e6cb3dad
BPS Git Server
git at git.bestpractical.com
Sun May 28 12:39:58 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/validator-ace-principal-check has been created
at 25e6cb3dad3b8ba81325c1b640b674f77d3ca8a6 (commit)
- Log -----------------------------------------------------------------
commit 25e6cb3dad3b8ba81325c1b640b674f77d3ca8a6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun May 28 15:38:36 2023 +0300
Add ACL.PrincipalId -> Principals.id check rt-validator
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index b731b04b90..bcc34b7599 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -245,6 +245,19 @@ foreach my $table ( qw(Users Groups) ) {
};
}
+push @CHECKS, "ACL -> Principals" => sub {
+ my $msg = "A record in ACL refers to a nonexistent record in Principals."
+ ." The script can delete the record in ACL table.";
+ return check_integrity(
+ 'ACL', 'PrincipalId' => 'Principals', 'id',
+ action => sub {
+ my $id = shift;
+ return unless prompt('Delete', $msg);
+ delete_record( 'ACL', $id );
+ },
+ );
+};
+
push @CHECKS, 'User <-> ACL equivalence group' => sub {
my $res = 1;
# from user to group
diff --git a/t/validator/ace.t b/t/validator/ace.t
new file mode 100644
index 0000000000..44137f4a8f
--- /dev/null
+++ b/t/validator/ace.t
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+RT::Test->db_is_valid;
+
+# ACE pointing to invalid Principal
+{
+ my $rv = $RT::Handle->dbh->do( "INSERT INTO ACL(PrincipalId, PrincipalType, RightName, ObjectType, ObjectId) VALUES(?, ?, ?, ?, ?)",
+ undef,
+ 1024*1024*1024, 'User', 'ARight', 'RT::Transaction', 1,
+ );
+ ok( $rv, 'inserted' );
+
+ my ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
+ isnt( $ecode, 0, 'non-zero exit code' );
+ like(
+ $res,
+ qr/ACL references a nonexistent record in Principals/,
+ 'Found/Fixed error of Transactions <-> CustomFields'
+ );
+ RT::Test->db_is_valid;
+}
+
+done_testing();
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list