Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions guarddog/analyzer/metadata/npm/typosquatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ def detect(

def _get_confused_forms(self, package_name) -> list:
"""Gets confused terms for npm packages.
Currently, there are no confused terms for npm packages.
Older npm packages may use uppercase letters, while new packages must be
lowercase. Treat the lowercase form as confusingly similar so packages
like "jsonstream" can be flagged against "JSONStream".
"""
return []
lowercase_package_name = package_name.lower()
if lowercase_package_name == package_name:
return []

return [lowercase_package_name]


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion tests/analyzer/metadata/test_typosquatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class TestTyposquatting:
("wich-boxed-primitive", "which-boxed-primitive"),
("twetnacl", "tweetnacl"),
("jest-watchers", "jest-watcher"),
("shpk", "sshpk")
("shpk", "sshpk"),
("jsonstream", "JSONStream"),
]

golang_typosquats = [
Expand Down