Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBug: Pre-release versions not considered matching #172
Comments
This comment has been minimized.
This comment has been minimized.
|
Hm, I just found this comment in the code: // https://docs.npmjs.com/misc/semver#prerelease-tags
fn pre_tag_is_compatible(&self, ver: &Version) -> bool {
// If a version has a prerelease tag (for example, 1.2.3-alpha.3) then it will
// only be
// allowed to satisfy comparator sets if at least one comparator with the same
// [major,
// minor, patch] tuple also has a prerelease tag.
!ver.is_prerelease() ||
(self.major == ver.major && self.minor == Some(ver.minor) &&
self.patch == Some(ver.patch) && !self.pre.is_empty())
} That may be correct for version resolution, but not for a case like vulnerability checking. Maybe the |
This comment has been minimized.
This comment has been minimized.
|
Yes, it's not what we want for resolution, for sure. That being said, if it doesn't make it for resolution, how would it make it into a vulnerability? Wouldn't you want those checks to follow resolution? |
This comment has been minimized.
This comment has been minimized.
|
Hm, I can't quite follow. In cargo-audit, an advisory is published as a file containing the semver specifiers for versions where the vulnerability is patched. Example. Vulnerability checking is done by testing whether a certain version is included in the patched range or not. |
This comment has been minimized.
This comment has been minimized.
|
Right, so if I had |
This comment has been minimized.
This comment has been minimized.
|
No, it's the other way around. If a program has I'm not sure how checking is done for libraries without a lockfile, maybe @tarcieri knows more. |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Apr 25, 2018
|
|
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik are there any news on this issue? Unfortunately it renders cargo audit useless for all projects that use a pre-release of hyper, since it reports a patched version as vulnerable... |
This comment has been minimized.
This comment has been minimized.
|
News is basically, "I have no time to prioritize work on SemVer right now, I hope to get back to it soon, the lack of 1.0 is really bugging me, but I'm also only human." |
This comment has been minimized.
This comment has been minimized.
|
That said, I am also still not 100% sure what this issue is saying; I haven't dug into the exact details, but not matching pre-releases is a feature, not a bug. |
This comment has been minimized.
This comment has been minimized.
|
I understand about the workload, that's no problem. If it's clear what needs to be done I might even be able to come up with a pull request. But regarding bug vs feature: Independently from package managers, why would a query for |
This comment has been minimized.
This comment has been minimized.
That is exactly why. release candidates should be opt-in. All major semver implementations I'm aware of work this way, for this reason. If we changed the API to let |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
May 29, 2018
•
|
It sounds like the simplest option is to explicitly enumerate the prereleases that contain the fix in the advisory's patched versions. I can also see how it's entirely possible there'd be prereleases which don't contain a security fix despite there being a fix in the final release. |
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik I think we're still not talking about the same thing The concrete use case I mentioned above:
|
This comment has been minimized.
This comment has been minimized.
|
(this is how the vulnerability db registers fixes)
Ah ha! This must be the misunderstanding. So the vulnerability DB uses a different conception of versions than Cargo does? You’re not expecting someone who puts >= 0.10.2 in their Cargo.toml to get the fix?
|
This comment has been minimized.
This comment has been minimized.
According to @tarcieri:
This means that we're always dealing with a pinned, concrete version from Cargo.lock, not with version ranges. For example, the question could be: "Is version |
This comment has been minimized.
This comment has been minimized.
|
Okay, we're finally on the same page. Whew. Thanks :) What do you think about
|
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
May 31, 2018
|
If there were a mode where prereleases were in lexographic order between the release versions, you could do e.g. |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Jul 23, 2018
|
@steveklabnik do you think this is something |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Jul 23, 2018
•
|
Here's the current logic we're using to select vulnerable crates, for what it's worth: self.find_by_crate(crate_name)
.iter()
.filter(|advisory| {
!advisory
.patched_versions
.iter()
.any(|req| req.matches(version))
})
.map(|a| *a)
.collect()
Perhaps there should be some special case handling of prereleases here? |
This comment has been minimized.
This comment has been minimized.
Diggsey
commented
Sep 12, 2018
•
|
@tarcieri I think Maybe you need something more complicated to handle regressions, eg. |
This comment has been minimized.
This comment has been minimized.
dwijnand
commented
Jan 18, 2019
|
Though the fact that Version's ordering doesn't match VersionReq's ordering is also a source of confusion. I think I'd expect semver's Version ordering to be consistent throughout the crate. |
dbrgn commentedApr 25, 2018
•
edited
This test fails:
It matches the req if I remove the "-pre.0" suffix though.
This causes cargo-audit to report wrong vulnerabilities.
I assume this is a bug, and does not follow the spec, right?