Skip to content

Conversation

SwishSwushPow
Copy link
Contributor

@SwishSwushPow SwishSwushPow commented Apr 9, 2025

Hi everyone 👋

While reviewing dependency updates in our project (trying to assure supply chain safety) I noticed that the tests directory contains many binary files and a couple of scripts as well. That makes it harder to review when checking the supply chain and I was wondering if it would be possible to remove this directory from the published package. That would remove a potential vector for a security vulnerability in the future.

The downside of course would be that the tests couldn't be run from the crate package anymore, but I'm not sure how popular that is.

Best regards!

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.76%. Comparing base (00249a9) to head (933ca3a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #340   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files          20       20           
  Lines        4343     4343           
=======================================
  Hits         4246     4246           
  Misses         97       97           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djc
Copy link
Member

djc commented Apr 9, 2025

As I understand it some packagers like to have the tests be part of the package because they can be used to verify that it works. Honestly I'm not convinced of the actual supply chain benefit of this change -- are you going to vet every line of code in this package for every update we release? If not, you're already trusting us.

(Dealt with the cargo-deny failure in #341.)

@weiznich
Copy link

weiznich commented Apr 9, 2025

are you going to vet every line of code in this package for every update we release?

That's basically what we are currently doing. (Well we just review the diffs, not the full code, but that comes down to the same thing if you initially reviewed "everything")

@SwishSwushPow
Copy link
Contributor Author

SwishSwushPow commented Apr 9, 2025

Hi and thanks for your quick reply. At the moment, whenever we update our dependencies, we are actually going over all the changes between the old and the new version (for this specific crate, the changes would e.g. look like this https://diff.rs/rustls-webpki/0.102.8/0.103.1). That includes dependencies of other dependencies as well (yes it's a long list).

In these situations we are mainly looking for things like changed build scripts, added binary files or data in code, suspicious looking code additions, changed ownership situations etc. We are not able to review each individual line in the context of the crate to assure that the functionality hasn't been tempered with deep down somewhere, but yes we are looking at every changed line in every changed file to check if something malicious is going on. In this way we hope to improve the supply chain safety for our project and the safety of the Rust ecosystem in general as well.

Edit: Oh sorry, weiznich was quicker ... 😅

Copy link
Member

@ctz ctz left a comment

Choose a reason for hiding this comment

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

FWIW we did this in rustls/rustls#2077 albeit for different reasons. In this change we go from 801KB to 77.6KB for the .crate size, which I think is worth doing irrespective of anything else.

I had understood that .crate files were never guaranteed to contain tests in a runnable form, so I can't really see that as being a good upstream for packaging?

@SwishSwushPow
Copy link
Contributor Author

Size wise if I simply execute cargo package we go from 802.1KiB to 77.6KiB for rustls-webpki

@djc djc enabled auto-merge April 9, 2025 09:50
@djc
Copy link
Member

djc commented Apr 9, 2025

Okay, that seems like a nice win -- let's do it. Thanks!

The tests include some scripts and binary files that can be hard to review when caring about supply chain safety.
auto-merge was automatically disabled April 9, 2025 10:43

Head branch was pushed to by a user without write access

@djc djc enabled auto-merge April 9, 2025 10:43
@SwishSwushPow
Copy link
Contributor Author

Sorry I put an accidental merge commit in my branch there. Now everything should be sorted again. Thank you both for responding to this PR so quickly! 🙏

@djc djc added this pull request to the merge queue Apr 9, 2025
Merged via the queue into rustls:main with commit ce0385c Apr 9, 2025
33 checks passed
@SwishSwushPow SwishSwushPow deleted the remove_tests_from_package branch April 9, 2025 10:52
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.

4 participants