Skip to content

Conversation

shantyk
Copy link
Contributor

@shantyk shantyk commented Jun 10, 2025

Resolves IDETECT-4738

Scope of this PR is limited to detect.binary.scan.file.name.patterns, for which the official docs say:

Screenshot 2025-09-05 at 11 56 49 By default, WildcardFileFilter is case sensitive. This was updated for this specific property only and all other uses of the test() method in the widely used file filter class have been left as is.

@shantyk shantyk changed the title Two potential options for fixing IDETECT-4738 IDETECT-4738: Make detect.binary.scan.file.name.patterns case insensitive Aug 29, 2025
@shantyk shantyk self-assigned this Sep 4, 2025
@shantyk shantyk marked this pull request as ready for review September 4, 2025 15:05
@shantyk shantyk marked this pull request as draft September 4, 2025 20:41
@shantyk shantyk marked this pull request as ready for review September 5, 2025 19:09
import org.apache.commons.io.filefilter.WildcardFileFilter;

public class DetectDirectoryFileFilter implements Predicate<File> {
Copy link
Contributor

@andrian-sevastyanov andrian-sevastyanov Sep 8, 2025

Choose a reason for hiding this comment

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

Minor, but I feel like the original class name was more fitting. Now it's named CaseSensitive yet it can do both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean... but the reason for changing it was the hope that this would prevent this class from being used without its default behaviour being clear in the future -- It is case sensitive by default but reason for IDETECT-4738 was because this was overlooked/assumed wrong at time of implementing detect.binary.scan.file.name.patterns.

Copy link
Contributor

@andrian-sevastyanov andrian-sevastyanov Sep 9, 2025

Choose a reason for hiding this comment

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

Now that I understand the intention I can offer a couple of options for your consideration:

  • split this into 2 subclasses: DetectDirectoryFileFilterCaseSensitive and DetectDirectoryFileFilterCaseInsensitive, while having a parent abstract class contain most of the filtering
  • make the constructor private and have the instantiation done by two different static methods: createCaseSensitiveFileFilter() and createCaseInsensitiveFIleFilter()

This is optional, especially since the PR is already merged.

@shantyk shantyk merged commit 303412f into master Sep 9, 2025
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

Successfully merging this pull request may close these issues.

4 participants