All Projects → praezi → rust

praezi / rust

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
RustPräzi: Representing crates.io as a call-based dependency network

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to rust

Core Plans
Core Habitat Plan definitions
Stars: ✭ 129 (+67.53%)
Mutual labels:  package-management
Habitat
Modern applications with built-in automation
Stars: ✭ 2,334 (+2931.17%)
Mutual labels:  package-management
crates.nvim
A neovim plugin that helps managing crates.io dependencies
Stars: ✭ 252 (+227.27%)
Mutual labels:  crates-io
Termux Create Package
Python script to create Termux packages easily.
Stars: ✭ 155 (+101.3%)
Mutual labels:  package-management
Atom Autocomplete Module Import
⚛️ Search & install npm packages from import/require statements.
Stars: ✭ 182 (+136.36%)
Mutual labels:  package-management
Pkgtop
Interactive package manager and resource monitor designed for the GNU/Linux.
Stars: ✭ 222 (+188.31%)
Mutual labels:  package-management
Bpkg
Lightweight bash package manager
Stars: ✭ 1,601 (+1979.22%)
Mutual labels:  package-management
cns
Search through rust crates without leaving the terminal
Stars: ✭ 23 (-70.13%)
Mutual labels:  crates-io
Sharec
📦 Store your configs in one place and share between projects without any pain
Stars: ✭ 198 (+157.14%)
Mutual labels:  package-management
crates-io-cn
Source code of crates-io.cn, also tools sets for sync crates.io
Stars: ✭ 20 (-74.03%)
Mutual labels:  crates-io
Glide
https://github.com/Masterminds/glide
Stars: ✭ 160 (+107.79%)
Mutual labels:  package-management
Luarocks
LuaRocks is the package manager for the Lua programming language.
Stars: ✭ 2,324 (+2918.18%)
Mutual labels:  package-management
colorful
Make your terminal output colorful.
Stars: ✭ 43 (-44.16%)
Mutual labels:  crates-io
Sampctl
The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.
Stars: ✭ 149 (+93.51%)
Mutual labels:  package-management
cmd-call-graph
A simple tool to generate a call graph for calls within Windows CMD (batch) files.
Stars: ✭ 37 (-51.95%)
Mutual labels:  call-graph-analysis
Minicran
R package to create internally consistent, mini version of CRAN
Stars: ✭ 123 (+59.74%)
Mutual labels:  package-management
Pacman
A package management tools for R
Stars: ✭ 220 (+185.71%)
Mutual labels:  package-management
libdnf
Package management library.
Stars: ✭ 157 (+103.9%)
Mutual labels:  package-management
purescript.nix
📦 PureScript package management with Nix
Stars: ✭ 12 (-84.42%)
Mutual labels:  package-management
chit
Crate help in terminal: A tool for looking up details about rust crates without going to crates.io
Stars: ✭ 40 (-48.05%)
Mutual labels:  crates-io

RustPräzi ([rʌstpʁɛˈt͡siːz])

Build Status LOC Join the chat at https://gitter.im/praezi/rust

Constructing call-based dependency networks of crates.io as conceptually described in

Hejderup J, Beller M, Gousios G. Präzi: From Package-based to Precise Call-based Dependency Network Analyses. 2018.

TL;DR: What does RustPräzi do?

Description

With RustPräzi, we go from coarse-grained package-based dependency networks (such as what GitHub uses for their vulnerable package detection) to more fine-grained call-based dependency networks. These allow us to track, for example, whether a vulnerable function of a library is actually being used and whether a security warning really needs to be raised. This is much more precise than package-based dependency networks. In fact, RustPräzi makes such analyses a lot more precise (upto 3x).

Package-based (PDN, above) versus Call-based Dependency Networks (CDN, below)

Use cases

RustPräzi opens the door to many new or more precise analyses:

  • Fine-grained security vulnerability propagation checking
  • Precise license compliance checking
  • Change impact and deprecation analysis ("Which clients break if I as a library maintainer remove this deprecated method?")
  • Health analyses of an entire ecosystem ("What are the most central functions?", "Where should we focus our testing efforts?", ...)
  • ... and more!

Getting started

Installation Prerequisites

  • The Rust toolchain with rustup (download at the offical website)
  • Python 2.7 or 3.7
  • GNU Parallel
  • A pre-built binary of LLVM 4.0 (download at official website). In the config.ini (root of the repository), specify the path to the uncompressed LLVM binary.
  • Recommended OS: Ubuntu 16.04.3 LTS

System Setup

  • ⚠️ Building crates can be dangerous as for some crates, this includes running the tests. Hence, it is advised to do it in a sandboxed environment.
  • 💻 We recommend running it on a very powerful system. Compiling 80k+ crates is no easy feat.

1. Create a conf.ini file at the root of the project with the following content

encoding=utf-8

[llvm]
  # specify the path to the untared LLVM binary folder.
  path=/path_where/clang+llvm-4.0.0-[your_platform]

[compiler]
  stable=1.23.0
  nightly=1.24.0

[storage]
  # all data will be stored in this folder
  path=/where/you/want/to/store/prazi/data

Since the bitcode generation changed in newer versions of Rust, we advise to stick to the compiler versions specified above.

2. Constructing call graphs of crates

  1. Compile the tool
cargo build --bin prazi --release
  1. Download crates, the downloader will fetch the latest index data, build a list of releases and then download/untar them
./target/release/prazi downloader
  1. Rewriting manifests, the manifest rewriter will fix invalid Cargo.toml files (e.g., specifying a non-existent local dependency) by emulating a dry-run of cargo publish
./target/release/prazi rewriter
  1. Building crates, it will first attempt to build all downloaded crates using a stable version of the compiler (as specified in conf.ini). To use a nightly version for failing builds, prepend the flag --nightly
./target/release/prazi build-crates
  1. Building LLVM call graphs
./target/release/prazi build-callgraphs

2. Construct RustPräzi

  1. Install rustfilt for demangling of Rust symbols
cargo install rustfilt
  1. Run graph generator script
./create_prazi_graph.sh 2> err.log 1> out.log

Two graphs are generated:

  • ../cdn/graphs/callgraph.ufi.merged.graph -- the call-based dependency network (CDN)
  • ../cdn/graphs/crate.dependency.callgraph.graph -- the packaged-based dependency network derived from the CDN

3. Graph analysis with RustPräzi

Loading Präzi with NetworkX
import networkx as nx
import re

regex = r"^(.*?) \[label:"

def load_prazi(file):
    PRAZI = nx.DiGraph()
    with open(file) as f: #callgraph.ufi.merged.graph
        for line in f:
            if "->" not in line:
                g = re.match(regex, line)
                if g:
                     PRAZI.add_node(g.group(1).strip('"'))
                else:
                    print "error, could not extract node: %s" % line
            else:
                g = re.match('\W*"(.*)" -> "(.*)";', line)
                if g:
                     PRAZI.add_edge(g.group(1), g.group(2))
                else:
                    print "error, could not extract edge: %s" % line
    return PRAZI

def load_prazi_dep(file): 
    PRAZI_DEP = nx.DiGraph()
    with open(file) as f: #crate.dependency.callgraph.graph
        for line in f:
            if "io :: crates :: " in line:
                if "->" not in line:
                     PRAZI_DEP.add_node(line[:-2])
                else:
                    g = re.match('\W*"(.*)" -> "(.*)";', line)
                    if g and ("io :: crates" in g.group(1) and "io :: crates" in g.group(2)):
                         PRAZI_DEP.add_edge(g.group(1), g.group(2))
                    else:
                        print "skip edge: %s" % line
            else:
                continue
    return  PRAZI_DEP

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in RustPräzi by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].