From c98bba1a5a29e11c82c6d31f6ffd201b8109ff40 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Mon, 26 Jul 2021 15:03:11 -0700 Subject: [PATCH] Filter using extension field rather than path #238 Signed-off-by: Jono Yang --- scanpipe/pipes/windows.py | 2 +- scanpipe/tests/test_pipes.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scanpipe/pipes/windows.py b/scanpipe/pipes/windows.py index b95bab92b..fa78d9ab7 100644 --- a/scanpipe/pipes/windows.py +++ b/scanpipe/pipes/windows.py @@ -74,7 +74,7 @@ def tag_uninteresting_windows_codebase_resources(project): for file_name in uninteresting_files: lookups |= Q(path__iendswith=file_name) for file_extension in uninteresting_file_extensions: - lookups |= Q(path__icontains=file_extension) + lookups |= Q(extension__icontains=file_extension) qs = project.codebaseresources.no_status() qs.filter(lookups).update(status="ignored-not-interesting") diff --git a/scanpipe/tests/test_pipes.py b/scanpipe/tests/test_pipes.py index e3619bdf6..479f6e265 100644 --- a/scanpipe/tests/test_pipes.py +++ b/scanpipe/tests/test_pipes.py @@ -762,7 +762,8 @@ def test_scanpipe_pipes_windows_tag_uninteresting_windows_codebase_resources(sel resource1 = CodebaseResource.objects.create( project=p1, path="root/Files/example.lnk", - rootfs_path="/Files/example.lnk" + rootfs_path="/Files/example.lnk", + extension=".lnk" ) resource2 = CodebaseResource.objects.create( project=p1, @@ -772,12 +773,14 @@ def test_scanpipe_pipes_windows_tag_uninteresting_windows_codebase_resources(sel resource3 = CodebaseResource.objects.create( project=p1, path="root/Files/example.dat", - rootfs_path="/Files/example.dat" + rootfs_path="/Files/example.dat", + extension=".dat" ) resource4 = CodebaseResource.objects.create( project=p1, path="root/Files/User/Test/foo.dat", - rootfs_path="/Files/User/Test/foo.dat" + rootfs_path="/Files/User/Test/foo.dat", + extension=".dat" ) windows.tag_uninteresting_windows_codebase_resources(p1)