compliance.utils package¶
Subpackages¶
- compliance.utils.services package
- Submodules
- compliance.utils.services.github module
Github
Github.add_card()
Github.add_issue()
Github.add_issue_comment()
Github.add_milestone()
Github.apply_labels()
Github.create_column()
Github.create_label()
Github.create_project()
Github.creates_for_project()
Github.extract_owner_repo()
Github.extract_owner_repo_issue()
Github.extract_path_chunks()
Github.get_all_cards()
Github.get_all_issues()
Github.get_all_projects()
Github.get_branch_protection_details()
Github.get_cards()
Github.get_columns()
Github.get_commit_details()
Github.get_issue()
Github.get_issue_comments()
Github.get_issues_page()
Github.get_project()
Github.get_pull_requests()
Github.get_repo_details()
Github.list_milestones()
Github.make_request()
Github.move_card()
Github.paginate_api()
Github.patch_issue()
Github.rand_color()
Github.remove_labels()
Github.search_issues()
Github.update_annotations()
extract_annotations()
- compliance.utils.services.pagerduty module
- Module contents
Submodules¶
compliance.utils.credentials module¶
Compliance credentials configuration.
- class compliance.utils.credentials.Config(cfg_file='~/.credentials')[source]¶
Bases:
object
Handle credentials configuration.
- get(section, key=None, account=None, default=<object object>)[source]¶
Retrieve sections and keys by account.
- Parameters:
section – the section from which to retrieve keys.
account – if provided, fetches the value for the specific account. assumes the account is prefixed to the key and separated by _.
default – if provided, returns this value if a value cannot be found; otherwise raises an exception.
- Parm key:
the key in the section whose value you want to retrieve. if not specified, returns the whole section as a dictionary.
compliance.utils.data_parse module¶
Compliance automation data and formatting utilities module.
- compliance.utils.data_parse.deep_merge(a, b, path=None, append=False)[source]¶
Merge two dicts, taking into account any sub (or sub-sub-*) dicts.
If
append
isTrue
then list values fromb
will be appended toa
’s. Modified from: https://stackoverflow.com/a/7205107/566346
- compliance.utils.data_parse.format_json(data, **addl_kwargs)[source]¶
Provide a JSON string formatted to the standards of the library.
This function ensures that the JSON is sorted, indented, and uses the appropriate separators for all instances of JSON generated by this library.
- Parameters:
data – The data structure to be formatted.
add_kwargs – Additional json.dumps options
- Returns:
A formatted JSON string.
- compliance.utils.data_parse.get_sha256_hash(key, size=None)[source]¶
Provide a SHA256 hash based on the supplied key values.
- Parameters:
key – An iterable of key values.
size – The size of the returned hash. Defaults to full hash. If size provided is greater than the hash size the full hash is returned.
- Returns:
a SHA256 hash for the key values supplied.
- compliance.utils.data_parse.parse_dot_key(data, key)[source]¶
Provide the element from the
data
dictionary defined by thekey
.The key may be a key path depicted by dot notation.
- Parameters:
data – A dictionary
key – A dictionary key string that may be a key path depicted by dot notation. For example “foo.bar”.
- Returns:
The dictionary value from
data
associated to thekey
.
compliance.utils.exceptions module¶
Compliance automation custom exceptions module.
- exception compliance.utils.exceptions.DependencyFetcherNotFoundError[source]¶
Bases:
ValueError
Dependency fetcher not found exception class.
Bases:
ValueError
Missing dependent evidence exception class.
- exception compliance.utils.exceptions.EvidenceNotFoundError[source]¶
Bases:
ValueError
Missing evidence exception class.
- exception compliance.utils.exceptions.HistoricalEvidenceNotFoundError[source]¶
Bases:
ValueError
Missing historical evidence exception class.
- exception compliance.utils.exceptions.LockerPushError(push_info=None)[source]¶
Bases:
Exception
Locker push exception class.
compliance.utils.http module¶
Compliance HTTP helpers.
compliance.utils.path module¶
Compliance automation path formatting utilities module.
- compliance.utils.path.get_module_path(path)[source]¶
Provide the full module dot notation path based on the file path provided.
- Parameters:
path – absolute or relative path to a file or directory.
- Returns:
the module path in dot notation.
- compliance.utils.path.get_toplevel_dirpath(path)[source]¶
Provide the top level directory for the given path.
The top level directory contains the
controls.json
file. This function returnsNone
if a top level path can not be found.- Parameters:
path – absolute or relative path to a file or directory.
- Returns:
the absolute path to the top level directory.
compliance.utils.test module¶
Compliance automation underlying test framework utilities module.
- compliance.utils.test.parse_test_id(test_id)[source]¶
Parse a test ID into useful parts.
Takes a test ID and parses out useful parts of it:
> parse_test_id('foo.bar.baz.test_mod.MyTestClass.test_method') { 'scope': 'foo', 'type': 'bar', 'accreditation': 'baz', 'file': 'test_mod', 'class': 'MyTestClass', 'method': 'test_method', 'class_path': 'foo.bar.baz.test_mod.MyTestClass.test_method' }
Note: scope/type/accreditation might not be returned if your path structure is different from the suggested one.
Module contents¶
Compliance automation utilities package.