Skip to content

Commit

Permalink
Merge pull request #205 from 0xdabbad00/bump_version
Browse files Browse the repository at this point in the history
Add test, bug fix, file bump
  • Loading branch information
0xdabbad00 authored Nov 8, 2021
2 parents 0ae7114 + 8434eab commit 53b1242
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parliament/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This library is a linter for AWS IAM policies.
"""
__version__ = "1.5.0"
__version__ = "1.5.1"

import fnmatch
import functools
Expand Down
6 changes: 6 additions & 0 deletions parliament/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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])
):
Expand All @@ -42,6 +45,9 @@ 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))
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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()

0 comments on commit 53b1242

Please sign in to comment.