Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/check-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ jobs:
id: filter
with:
filters: |
subscriptions_holder: subscriptions_holder/src
t_coubs_initiator: t_coubs_initiator/src
coub_smart_searcher: coub_smart_searcher/src
kafka_message_producer: kafka_message_producer/src
kafka_message_consumer: kafka_message_consumer/src
telegram_bot: telegram_bot/src
subscriptions_scheduler: subscriptions_scheduler/src
subscriptions_holder:
- 'subscriptions_holder/src/**'
t_coubs_initiator:
- 't_coubs_initiator/src/**'
coub_smart_searcher:
- 'coub_smart_searcher/src/**'
kafka_message_producer:
- 'kafka_message_producer/src/**'
kafka_message_consumer:
- 'kafka_message_consumer/src/**'
telegram_bot:
- 'telegram_bot/src/**'
subscriptions_scheduler:
- 'subscriptions_scheduler/src/**'
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ public class SearchCriteriaParserImpl implements SearchCriteriaParser {
@Override
public List<SearchCriteria> parse(String search) {
List<SearchCriteria> params = new ArrayList<>();
if (search != null) {
Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),");
Matcher matcher = pattern.matcher(search + ",");
while (matcher.find()) {
params.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3)));
}

if (search == null || !isValidString(search) || search.length() > 1000) {
throw new IllegalArgumentException("Invalid search criteria");
}

search = search + ",";

Pattern pattern = Pattern.compile("(\\w+?)([:<>])(\\w+?),");
Matcher matcher = pattern.matcher(search);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on a [user-provided value](2) may run slow on strings with many repetitions of 'a'.

while (matcher.find()) {
params.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3)));
}

return params;
}

private boolean isValidString(String str) {
return str != null && !str.isEmpty() && str.matches("[a-zA-Z0-9][:<>],");
}
}