From e8326e76a6e8f904d0f7479f38ec4eaa22797c75 Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Wed, 1 Jul 2026 17:14:38 +0800 Subject: [PATCH] fix(ecstore): harden replication runtime guard (#4132) --- scripts/check_architecture_migration_rules.sh | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/check_architecture_migration_rules.sh b/scripts/check_architecture_migration_rules.sh index 751d3157c..eab6ffbc7 100755 --- a/scripts/check_architecture_migration_rules.sh +++ b/scripts/check_architecture_migration_rules.sh @@ -2627,21 +2627,25 @@ fi $source = blank_block_comments($source); $source =~ s{//[^\n]*}{blank($&)}eg; - for my $statement (split /;/, $source) { + while ($source =~ /([^;]+)(?:;|$)/g) { + my $statement_start = $-[1]; + my $statement = $1; my $normalized = $statement; $normalized =~ s/\s+//g; my $hits_ecstore = - $normalized =~ /\bECStore\b/ - && $normalized =~ /crate::(?:store(?:::|::\{)|\{.*store(?:::|::\{))/s; + $normalized =~ /\bECStore(?:\b|as)/ + && $normalized =~ /crate::(?:store::\{?|\{.*store::\{?)/s; my $hits_monitor = - $normalized =~ /\bMonitor\b/ - && $normalized =~ /crate::(?:bucket(?:::|::\{)|\{.*bucket(?:::|::\{))/s - && $normalized =~ /bucket(?:::|::\{).*bandwidth(?:::|::\{).*monitor(?:::|::\{)/s; + $normalized =~ /\bMonitor(?:\b|as)/ + && $normalized =~ /crate::(?:bucket::\{?|\{.*bucket::\{?)/s + && $normalized =~ /bucket::\{?.*bandwidth::\{?.*monitor::\{?/s; if ($hits_ecstore || $hits_monitor) { - my $prefix = substr($source, 0, index($source, $statement)); - my $line = ($prefix =~ tr/\n//) + 1; + my $leading = $statement; + $leading =~ s/^(\s*).*$/$1/s; + my $prefix = substr($source, 0, $statement_start); + my $line = ($prefix =~ tr/\n//) + ($leading =~ tr/\n//) + 1; $normalized =~ s/\s+/ /g; print "$ARGV:$line:$normalized\n"; }