Close public API gaps: nameable field types, reachable no_libc, honest rule-load errors - #23
Open
mnaza wants to merge 2 commits into
Open
Close public API gaps: nameable field types, reachable no_libc, honest rule-load errors#23mnaza wants to merge 2 commits into
mnaza wants to merge 2 commits into
Conversation
- pub use FileFormat, Os, FileArchitecture, SecurityCheckStatus from the crate root — they appear in public fields but lived in private modules, so downstream could not name them. - FunctionCapabilities: address()/features()/capabilities() getters (fields stay private; additive). - BinarySecurityCheckOptions: builder-style no_libc(bool) — the documented option was unreachable (pub(crate) field, new() hard-coded false). - from_file/from_buffer: spawn the rules-load thread BEFORE format detection + disassembly so it actually overlaps (smda disassembles eagerly; previously join blocked immediately), propagate the real RuleSet::new error instead of misreporting DescriptionEvaluationError, and resume_unwind a loader panic instead of mislabeling it. - LibCSpec: strict FromStr (unknown versions error instead of silently degrading to LSB5); lenient From<String> kept for compat; capa_cli uses the strict parse. New Error::InvalidLibCSpec variant. - from_file takes impl AsRef<Path> (was AsRef<str>); existing &str/String callers keep compiling. Adds tests/public_api.rs integration tests pinning the public surface.
mnaza
force-pushed
the
fix/public-api-gaps
branch
from
July 31, 2026 08:57
255d910 to
dd9270f
Compare
Owner
|
conflicts |
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22.
Small public-API fixes; everything is additive or behavior-preserving for existing callers. New
tests/public_api.rsintegration test pins the surface (5 tests; total 18 lib + 5 integration, all green).1. Types in public fields are now nameable downstream
Properties::format/os/archandFileCapabilities::security_checksexposed types from private modules — downstream couldDebug-print them but nevermatchon them. Now re-exported from the crate root:2.
FunctionCapabilitiesgettersaddress()/features()/capabilities()— fields stay private, so this is additive and non-breaking.3.
no_libcis reachableBinarySecurityCheckOptionsfields arepub(crate)andnew()hard-codedno_libc: false— the documented "assume no C runtime" option could not be enabled. New builder-style method:4. Rule loading: real parallelism + real errors
The loader thread was spawned after
get_file_extractors/Extractor::from_buffer, and smda disassembles eagerly in the constructor — sojoinblocked immediately and ~1000 YAML rule files loaded strictly serially. The spawn now happens first, overlapping rule loading with format detection + disassembly.Errors:
Ok(Err(_)) | Err(_) => DescriptionEvaluationErrorthrew away the actual failure (bad YAML, missing dependency…) and pointed users at the wrong thing. Now the realRuleSet::newerror propagates, and a loader panic is re-thrown viaresume_unwindinstead of being mislabeled.5. Strict
LibCSpec::from_strUnknown LSB versions silently became
LSB5, changing fortify-check semantics (e.g.4.0.1typo).FromStrreturns the newError::InvalidLibCSpec; the lenientFrom<String>stays for compatibility;capa_clinow uses the strict parse and exits with an error message on bad input.6.
from_file(impl AsRef<Path>)Was
AsRef<str>— non-UTF-8 paths (legal on Unix) could not be analysed.&str/Stringcallers keep compiling; conversion isto_string_lossyinternally.Verified:
cargo test --all-features,cargo check --no-default-features/--features verbose, clippy--all-targets— all clean. CHANGELOG entry under[Unreleased]. Based on master; independent of #17 / #19 / #21 except for the shared[Unreleased]CHANGELOG heading.