Thanks to visit codestin.com
Credit goes to github.com

Skip to content

vet: adds a check to disallow usage of regex.Compile in xDS code - #9216

Merged
eshitachandwani merged 6 commits into
grpc:masterfrom
eshitachandwani:compile_vet_sh
Jul 3, 2026
Merged

vet: adds a check to disallow usage of regex.Compile in xDS code#9216
eshitachandwani merged 6 commits into
grpc:masterfrom
eshitachandwani:compile_vet_sh

Conversation

@eshitachandwani

@eshitachandwani eshitachandwani commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fixes : #9153
This PR adds a check to disallow usage of regex.Compile in xDS code.
Excludes the following from check :

  • all test files
  • internal/xds/matcher/string_matcher.go : because this is where SafeRegex function lives
  • unmarshal_rds.go - becuase hashPoliciesProtoToSlice needs to use it becuase it requires partial matches too , to replace the substring.

RELEASE NOTES: None

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (484f150) to head (1c65fad).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9216      +/-   ##
==========================================
- Coverage   83.19%   83.16%   -0.04%     
==========================================
  Files         420      420              
  Lines       34010    34024      +14     
==========================================
  Hits        28295    28295              
- Misses       4281     4288       +7     
- Partials     1434     1441       +7     

see 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eshitachandwani

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a static analysis check in scripts/vet.sh to prevent direct calls to regexp.Compile in xDS production code. The reviewer suggested extending this check to also disallow regexp.MustCompile to ensure complete safety, providing a code suggestion to implement this using git grep's -e and --or flags.

Comment thread scripts/vet.sh
@eshitachandwani eshitachandwani assigned arjan-bal and mbissa and unassigned arjan-bal Jul 2, 2026
@eshitachandwani
eshitachandwani removed the request for review from arjan-bal July 2, 2026 10:26

@arjan-bal arjan-bal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread scripts/vet.sh Outdated
Comment on lines +93 to +94


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A single blank line is sufficient for vertical separation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added by mistake. Cleaned it up. Thank you!

@arjan-bal arjan-bal assigned eshitachandwani and unassigned mbissa Jul 3, 2026
@eshitachandwani
eshitachandwani merged commit 1a80fca into grpc:master Jul 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github: Add vet.sh rule to restrict direct regexp.Compile calls in xDS code

3 participants