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

Ignore build.rs #116

Closed
anderejd opened this issue Sep 26, 2020 · 7 comments · Fixed by #193
Closed

Ignore build.rs #116

anderejd opened this issue Sep 26, 2020 · 7 comments · Fixed by #193
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@anderejd
Copy link
Contributor

anderejd commented Sep 26, 2020

Should cargo-geiger ignore build.rs since that code doesn't end up in the target binary?

Summary

Yes, cargo-geiger should ignore build.rs.

@anderejd anderejd added the question Further information is requested label Sep 26, 2020
@Shnatsel
Copy link

TL;DR: yes.

Build scripts have a completely different attack model. They can run arbitrary code at build time - steal your passwords, download malware, you name it. Whether they use unsafe in there or not is irrelevant.

What we should be concerned is build.rs generating code with unsafe that does end up in the build, but that's covered by the "just run the compiler lint" approach described in #102

In the same vein, unsafe code in dev- and build-dependencies should be excluded from the tally.

@tarcieri
Copy link
Collaborator

agree with @Shnatsel: I think of cargo-geiger as a static analysis tool, and what build.rs does is anything but static.

@anderejd
Copy link
Contributor Author

Great, let's make it ignore build.rs!

@anderejd anderejd added bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed question Further information is requested labels Sep 29, 2020
@anderejd anderejd changed the title Ignore build.rs? Ignore build.rs Sep 29, 2020
@anderejd
Copy link
Contributor Author

anderejd commented Sep 29, 2020

In the same vein, unsafe code in dev- and build-dependencies should be excluded from the tally.

Should build and dev dependencies be completely ignored, never scanned, never reported, or only ignored when summing up the final score on the bottom line?

@Shnatsel
Copy link

Well, build dependencies have a totally different threat model, so I don't see how looking for unsafe code in them would be useful. It would be misleading, if anything. And dev depdencies ostensibly don't affect the final binary at all.

I'd just exclude them completely, and wait for someone with a use case for scanning them to show up.

@anderejd
Copy link
Contributor Author

Sounds good to me.

@kornelski
Copy link

kornelski commented Jan 20, 2021

I am interested in the "completely different attack model" of crates attacking the build machine, because they can inject unsafe code into the executable. For example, nothing stops a sneaky crate from modifying ~/.cargo/registry to inject malware into other crates.

Could you consider an option in cargo-geiger that flags all build-time code execution? build.rs, proc macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants