Showing 19 of 83 total issues
File server.py
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Server class"""
import re
import cloudpassage.sanity as sanity
from .utility import Utility as utility
File halo.py
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""HaloSession class.
Manage session configuration for interacting with the CloudPassage Halo API.
"""
Function determine_policy_metadata
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def determine_policy_metadata(cls, policy):
"""Return dict of policy type, name, and target platform.
If string, attempts to convert to dict to parse.
Possible return values for policy_type:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validate_object_id
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_object_id(object_id):
"""Validate object ID (server_id, policy_id, etc...)
This function validates Object IDs with the intent of guarding against URL
traversal.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, apikey, apisecret, **kwargs):
self.auth_endpoint = 'oauth/access_token'
self.api_host = 'api.cloudpassage.com'
self.api_port = 443
self.sdk_version = utility.get_sdk_version()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_paginated
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_paginated(self, endpoint, key, max_pages, **kwargs):
"""This method returns a concatenated list of objects
from the Halo API.
It's really a wrapper for the get() method. Pass in the
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validate_server_state
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_server_state(self, states):
"""Ensure that server state in query is valid"""
if isinstance(states, list):
for state in states:
if state not in self.valid_server_states:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify_and_build_module_params
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def verify_and_build_module_params(self, module_raw):
"""Verifies module params and data types"""
if isinstance(module_raw, list):
for module in module_raw:
if self.scan_type_supported(module) is not True:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validate_platform
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_platform(self, platforms):
"""Validate platform in query is valid"""
if isinstance(platforms, list):
for platform in platforms:
if not self.platform_validator.match(platform):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validate_cve_id
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_cve_id(self, cve_ids):
"""Validate CVE ID designation"""
if isinstance(cve_ids, list):
for cve_id in cve_ids:
if not self.cve_validator.match(cve_id):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validate_kb_id
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_kb_id(self, kb_ids):
"""Validate KB ID is valid"""
if isinstance(kb_ids, list):
for kb_id in kb_ids:
if not self.kb_validator.match(kb_id):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify_and_build_status_params
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def verify_and_build_status_params(self, status_raw):
"""Verifies status params and data types."""
if isinstance(status_raw, list):
for status in status_raw:
if self.scan_status_supported(status) is not True:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function authenticate_client
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def authenticate_client(self):
"""This method attempts to set an OAuth token
Call this method and it will use the API key and secret
as well as the proxy settings (if used) to authenticate
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_response(self, client_method, verb, url, params, reqbody):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, session, start_time, start_url, item_key, params={}):
Function __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, **kwargs):
self.api_hostname = "api.cloudpassage.com"
self.key_id = None
self.secret_key = None
self.api_port = 443
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_adjustment_factor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_adjustment_factor(cls, pages, page_size, item_key):
"""Return adjustment factor, to optimize parallelization of API req.
Args:
pages(list): Pages from query.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function is_it_a_string
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_it_a_string(sample):
"""Return boolean True if ``sample`` is a string, else return False."""
if sys.version_info < (3, 0):
return True if isinstance(sample, basestring) else False # NOQA: F821
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function sanitize_url_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_url_params(cls, params):
"""Sanitize URL arguments for the Halo API
In most cases, the Halo API will only honor the last value
in URL arguments when multiple arguments have the same key.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"