Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This auto-generated code raises issue with SAST tools #21024

Open
avl42 opened this issue Apr 3, 2025 · 0 comments
Open

This auto-generated code raises issue with SAST tools #21024

avl42 opened this issue Apr 3, 2025 · 0 comments

Comments

@avl42
Copy link

avl42 commented Apr 3, 2025

I'm aware that the reference below points to generated code, and the culprit is whereever this code gets generated.

SonarQube correctly criticizes the approach as unnecessarily slow.

What should it do:

  • replace the longest prefix that ends in either / or \ by empty string.

What it really does:

  • the right thing, as above, but then also:
  • for each character position of the remaining base filename try to find another / or \
    that means if the basename has 100 characters it will try to re-match the regexp on 99 starting points.

My suggestion is to change the generator itself, such that the referenced line gets created that way, instead:

return filename.replaceFirst("^.*[/\\\\]", "");

I hope it makes sense and that others more into the codebase will find the relevant template or generating location instantly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant