pyupio / safety

Safety checks Python dependencies for known security vulnerabilities and suggests the proper remediations for vulnerabilities detected.
https://safetycli.com/product/safety-cli
MIT License
1.66k stars 141 forks source link

Safety scan command doesn't detect my pyproject.toml (or my env.yml) file with all its dependencies #505

Open Alex-ley-scrub opened 4 months ago

Alex-ley-scrub commented 4 months ago

Description

What I Did

$ ls -al pyproject.toml
-rw-r--r--  1 alex  staff  5000 Feb 24 15:14 pyproject.toml

$ safety scan          
Safety 3.0.1 scanning /Users/alex/repos/Backend
2024-02-24 18:22:12 UTC

Account: Alex Ley, alex@scrub-ai.com 
 Git branch: fix/github_actions_versions
 Environment: development
 Scan policy: None, using Safety CLI default policies

Tested 0 dependencies for known security issues using default Safety CLI policies
0 security issues found, 0 fixes suggested

$ uv pip compile pyproject.toml -o requirements.txt 
Resolved 178 packages in 408ms
warning: The package `pytorch-lightning==2.0.0` does not have an extra named `jsonargparse`.

$ safety scan                                       
Safety 3.0.1 scanning /Users/alex/repos/Backend
2024-02-24 18:22:46 UTC

Account: Alex Ley, alex@scrub-ai.com 
 Git branch: fix/github_actions_versions
 Environment: development
 Scan policy: None, using Safety CLI default policies

Python detected. Found 1 Python requirement file

Dependency vulnerabilities detected:

📝 requirements.txt:
...
image
Alex-ley-scrub commented 4 months ago

perhaps interestingly (or not) - this works - it scans my /Users/alex/miniconda/envs/py311/lib/python3.11/site-packages rather than my pyproject.toml file but that is also pretty ideal:

uv pip uninstall safety
uv pip uninstall dparse
uv pip install safety==2.3.5
safety check

  Safety v2.3.5 is scanning for Vulnerabilities...
  Scanning dependencies in your environment:

  -> /Users/alex/miniconda/envs/py311/lib/python3.11/site-packages

this also works but scans even more stuff:

uv pip uninstall safety
uv pip uninstall dparse
uv pip install safety==3.0.1 --prerelease=allow
safety check

  Safety v3.0.1 is scanning for Vulnerabilities...
  Scanning dependencies in your environment:

  -> /Users/alex/miniconda/envs/py311/bin
  -> /Users/alex/miniconda/envs/py311/lib/python311.zip
  -> /Users/alex/miniconda/envs/py311/lib/python3.11/lib-dynload
  -> /Users/alex/miniconda/envs/py311/lib/python3.11
  -> /Users/alex/repos/Backend
  -> /Users/alex/miniconda/envs/py311/lib/python3.11/site-packages

Is this safety check a better command for me to run than safety scan for my use case (scanning my repo env dependencies)?