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

deleting multiline comments does not work correctly #43

Open
Skripko-Ivan opened this issue May 23, 2024 · 3 comments
Open

deleting multiline comments does not work correctly #43

Skripko-Ivan opened this issue May 23, 2024 · 3 comments

Comments

@Skripko-Ivan
Copy link

Libsast pattern for deleting multiline comment ("/*([\S|\s]+?)*/") will delete code if it will find "/" in constant string. For example:
uriMatcher.addURI(PROVIDER_NAME, "users/
", 1);

@ajinabraham
Copy link
Owner

What version of libast are you using? This is the comment detection regex: https://github.com/ajinabraham/libsast/blob/09165d63062312b6ecfef6fb96177851030c9d42/libsast/core_matcher/helpers.py#L18C26-L18C43

@Skripko-Ivan
Copy link
Author

Skripko-Ivan commented May 23, 2024

Github delete some symbols from my issue text.
Correct issue text:
Libsast pattern for deleting multiline comment ("/\*([\S|\s]+?)\*/") will delete code if it will find "/*" in constant string. For example:
uriMatcher.addURI(PROVIDER_NAME, "users/*", 1);
test = 2;
/* comment */
As result, it will delete:
/*", 1);
test = 2;
/* comment */

@ajinabraham
Copy link
Owner

Yeah this is a limitation of regex based approach,
It will match

/*", 1);
test = 2;
/* comment */

Regex matches are are quick pattern lookups. You should use a semgrep rule with libsast instead to get better AST based look up.

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

2 participants