Repository: webscopeio/license.sh

Issue:
Ignore packages with package version
SSIA

Discussion:

Patch:
diff --git a/docs/usage.md b/docs/usage.md
index 956e8ec..8ec6d1d 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -44,9 +44,9 @@ Example:
 ```
 {
   "ignored_packages": {
-    "python_pipenv": [
-      "PyInquirer",
-      "setuptools"
+    "python_pipenv": [ 
+      "PyInquirer==1.0.0",
+      "setuptools==3.4.5"
     ],
     "npm": [],
     "maven": [],
@@ -61,15 +61,21 @@ Example:
 ```
   "ignored_packages": {
     "python_pipenv": [
-      "PyInquirer",
-      "setuptools"
+      "PyInquirer==1.0.0",
+      "setuptools==3.4.5"
     ],
     "npm": [],
     "maven": [],
     "yarn": []
   }
 ```
-You can ignore specific packages if it's license is unknown or you have some reason hat you don't what to see it as an error
+You can ignore specific packages if it's license is unknown or you have some reason hat you don't what to see it as an error.
+
+Format:
+"{PACKAGE_NAME}:-:{PACKAGE_VESION}"  --- To ignore specific version of the package RECOMENDED 
+
+"{PACKAGE_NAME}" --- To ignore every version of this specific package
+
 
 * ### Whitelist
 ```
diff --git a/license_sh/helpers.py b/license_sh/helpers.py
index e3e360e..3c10891 100644
--- a/license_sh/helpers.py
+++ b/license_sh/helpers.py
@@ -214,11 +214,12 @@ def annotate_dep_tree(
 
     licenses_not_found = set()
     for node in PreOrderIter(tree):
-        if analyze:
-            node.analyze_problem = not is_analyze_ok(node)
-        node.license_problem = (
-            not is_license_ok(node.license_normalized, whitelist)
-            and node.name not in ignored_packages
+        node.analyze_problem = analyze and not is_analyze_ok(node)
+        node.license_problem = not is_license_ok(
+            node.license_normalized, whitelist
+        ) and not (
+            f"{node.name}=={node.version}" in ignored_packages
+            or node.name in ignored_packages
         )
         if node.license_problem and node.licenses:
             for license_not_found in node.licenses:
@@ -233,7 +234,7 @@ def annotate_dep_tree(
                 map(
                     lambda x: x.subtree_problem
                     or x.license_problem
-                    or (analyze and x.analyze_problem),
+                    or x.analyze_problem,
                     node.children,
                 )
             )


Test patch:
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 4389639..f66ba1e 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -160,6 +160,7 @@ class HelpersTestCase(unittest.TestCase):
             version="",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=True,
             license_normalized="MIT",
@@ -171,6 +172,7 @@ class HelpersTestCase(unittest.TestCase):
             version="1.1.1",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=True,
             license_normalized="MIT",
@@ -181,6 +183,7 @@ class HelpersTestCase(unittest.TestCase):
             version="4.4.4",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=True,
             license_normalized="MIT",
@@ -192,6 +195,7 @@ class HelpersTestCase(unittest.TestCase):
             version="2.2.2",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=False,
             license_normalized="MIT",
@@ -202,6 +206,7 @@ class HelpersTestCase(unittest.TestCase):
             version="5.5.5",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=False,
             license_normalized="MIT",
@@ -212,6 +217,7 @@ class HelpersTestCase(unittest.TestCase):
             version="7.7.7",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=False,
             license_normalized="MIT",
@@ -223,6 +229,7 @@ class HelpersTestCase(unittest.TestCase):
             version="3.3.3",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=True,
             license_normalized="MIT",
@@ -233,6 +240,7 @@ class HelpersTestCase(unittest.TestCase):
             version="7.7.6",
             license="GPL",
             licenses=["GPL"],
+            analyze_problem=False,
             license_problem=True,
             subtree_problem=False,
             license_normalized="GPL",
@@ -244,6 +252,7 @@ class HelpersTestCase(unittest.TestCase):
             version="4.4.4",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=False,
             license_normalized="MIT",
@@ -255,6 +264,7 @@ class HelpersTestCase(unittest.TestCase):
             version="5.5.5",
             license="MIT",
             licenses=["MIT"],
+            analyze_problem=False,
             license_problem=False,
             subtree_problem=True,
             license_normalized="MIT",
@@ -265,6 +275,7 @@ class HelpersTestCase(unittest.TestCase):
             version="6.6.6",
             license="GPL",
             licenses=["GPL"],
+            analyze_problem=False,
             license_problem=True,
             subtree_problem=False,
             license_normalized="GPL",
@@ -276,6 +287,7 @@ class HelpersTestCase(unittest.TestCase):
             version="6.6.6",
             license="GPL",
             licenses=["GPL"],
+            analyze_problem=False,
             license_problem=True,
             subtree_problem=False,
             license_normalized="GPL",
@@ -288,7 +300,7 @@ class HelpersTestCase(unittest.TestCase):
 
     def test_bad_licenses_identified_are_ignored_by_package_whitelist(self):
         tree = get_tree()
-        ignored_packages = ["package7", "package6"]
+        ignored_packages = ["package7==7.7.6", "package6==6.6.6"]
 
         whitelist = ["MIT", "Apache-2.0"]
         _, unknown_licenses = annotate_dep_tree(tree, whitelist, ignored_packages)