You cannot do that analysis with one sample. Why pick one day? That is an arbatary amount? Pick the 1 hour or minute that the CVE was released and you will find rust might be responsible for 100% of CVEs, Take a Week or year and that number drops dramatically. Pick the next day and that drops to 0%. You can select any % you want if you change what time period you are looking at.
The fact that there has been one cve in 5 years of rust in the kernel is a bigger tell. There will be more rust CVEs, and each one is going to be big news as they happen so rarely.
parse_oui_databasetakes in a file path as a &String that is used to open the file in a parsing function. IMO there are a number of problems here.First, you should almost never take in a
&Stringas a function argument. This basically means you have a reference to a owned object. It forces an allocation of everything passed into the function only to take a reference of it. It excludes types that are simply&strs forcing the caller to convert them to a full String - which involves an allocation. The function should just taking in a&stras it is cheap to convert aStringto a&str(cheaper to use than a&Stringas well as&Stringhave a double redirection).Sometimes it might be even better might be to take in a
impl<AsRef(str)>which means the function can take in anything that can be converted into a&strwithout the caller needing to do it directly. Though on larger functions like this that might not always be the best idea as it makes it generic and so will be monomorphised for every type you pass into it. This can bloat a binary if you do it on lots of large functions with lots of different input types. You can also get the best of both worlds with a generic wrapper function to a concrete implementation - so the large function has a concrete type&strand a warpper that takes aimpl <AsRef<str>>and calls the inner function. Though in this case it is probably easier to just take in a&strand manually convert at all the one call sites.Second.
String/&strare not the write types for paths. Those would bePathBufand&Pathwhich both work likeStringand&str(so all the above applies to these as well). These are generally better to use as paths in most OSs dont have to be unicode. Which means there are files (though very rarely) which cannot be represented as a String. This is whyFile::opentakes in aAsRef<Path>which your function can also.Lastly. I would not conflate opening a file with parsing it. These should be two different functions. This makes the code a bit more flexible - you can get the file to parse from other sources. One big advantage to this would be for testing where you can just have the test data as strings in the test. It also makes the returned error type simpler as one function can deal with io errors and the other with parsing errors. And in this case you can just parse the file directly from the internet request rather than saving it to a file first (though there are other reasons you may or may not want to do this).