Skip to content

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

Open
@avl42

Description

@avl42

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions