Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.
Merged
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
8 changes: 7 additions & 1 deletion security_monkey/common/gcp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
.. module: security_monkey.auditors.gcp.config
.. module: security_monkey.common.gcp.config
:platform: Unix
.. version:: $$VERSION$$
.. moduleauthor:: Tom Melendez <supertom@google.com> @supertom
"""

class ApplicationConfig(object):
SECURITY_MONKEY_VERSION = '0.8.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From http://stackoverflow.com/questions/5285858/determining-what-version-of-flask-is-installed

>>> import pkg_resources
>>> pkg_resources.get_distribution('security_monkey').version
'0.8.0'

Might make sense to add a security_monkey.__version__ as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #617 to track usecase for security_monkey.__version__


@staticmethod
def get_version():
return ApplicationConfig.SECURITY_MONKEY_VERSION

class AuditorConfig(object):
"""
Expand Down
4 changes: 4 additions & 0 deletions security_monkey/common/gcp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ def gcp_resource_id_builder(service, identifier, region=''):

def modify(d, format='camelized'):
return cloudaux_modify(d, format=format)

def get_user_agent(**kwargs):
from security_monkey.common.gcp.config import ApplicationConfig as appconfig
return 'security-monkey/%s' % appconfig.get_version()
4 changes: 3 additions & 1 deletion security_monkey/watchers/gcp/gce/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.. version:: $$VERSION$$
.. moduleauthor:: Tom Melendez <supertom@google.com> @supertom
"""
from security_monkey.common.gcp.util import get_gcp_project_creds, gcp_resource_id_builder, modify
from security_monkey.common.gcp.util import get_gcp_project_creds, get_user_agent, gcp_resource_id_builder, modify
from security_monkey.watcher import Watcher
from security_monkey.watcher import ChangeItem

Expand All @@ -39,6 +39,7 @@ def __init__(self, accounts=None, debug=False):
self.ephemeral_paths = [
"Etag",
]
self.user_agent = get_user_agent()

def slurp(self):
"""
Expand All @@ -52,6 +53,7 @@ def slurp(self):
@iter_project(projects=project_creds)
def slurp_items(**kwargs):
item_list = []
kwargs['user_agent'] = self.user_agent
rules = list_firewall_rules(**kwargs)

for rule in rules:
Expand Down
5 changes: 4 additions & 1 deletion security_monkey/watchers/gcp/gce/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.. moduleauthor:: Tom Melendez <supertom@google.com> @supertom

"""
from security_monkey.common.gcp.util import get_gcp_project_creds, gcp_resource_id_builder
from security_monkey.common.gcp.util import get_gcp_project_creds, get_user_agent, gcp_resource_id_builder
from security_monkey.watcher import Watcher
from security_monkey.watcher import ChangeItem

Expand All @@ -40,6 +40,7 @@ def __init__(self, accounts=None, debug=False):
self.ephemeral_paths = [
"Etag",
]
self.user_agent = get_user_agent()

def slurp(self):
"""
Expand All @@ -48,11 +49,13 @@ def slurp(self):
location of the exception and the value is the actual exception
"""
self.prep_for_slurp()

project_creds = get_gcp_project_creds(self.accounts)

@iter_project(projects=project_creds)
def slurp_items(**kwargs):
item_list = []
kwargs['user_agent'] = self.user_agent
networks = list_networks(**kwargs)

for network in networks:
Expand Down
5 changes: 4 additions & 1 deletion security_monkey/watchers/gcp/gcs/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.. moduleauthor:: Tom Melendez <supertom@google.com> @supertom

"""
from security_monkey.common.gcp.util import get_gcp_project_creds, gcp_resource_id_builder
from security_monkey.common.gcp.util import get_gcp_project_creds, get_user_agent, gcp_resource_id_builder
from security_monkey.watcher import Watcher
from security_monkey.watcher import ChangeItem

Expand All @@ -40,6 +40,7 @@ def __init__(self, accounts=None, debug=False):
self.ephemeral_paths = [
"Etag",
]
self.user_agent = get_user_agent()

def slurp(self):
"""
Expand All @@ -48,11 +49,13 @@ def slurp(self):
location of the exception and the value is the actual exception
"""
self.prep_for_slurp()

project_creds = get_gcp_project_creds(self.accounts)

@iter_project(projects=project_creds)
def slurp_items(**kwargs):
item_list = []
kwargs['user_agent'] = self.user_agent
buckets = list_buckets(**kwargs)

for bucket in buckets:
Expand Down
5 changes: 4 additions & 1 deletion security_monkey/watchers/gcp/iam/serviceaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.. moduleauthor:: Tom Melendez <supertom@google.com> @supertom

"""
from security_monkey.common.gcp.util import get_gcp_project_creds, gcp_resource_id_builder
from security_monkey.common.gcp.util import get_gcp_project_creds, get_user_agent, gcp_resource_id_builder
from security_monkey.watcher import Watcher
from security_monkey.watcher import ChangeItem

Expand All @@ -40,6 +40,7 @@ def __init__(self, accounts=None, debug=False):
self.ephemeral_paths = [
"Etag",
]
self.user_agent = get_user_agent()

def slurp(self):
"""
Expand All @@ -48,11 +49,13 @@ def slurp(self):
location of the exception and the value is the actual exception
"""
self.prep_for_slurp()

project_creds = get_gcp_project_creds(self.accounts)

@iter_project(projects=project_creds)
def slurp_items(**kwargs):
item_list = []
kwargs['user_agent'] = self.user_agent
service_accounts = list_serviceaccounts(**kwargs)

for service_account in service_accounts:
Expand Down