Skip to content

Commit

Permalink
fix(replayer): replay corpus files in hidden dirs (#254)
Browse files Browse the repository at this point in the history
* fix(replay): replay corpus files in hidden dirs

The replayer would not execute hidden corpus files or files in hidden
directories if they were in the bazel project root (#253).

* chore: update upload-artifact action

`actions/upload-artifact` v1 and v2 are no longer supported.
  • Loading branch information
simonresch authored Sep 15, 2024
1 parent 691c893 commit a8d424d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/oss_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fuzz-seconds: 60
dry-run: false
- name: Upload crashes
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand All @@ -66,7 +66,7 @@ jobs:
fuzz-seconds: 60
dry-run: false
- name: Upload crashes
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
5 changes: 3 additions & 2 deletions fuzzing/replay/file_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ absl::Status TraverseDirectory(
}
break;
}
if (absl::StartsWith(entry->d_name, ".")) {
auto entry_name = absl::string_view(entry->d_name);
if (entry_name == "." || entry_name == "..") {
continue;
}
const std::string entry_path = absl::StrCat(path, "/", entry->d_name);
const std::string entry_path = absl::StrCat(path, "/", entry_name);
status.Update(YieldFiles(entry_path, callback));
}
closedir(dir);
Expand Down
16 changes: 16 additions & 0 deletions fuzzing/replay/file_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ TEST(YieldFilesTest, YieldsDeepFiles) {
EXPECT_THAT(collected_paths, testing::SizeIs(4));
}

TEST(YieldFilesTest, YieldsHiddenFilesAndDirs) {
const std::string root_dir =
absl::StrCat(getenv("TEST_TMPDIR"), "/dir-with-hidden");
ASSERT_EQ(mkdir(root_dir.c_str(), 0755), 0);
ASSERT_TRUE(SetFileContents(absl::StrCat(root_dir, "/.a"), "foo").ok());
const std::string child_dir = absl::StrCat(root_dir, "/.hidden");
ASSERT_EQ(mkdir(child_dir.c_str(), 0755), 0);
ASSERT_TRUE(SetFileContents(absl::StrCat(child_dir, "/b"), "bar").ok());

std::vector<std::string> collected_paths;
const absl::Status status =
YieldFiles(root_dir, CollectPathsCallback(&collected_paths));
EXPECT_TRUE(status.ok());
EXPECT_THAT(collected_paths, testing::SizeIs(2));
}

} // namespace

} // namespace fuzzing

0 comments on commit a8d424d

Please sign in to comment.