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

feat: support temporal score and Environmental Score #1198

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bxf12315
Copy link

@bxf12315 bxf12315 commented Jun 6, 2024

No description provided.

.gitignore Outdated Show resolved Hide resolved
@tarcieri
Copy link
Member

tarcieri commented Jun 6, 2024

It would be nice if these changes could be done in a purely additive manner with any breaking changes as a last resort and kept as minimal as possible.

This crate has been post-1.0 for over 5 years and any unnecessary changes will cause breakages/churn.

@bxf12315
Copy link
Author

bxf12315 commented Jun 7, 2024

@tarcieri How about this commit?

@gildub
Copy link

gildub commented Jun 11, 2024

@bxf12315, could you please add a description to this PR ?
I'm trying to help with the review but I got initially confused.
Let's add CVSS v3.1 support for Temporal and Environmental Scores.
And also link related issues ?

Copy link

@gildub gildub left a comment

Choose a reason for hiding this comment

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

The code looks good to me.
Although the use of abbreviations for the metrics of the various groups is confusing.
It makes sense in a context of a specification document but it's makes the code obscure and hard to read.

For the base group, dubbing the file 'attack_vector.rs', instead of 'av' is clear about its purpose, especially because there are many files such as 'ac', 'av', etc.
But I suppose the main issue is because the file name should reflect the name of the struct or object it manages.

Also I think the use of mod.rs inside of base, environmental and temporal modules would be more idiomatic to Rust as of today.

@tarcieri
Copy link
Member

Note that mod.rs is the older, Rust 2015 convention, and we use the newer Rust 2018 convention with files named after their respective modules: https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html#no-more-modrs

Please don't use mod.rs, and if we haven't already, we should enable the lints to deny it.

@tarcieri
Copy link
Member

For the base group, dubbing the file 'attack_vector.rs', instead of 'av' is clear about its purpose, especially because there are many files such as 'ac', 'av', etc.

@gildub you are suggesting breaking changes that are more or less bikeshedding. This crate has been stable, for many, many years. Please don't make any superfluous changes, and please follow the existing conventions.

@bxf12315 bxf12315 marked this pull request as ready for review June 11, 2024 13:22
@gildub
Copy link

gildub commented Jun 11, 2024

@tarcieri,

Regarding the mod.rs style, I thought it was the other way around, thanks for the link !

Regarding the file names, shouldn't the file name reflect the struct it contains ?
That doesn't seems superfluous because, for exemple, 'src/v3/temporal.e.rs' file is handling ExploitCodeMaturity structure not e structure and that doesn't seem to be respecting Rust practices. Also the existing code seems to not have such convention.

@bxf12315
Copy link
Author

bxf12315 commented Jun 12, 2024

@tarcieri,

Regarding the mod.rs style, I thought it was the other way around, thanks for the link !

Regarding the file names, shouldn't the file name reflect the struct it contains ? That doesn't seems superfluous because, for exemple, 'src/v3/temporal.e.rs' file is handling ExploitCodeMaturity structure not e structure and that doesn't seem to be respecting Rust practices. Also the existing code seems to not have such convention.

@gildub I'm not good at naming, but I personally think that naming conventions consistent with the whole project are reasonable.

@gildub
Copy link

gildub commented Jun 12, 2024

Hi @xiabai,
could you please clarify if you agree with changing the files names to more explicit names or not ?

@bxf12315
Copy link
Author

Hi @xiabai, could you please clarify if you agree with changing the files names to more explicit names or not ?

I do not think change file's name is necessary. Keep changes to a minimum.

Hi @xiabai, could you please clarify if you agree with changing the files names to more explicit names or not ?

I do not think change file's name is necessary. Keep changes to a minimum.

@gildub

This comment was marked as off-topic.

@tarcieri
Copy link
Member

@gildub the changes you are proposing are, at best, off-topic for this PR. Please open a separate issue.

@gildub

This comment was marked as off-topic.

@bxf12315
Copy link
Author

@tarcieri How to trigger the github workflow, I find an compile error, it's just happened on rust 1.6, I want to rebuild it.

@tarcieri
Copy link
Member

@bxf12315 it should run automatically from now on

@gildub

This comment was marked as off-topic.

@bxf12315 bxf12315 force-pushed the ts-es branch 4 times, most recently from 1babc4d to 27ba93e Compare June 13, 2024 10:46
Comment on lines 22 to 23
/// Get CVSS v3.1 score for this metric.
fn score(self) -> f64;
// fn score(self) -> f64;
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change

@tarcieri
Copy link
Member

tarcieri commented Jun 13, 2024

So yeah, this PR includes many, many breaking changes by decomposing what are currently inherent methods into traits.

That's not necessarily a dealbreaker for this PR but it will signal the start of another breaking release cycle where it would be good to also address #1087, and would therefore delay any usage of these new features outside of prereleases.

I think it can probably still be written in a purely additive way that doesn't break any existing APIs (again, this is a v2.0 crate which has been stable for many years), and perhaps introduce those changes separately in a PR that starts a new breaking release cycle.

@bxf12315
Copy link
Author

bxf12315 commented Jun 13, 2024

So yeah, this PR includes many, many breaking changes by decomposing what are currently inherent methods into traits.

That's not necessarily a dealbreaker for this PR but it will signal the start of another breaking release cycle where it would be good to also address #1087, and would therefore delay any usage of these new features outside of prereleases.

I think it can probably still be written in a purely additive way that doesn't break any existing APIs (again, this is a v2.0 crate which has been stable for many years), and perhaps introduce those changes separately in a PR that starts a new breaking release cycle.

ok, I got your point, I will drop these three traits MetricScore and ScopedScore, and ModifiedScore, keep the old logic.
I will try to update them before the weekend.

@bxf12315 bxf12315 force-pushed the ts-es branch 2 times, most recently from ca7d5cc to a2a9c0f Compare June 14, 2024 03:18
@bxf12315
Copy link
Author

@tarcieri updated, please check again.

@bxf12315
Copy link
Author

@tarcieri please review the PR. Thanks

@bxf12315
Copy link
Author

bxf12315 commented Jul 8, 2024

@tarcieri hi please review the PR. Thanks

@tarcieri
Copy link
Member

tarcieri commented Jul 8, 2024

@bxf12315 I will try to review soon, however I am the maintainer for a large number of projects and this PR is something of a lower priority to me

cvss/src/metric.rs Outdated Show resolved Hide resolved
cvss/src/v3/cvss.rs Outdated Show resolved Hide resolved
@tarcieri
Copy link
Member

tarcieri commented Oct 9, 2024

I'm a little confused how referencing std didn't break CI

@bxf12315
Copy link
Author

Please check again. Thanks

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.

3 participants