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

CSUB-386: Enable cargo audit in CI #880

Merged
merged 4 commits into from
Mar 20, 2023
Merged

Conversation

atodorov
Copy link
Contributor

Description of proposed changes:

Practical tips for PR review & merge:

  • All GitHub Actions report PASS
  • Newly added code/functions have unit tests
    • Coverage tools report all newly added lines as covered
    • The positive scenario is exercised
    • Negative scenarios are exercised, e.g. assert on all possible errors
    • Assert on events triggered if applicable
    • Assert on changes made to storage if applicable
  • Modified behavior/functions - try to make sure above test items are covered
  • Integration tests are added if applicable/needed

@atodorov atodorov force-pushed the CSUB-386-enable-cargo-audit branch 2 times, most recently from d6721aa to 5c14955 Compare January 11, 2023 15:27
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2023

Codecov Report

❗ No coverage uploaded for pull request base (dev@f1d3463). Click here to learn what that means.
The diff coverage is n/a.

@@          Coverage Diff           @@
##             dev     #880   +/-   ##
======================================
  Coverage       ?   77.62%           
======================================
  Files          ?       75           
  Lines          ?    11383           
  Branches       ?        0           
======================================
  Hits           ?     8836           
  Misses         ?     2547           
  Partials       ?        0           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

For full LLVM coverage report click here!

@AdaJane
Copy link
Contributor

AdaJane commented Jan 11, 2023

The report being output by the audit points to the time library as being the only one with a real "problem" (segFault). It looks like this is depended on by some of the runtime related crates.

If that library is being used inside the runtime, it's not a security concern because of the wasmtime handles segFaults (terminates the process and 0s the memory).

One question I have from looking at this and the the main cargo.toml, "Does dependabot do anything about explicit version dependencies?".

I would assume, for example, that this dependency:
tracing = { version = "5.0.0", default-features = false, branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate.git", package = "sp-tracing" }
would not be automatically updated because it both depends on an explicit and exact version, and it comes from a GitHub repo.

Still digging, but any insights are appreciated.

@atodorov
Copy link
Contributor Author

I would assume, for example, that this dependency:
tracing = { version = "5.0.0", default-features = false, branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate.git", package = "sp-tracing" }
would not be automatically updated

That's correct. Dependabot will not do anything about it.

@WilfredTA
Copy link

Referring to this issue in the chrono repository. Projects that have referenced that issue appear to have fixed the issue in one of a few different ways:

  1. Update the time dependency to a version that patches this vulnerability
  2. Disable chrono default features, which disables the oldtime feature, which prevents the dependency on time crate
  3. Wait for chrono 0.5 upstream, which removes this dependency.

However, maintainers of chrono have stated that chrono does not use the vulnerable API in time crate.

Unfortunately, this would not fix the problem... because it appears that chrono has the same vulnerability in its own source code that the time crate has, as discussed here. This vulnerability is described in RUSTSEC-2020-0159. The PR that introduced the 2020-0159 security advisory states that this has impacted at least one project running in production.

We need to look at the execution paths & conditions to determine whether this is a concern for us. Unfortunately, it appears that some of the dependencies that utilize chrono are also no longer maintained, so we wouldn't expect these fixes to come upstream. Let's determine how our third party libraries use chrono and if their usage leads to erroneous behavior.

The fact that multiple core dependencies are no longer maintained brings up another issue around how large our "trusted base" is, given the amount of dependencies the project has.

Let's take a little more time to analyze the short term risks of the failures reported by cargo-audit as well as the long term consequences of the deps we are using.

@AdaJane
Copy link
Contributor

AdaJane commented Jan 12, 2023

Referring to this issue in the chrono repository. Projects that have referenced that issue appear to have fixed the issue in one of a few different ways:

The fact that multiple core dependencies are no longer maintained brings up another issue around how large our "trusted base" is, given the amount of dependencies the project has.

Let's take a little more time to analyze the short term risks of the failures reported by cargo-audit as well as the long term consequences of the deps we are using.

The time dependency here looks like it's being pulled in by Substrate related crates. There are newer versions of these crates available now on crates.io (as opposed the github they're currently being pulled from), but several of the newer crates introduce new names for existing types as well as moving types we're using to new modules. There would be a bit of effort involved in migrating to the latest Substrate crates, but it may help with some of our dependency concerns here.

The downside is that by upgrading the substrate crates we go from ~900 dependencies to just over 1100, so not the ideal direction.

@atodorov atodorov changed the title Enable cargo audit in CI CSUB-386: Enable cargo audit in CI Jan 17, 2023
Potential segfault in the time crate:
https://rustsec.org/advisories/RUSTSEC-2020-0071

this is not a direct dependency of creditcoin-node and will be fixed
via a future upgrade of Substrate.

ALSO don't error out on warnings because all of them are coming from
Substrate as well.
@atodorov atodorov force-pushed the CSUB-386-enable-cargo-audit branch 2 times, most recently from 7ea0b3f to 5faa4ff Compare March 16, 2023 13:03
this is an extra check which should hopefully inform us on warnings
or anything else that is a 1st level dependency of Creditcoin.
@atodorov atodorov force-pushed the CSUB-386-enable-cargo-audit branch from 5faa4ff to 804eeca Compare March 16, 2023 13:12
Copy link
Contributor

@AdaJane AdaJane left a comment

Choose a reason for hiding this comment

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

I'm not crazy about ignoring all indirect dependencies, but I think this is still a nice addition to the pipeline.

Edit: After clarification, everything makes sense

Copy link
Contributor

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

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

A couple questions/comments

.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
@atodorov atodorov merged commit 9da4678 into dev Mar 20, 2023
@atodorov atodorov deleted the CSUB-386-enable-cargo-audit branch March 20, 2023 17:11
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.

6 participants