-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from DataDog/88-guarddog-fails-to-parse-the-wh…
…ole-requirementstxt-after-encountering-package-name-starting-with-git+https Handle requirement file parsing errors
- Loading branch information
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import pkg_resources | ||
|
||
from guarddog.scanners.project_scanner import RequirementsScanner | ||
|
||
|
||
# Regression test for https://github.com/DataDog/guarddog/issues/78 | ||
def test_requirements_scanner_on_non_existing_package(): | ||
def test_requirements_scanner(): | ||
scanner = RequirementsScanner() | ||
result = scanner.parse_requirements(["not-a-real-package==1.0.0"]) | ||
assert "not-a-real-package" not in result | ||
result = scanner.parse_requirements(["not-a-real-package==1.0.0", "flask==2.2.2"]) | ||
assert "not-a-real-package" not in result # ignoring non existing packages | ||
assert "flask" in result | ||
|
||
|
||
# Regression test for https://github.com/DataDog/guarddog/issues/88 | ||
def test_requirements_scanner_on_git_url_packages(): | ||
scanner = RequirementsScanner() | ||
result = scanner.parse_requirements([ | ||
"flask==2.2.2", | ||
"http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl", | ||
"guarddog @ git+https://github.com/DataDog/guarddog.git", | ||
"git+https://github.com/DataDog/guarddog.git" | ||
]) | ||
assert "guarddog" in result | ||
assert "flask" in result | ||
assert len(result) == 2 | ||
|