PyGraas provides a runtime safety mechanism by offering a Graph Analytics and Restriction layer on top of Python packages. It helps in identifying vulnerable dependencies and allows for the restriction of unsafe functions.
- Dependency Graph: Build a DependencyGraph for Python packages.
- Vulnerability Detection: Identify vulnerable Python dependencies using VulnerabilityGraph and analyze these graphs.
- Function Restrictions: Block vulnerable functions, even those deep in the call stack.
- Graph Export: Export graphs as GEXF files for further analysis.
- User-Friendly API: Easy to use and integrate into existing projects.
To install PyGraas, follow these steps:
-
Clone the Repository:
git clone https://github.com/aadya940/pygraas.git cd pygraas
-
Install Dependencies: You can install the required dependencies using pip:
pip install -r requirements.txt
-
Install the Package: You can install the package using:
pip install .
Here's a quick example of how to use PyGraas to analyze a package:
from pygraas import DependencyGraph
# Create a DependencyGraph for the 'numpy' package
g = DependencyGraph(package_name="numpy", package_url="https://github.com/numpy/numpy")
# Build the graph with a maximum depth of 4
graph = g.build_graph(max_bacon=4)
# Get the nodes and edges
nodes = g.get_nodes()
edges = g.get_edges()
print("Nodes:", nodes)
print("Edges:", edges)
from pygraas import VulnerabilityGraph
# Create a VulnerabilityGraph based on the DependencyGraph
v = VulnerabilityGraph(graph)
# Build the vulnerability graph
vulnerability_graph = v.build_vulnerability_graph()
# Get vulnerable packages
vulnerables = v.get_vulnerables(details=True)
print("Vulnerable Packages:", vulnerables)
- Requirements:
- Ensure you have
Git
andPyDeps
installed and configured correctly in your system path. - Data Source: Vulnerability data is sourced from Safety DB.
- Ensure you have
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.
This project is licensed under the MIT License. See the LICENSE file for details.
- Thanks to the contributors and the open-source community for their support and contributions.
Refer examples/test.ipynb
.