Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Arbitrary to Glob #2720

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

johnsonw
Copy link

Derive Arbitrary for Glob struct. This feature is optional so the derive will only take place when the feature is enabled. This feature is mandatory when using Glob in fuzz testing.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Overall LGTM, with a couple changes.

Note that I am working on a rewrite of globset and it's not obvious to me that maintaining this Arbitrary impl will be straight-forward. So this might get lost in a future upgrade that will probably happen this year.

(I also resisted adding this to regex-syntax pretty hard, but it turned out that this was the least bad option after a lot of discussion.)

@@ -21,6 +21,7 @@ bench = false

[dependencies]
aho-corasick = "1.1.1"
arbitrary = { version = "1.3.2", optional = true, features = ["derive"] }
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like implicitly depending on crate names for features. Could you explicitly add an arbitrary feature? Example: https://github.com/rust-lang/regex/blob/0c0990399270277832fbb5b91a1fa118e6f63dba/regex-syntax/Cargo.toml#L18

Copy link
Owner

Choose a reason for hiding this comment

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

Please also add docs for this feature in the crate docs, e.g., https://docs.rs/regex-syntax/latest/regex_syntax/#crate-features

Copy link
Author

Choose a reason for hiding this comment

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

Would you be ok with me adding a fuzz folder with a simple fuzz test?

Copy link
Owner

Choose a reason for hiding this comment

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

Probably fine. But it needs to be tested in CI.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @BurntSushi. I've setup a fuzz directory and added a fuzz_testing action to ci.yml. Let me know if you want to adjust the duration for the fuzz testing as this can be modified. I've also addressed the other comments above.

Derive `Arbitrary` for `Glob` struct. This feature is optional so the
derive will only take place when the feature is enabled. This feature is
mandatory when using Glob in fuzz testing.

Signed-off-by: William Johnson <wjohnson@whamcloud.com>
@johnsonw johnsonw force-pushed the johnsonw/add-arbitrary-to-glob branch from 3b62d1a to 579ef12 Compare January 24, 2024 17:24
- Add CI Action to run fuzz testing
- Add `arbitrary` feature in globset Cargo.toml
- Add description for `Crate Features` in Globset

Signed-off-by: William Johnson <wjohnson@whamcloud.com>
Signed-off-by: William Johnson <wjohnson@whamcloud.com>
Signed-off-by: William Johnson <wjohnson@whamcloud.com>
@johnsonw johnsonw marked this pull request as ready for review January 24, 2024 23:45
crates/globset/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: William Johnson <wjohnson@whamcloud.com>
@johnsonw
Copy link
Author

Happy Friday @BurntSushi, I just wanted to check and see if there is anything else you would like me to address?

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Thanks. I normally take a long time to review things. So I wouldn't necessarily expect a quick turn-around here. With that said, I left a number of comments. Thank you for working on this.

sudo apt-get update
sudo apt-get install g++ --yes

- uses: dtolnay/rust-toolchain@nightly
Copy link
Owner

Choose a reason for hiding this comment

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

Is nightly needed here? If not, please use @master like the rest of the jobs.

Copy link
Author

Choose a reason for hiding this comment

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

If we are not concerned with running the fuzz tests in CI then we don't need the nightly build. I'll change this to match the others.


- name: Install packages (Ubuntu)
run: |
sudo apt-get update
Copy link
Owner

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Author

Choose a reason for hiding this comment

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

libFuzzer requires LLVM sanitizer support and a C++ compiler with C++ 11 support. It is required to install the fuzzer and to compile the targets. Please see https://rust-fuzz.github.io/book/cargo-fuzz/setup.html for more information.

crates/globset/src/lib.rs Outdated Show resolved Hide resolved
crates/globset/src/lib.rs Outdated Show resolved Hide resolved
fuzz/.cargo/config.toml Outdated Show resolved Hide resolved
fuzz/scripts/run-all.sh Outdated Show resolved Hide resolved
fuzz/scripts/run-all.sh Outdated Show resolved Hide resolved
fuzz/scripts/run-all.sh Outdated Show resolved Hide resolved
fuzz/scripts/run-all.sh Outdated Show resolved Hide resolved
working-directory: fuzz

- run: ./scripts/run-all.sh
working-directory: fuzz
Copy link
Owner

Choose a reason for hiding this comment

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

For CI, I don't think we need to actually run fuzzing. Let's just make sure all of the fuzz targets build.

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good. I'll update this to simply run a cargo check in the fuzz directory.

instead of actually running the tests.
- Fix "Crate Features" documentation
- Update lines to have a maximum of 79 columns in README.md
- Remove unnecessary files.
- Cleanup fuzz_glob test.

Signed-off-by: William Johnson <wjohnson@whamcloud.com>
@johnsonw
Copy link
Author

johnsonw commented Feb 5, 2024

Good afternoon, I just wanted to follow up on this. Let me know if there is anything else I need to address.

@BurntSushi
Copy link
Owner

I normally take a long time to review things.

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.

None yet

3 participants