From a41192ffab4215c56a9a714e81b1311b9a33d88f Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Wed, 1 Mar 2023 16:35:41 +0100 Subject: [PATCH] Consider 'src/test' test directories The Maven 'Standard Directory Layout' [0] is fairly widely used, not only in Maven but also in adjacent ecosystems like Gradle and clojure. Longer-term this would become part of the default policy, see discussion at https://github.com/ossf/scorecard/pull/1408#issuecomment-999806097 etc. [0]: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html Signed-off-by: Arnout Engelen --- checks/fileparser/listing.go | 4 +++- checks/fileparser/listing_test.go | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/checks/fileparser/listing.go b/checks/fileparser/listing.go index aab72e085c5c..3efb82089910 100644 --- a/checks/fileparser/listing.go +++ b/checks/fileparser/listing.go @@ -52,7 +52,9 @@ func isMatchingPath(fullpath string, matchPathTo PathMatcher) (bool, error) { func isTestdataFile(fullpath string) bool { // testdata/ or /some/dir/testdata/some/other return strings.HasPrefix(fullpath, "testdata/") || - strings.Contains(fullpath, "/testdata/") + strings.Contains(fullpath, "/testdata/") || + strings.HasPrefix(fullpath, "src/test/") || + strings.Contains(fullpath, "/src/test/") } // PathMatcher represents a query for a filepath. diff --git a/checks/fileparser/listing_test.go b/checks/fileparser/listing_test.go index 0c55518d223d..7d3e7cbfacba 100644 --- a/checks/fileparser/listing_test.go +++ b/checks/fileparser/listing_test.go @@ -375,6 +375,13 @@ func Test_isTestdataFile(t *testing.T) { }, want: true, }, + { + name: "testdata file", + args: args{ + fullpath: "archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/redback-authz-open.jar", + }, + want: true, + }, } for _, tt := range tests { tt := tt // Re-initializing variable so it is not changed while executing the closure below