From 0492e9e5248bf4a6cf343d7986f5aa835d603b1e Mon Sep 17 00:00:00 2001 From: Scott Piper Date: Mon, 8 Nov 2021 14:38:47 -0700 Subject: [PATCH] revert recent bug fix --- parliament/__init__.py | 2 +- parliament/policy.py | 6 ------ tests/unit/test_usage.py | 28 ---------------------------- 3 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 tests/unit/test_usage.py diff --git a/parliament/__init__.py b/parliament/__init__.py index 094acf7..7b48bb3 100644 --- a/parliament/__init__.py +++ b/parliament/__init__.py @@ -1,7 +1,7 @@ """ This library is a linter for AWS IAM policies. """ -__version__ = "1.5.1" +__version__ = "1.5.2" import fnmatch import functools diff --git a/parliament/policy.py b/parliament/policy.py index e169e86..8f36222 100644 --- a/parliament/policy.py +++ b/parliament/policy.py @@ -28,9 +28,6 @@ def __init__(self, policy_json, filepath=None, config=None): self.config = config if config else {} def add_finding(self, finding, detail="", location={}): - print(type(location)) - print(location) - print(type({})) if type(location) == tuple and "jsoncfg.config_classes" in str( type(location[1]) ): @@ -45,9 +42,6 @@ def add_finding(self, finding, detail="", location={}): location_data["lineno"] = jsoncfg.node_location(location).line location_data["column"] = jsoncfg.node_location(location).column location = location_data - - if type(location) != dict: - location = {'filepath': location} if "filepath" not in location: location["filepath"] = self.filepath self._findings.append(Finding(finding, detail, location)) diff --git a/tests/unit/test_usage.py b/tests/unit/test_usage.py deleted file mode 100644 index 31acd93..0000000 --- a/tests/unit/test_usage.py +++ /dev/null @@ -1,28 +0,0 @@ -import unittest -from nose.tools import raises, assert_equal, assert_true, assert_false -import json -import parliament - - -class TestUsage(unittest.TestCase): - """Test basic usage of the library""" - - def test_using_library(self): - # This is a common use of the library, so just follow the path to ensure no exceptions are thrown. - policy_doc = """ - { - "Statement": [ - { - "Effect": "Allow", - "Action": "s3:ListAllMyBuckets", - "Resource": "*", - "Condition": { - "StringEquals": { "aws:PrincipalTag/project": "web" } - } - } - ], - "Version": "2012-10-17" - }""" - policy_doc = json.loads(policy_doc) - policy = parliament.policy.Policy(policy_doc) - policy.analyze() \ No newline at end of file