src package¶
Subpackages¶
- src.checks package
- Submodules
- src.checks.checked_in_binaries module
FactHelperFileFileType
FactHelperFile
CheckedInBinaries
CheckedInBinaries.blacklist_dir
CheckedInBinaries.exclude
CheckedInBinaries.blacklist
CheckedInBinaries.whitelist
CheckedInBinaries.fileTypeTools
CheckedInBinaries.__init__()
CheckedInBinaries.__update_blacklist()
CheckedInBinaries.__init_blacklist()
CheckedInBinaries.__is_too_generic()
CheckedInBinaries._run_all_tools()
CheckedInBinaries._format_findings()
CheckedInBinaries.__format_findings()
CheckedInBinaries._is_ok()
CheckedInBinaries._calc_score()
CheckedInBinaries._determine_violations()
CheckedInBinaries.run()
CheckedInBinaries.__annotations__
CheckedInBinaries.__module__
- src.checks.comments_in_code module
CommentsInCode
CommentsInCode.__init__()
CommentsInCode.__load_tokei_to_linguist()
CommentsInCode.__compute_l_check()
CommentsInCode.__have_tokei()
CommentsInCode.__fetch_linguist()
CommentsInCode.__compute_l_repo()
CommentsInCode.__run_tokei()
CommentsInCode._tokei()
CommentsInCode._sigma()
CommentsInCode._compute_tokei()
CommentsInCode._compute_score()
CommentsInCode.run()
CommentsInCode.__annotations__
CommentsInCode.__module__
- src.checks.existence_of_documentation_infrastructure module
logger
PlainInTreeFile
PlainInTreeFolder
OutOfTreeExternal
OutOfTreeWiki
ExistenceOfDocumentationInfrastructure
ExistenceOfDocumentationInfrastructure.DEFAULT_RISE
ExistenceOfDocumentationInfrastructure.doc_types
ExistenceOfDocumentationInfrastructure._sigma()
ExistenceOfDocumentationInfrastructure.sigma_inv()
ExistenceOfDocumentationInfrastructure._sigma_inv_2()
ExistenceOfDocumentationInfrastructure._compute_delta()
ExistenceOfDocumentationInfrastructure._score()
ExistenceOfDocumentationInfrastructure._detailed_results()
ExistenceOfDocumentationInfrastructure.__annotations__
ExistenceOfDocumentationInfrastructure.__module__
ExistenceOfDocumentationInfrastructure.run()
- src.checks.interfaces_checked_in_binaries module
- src.checks.interfaces_existence_of_documentation_infrastructure module
DocumentationTypeInterface
DocumentationTypeInterface.TEXT_FILE_REGEX
DocumentationTypeInterface.LINK_PATTERN
DocumentationTypeInterface.PubbliccodeymlDocLink
DocumentationTypeInterface.ScrapedDocLink
DocumentationTypeInterface.RM_WHITESPACE_MAP
DocumentationTypeInterface.__init__()
DocumentationTypeInterface._is_external_url()
DocumentationTypeInterface._docs_in_publiccodeyml()
DocumentationTypeInterface._collect_doc_links()
DocumentationTypeInterface._amount()
DocumentationTypeInterface._text_file_filter()
DocumentationTypeInterface._get_publiccodeyml()
DocumentationTypeInterface._remove_whitespace()
DocumentationTypeInterface.delta()
DocumentationTypeInterface.__annotations__
DocumentationTypeInterface.__module__
- src.checks.interfaces_sast_usage_basic module
- src.checks.interfaces_secrets module
SecretInterface
SecretsToolInterface
SecretsToolInterface.__init__()
SecretsToolInterface.name
SecretsToolInterface.check_file()
SecretsToolInterface.check_files()
SecretsToolInterface.create_or_overwrite_baseline()
SecretsToolInterface.update_baseline()
SecretsToolInterface.diff_vs_baseline()
SecretsToolInterface.delete_baseline()
SecretsToolInterface.detected_secrets
SecretsToolInterface.__dict__
SecretsToolInterface.__module__
SecretsToolInterface.__weakref__
- src.checks.sast_usage_basic module
SastToolKind
SastTool
SastTool.default_special_regex_values
SastTool.default_language_regex_values
SastTool.__init__()
SastTool.__add_source_file_regex()
SastTool.__compile_regex()
SastTool.__getitem__()
SastTool.from_file_validate()
SastTool.check_file()
SastTool._check_file()
SastTool.weight
SastTool.__annotations__
SastTool.__dict__
SastTool.__module__
SastTool.__weakref__
SastUsageBasic
SastUsageBasic.exclude
SastUsageBasic.__init__()
SastUsageBasic.__load_tool_schema()
SastUsageBasic.__generate_tools()
SastUsageBasic.__load_tools()
SastUsageBasic.__build_lang_tools()
SastUsageBasic._detect_sast_tools()
SastUsageBasic._calc_score()
SastUsageBasic.run()
SastUsageBasic.__annotations__
SastUsageBasic.__module__
- src.checks.secrets module
DetectSecretsSecret
DetectSecrets
DetectSecrets.__init__()
DetectSecrets.check_file()
DetectSecrets._get_baseline_dir()
DetectSecrets._get_baseline_file()
DetectSecrets.maybe_load_baseline()
DetectSecrets.create_or_overwrite_baseline()
DetectSecrets.update_baseline()
DetectSecrets.diff_vs_baseline()
DetectSecrets.delete_baseline()
DetectSecrets.check_files()
DetectSecrets.detected_secrets
DetectSecrets.__annotations__
DetectSecrets.__module__
Secrets
_custom_settings()
- Module contents
Submodules¶
src.config module¶
Module that loads the tool’s runtime configuration from a file and makes it accessible to other modules.
- class src.config.Singleton(*args: Any, **kw: Dict[str, Any])[source]¶
Bases:
object
- Parameters:
args (Any) –
kw (Dict[str, Any]) –
- static __new__(cls, *args: Any, **kw: Dict[str, Any])[source]¶
- Parameters:
args (Any) –
kw (Dict[str, Any]) –
- __dict__¶
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
- class src.config.Context(*args: Any, **kw: Dict[str, Any])[source]¶
Bases:
Singleton
- Attributes:
- settings: mapping of detected runtime configuration options to their
values. key naming scheme is <section>_<name>
- config_file_name: str¶
- config_file_locations: List[Path]¶
- _transform_setting(setting_name: str, new_type: Type[Any]) None [source]¶
- Parameters:
setting_name (str) –
new_type (Type[Any]) –
- Return type:
None
- __annotations__¶
- __module__¶
- _instance¶
src.dashboard module¶
- class src.dashboard.DashboardColumns(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
- ID¶
- NAME¶
- COMMITS¶
- LAST_UPDATE¶
- BRANCHES¶
- ISSUES¶
- CONTRIBUTORS¶
- USERS¶
- STARS¶
- LANGUAGES¶
- LOC¶
- __module__¶
- class src.dashboard.Dashboard(oc: OpenCode)[source]¶
Bases:
object
- Parameters:
oc (OpenCode) –
- dashboard_file_path: Path¶
- pl_whitelist_path: Path¶
- pl_whitelist_wiki_path: Path¶
- pl_whitelist_manual: Set[str]¶
- pl_blacklist_manual: Set[str]¶
- repo_blacklist_manual: Set[int]¶
- dashboard_columns: List[Tuple[str, Type]]¶
- class dashboardColumns(id, Name, Commits, LastUpdate, Branches, Issues, Contributors, Users, Stars, Languages, LOC)¶
Bases:
tuple
- Parameters:
id (int) –
Name (str) –
Commits (int) –
LastUpdate (str) –
Branches (int) –
Issues (int) –
Contributors (int) –
Users (int) –
Stars (int) –
Languages (str) –
LOC (str) –
- Branches: int¶
Alias for field number 4
- Commits: int¶
Alias for field number 2
- Contributors: int¶
Alias for field number 6
- Issues: int¶
Alias for field number 5
- LOC: str¶
Alias for field number 10
- Languages: str¶
Alias for field number 9
- LastUpdate: str¶
Alias for field number 3
- Name: str¶
Alias for field number 1
- Stars: int¶
Alias for field number 8
- Users: int¶
Alias for field number 7
- __annotations__¶
- __getnewargs__()¶
Return self as a plain tuple. Used by copy and pickle.
- __match_args__¶
- __module__¶
- static __new__(_cls, id: int, Name: str, Commits: int, LastUpdate: str, Branches: int, Issues: int, Contributors: int, Users: int, Stars: int, Languages: str, LOC: str)¶
Create new instance of dashboardColumns(id, Name, Commits, LastUpdate, Branches, Issues, Contributors, Users, Stars, Languages, LOC)
- Parameters:
id (int) –
Name (str) –
Commits (int) –
LastUpdate (str) –
Branches (int) –
Issues (int) –
Contributors (int) –
Users (int) –
Stars (int) –
Languages (str) –
LOC (str) –
- __repr__()¶
Return a nicely formatted representation string
- __slots__¶
- _asdict()¶
Return a new dict which maps field names to their values.
- _field_defaults¶
- _fields¶
- classmethod _make(iterable)¶
Make a new dashboardColumns object from a sequence or iterable
- _replace(**kwds)¶
Return a new dashboardColumns object replacing specified fields with new values
- id: int¶
Alias for field number 0
- _maybe_create_pl_whitelist() bool [source]¶
cloc also counts stuff that’s not a PL, use a whitelist to filter its output
- Return type:
bool
- _iter_dashboard() Iterable[dashboardColumns] [source]¶
- Return type:
Iterable[dashboardColumns]
- _pl_print_cvs(result: List[Tuple[str, float]]) None [source]¶
- Parameters:
result (List[Tuple[str, float]]) –
- Return type:
None
- run(args_dict: Dict[str, Any]) None [source]¶
- Parameters:
args_dict (Dict[str, Any]) –
- Return type:
None
- __annotations__¶
- __dict__¶
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
src.exceptions module¶
Exceptions that might be raised by core or check code.
- exception src.exceptions.CoreGoesBoomException[source]¶
Bases:
Exception
Raised if core code encounters an unrecoverable error (uncaught).
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
- exception src.exceptions.CheckGoesBoomException[source]¶
Bases:
Exception
Raise this exception if your check exploded. (at runtime)
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
src.interfaces module¶
Collection of all interfaces
- class src.interfaces.Named[source]¶
Bases:
object
- class property name: str¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- __dict__¶
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
- class src.interfaces.CheckInterface(proj: Project, repo: Repo, api: Gitlab)[source]¶
Bases:
Named
Represents a check that can be applied to a repository @schema: JSON schema that results of this check must adhere to
- Parameters:
proj (Project) –
repo (Repo) –
api (Gitlab) –
- exclude: Pattern[str] | None¶
- __init__(proj: Project, repo: Repo, api: Gitlab)[source]¶
- Parameters:
proj (Project) –
repo (Repo) –
api (Gitlab) –
- _get_resource_dir() Path [source]¶
- Returns:
The root of this check’s personal resource directory.
- Return type:
Path
- _gen_file_list() Generator[Path, None, None] [source]¶
Helper to generate a list of all _relevant_ files in a project. Skips all files whose - name matches the self.exclude pattern - path relative to the project root matches self.exclude_path pattern
- Returns:
Iterator over all files in the project
- Return type:
Generator[Path, None, None]
- run(args_dict: Dict[str, Any] | None = None) Dict[str, Any] [source]¶
- Parameters:
args_dict (Dict[str, Any] | None) –
- Return type:
Dict[str, Any]
- property description: Dict[str, Any]¶
- results_valid(results: Dict[str, Any]) bool [source]¶
Validates the tool-specific results of a run against the corresponding JSON schema returns: true iff the results match the schema
- Parameters:
results (Dict[str, Any]) –
- Return type:
bool
- __annotations__¶
- __module__¶
src.opencode module¶
Module which provides the methods that correspond to the subcommands of occmd
- class src.opencode.OpenCode[source]¶
Bases:
object
Class which provides the methods that correspond to the subcommands of occmd
- url_opencode: str¶
- apikey: str | None¶
- p_db_raw: Path¶
- property users: List[RESTObject] | RESTObjectList¶
returns: All users registered on the OpenCoDE platform Note: might not work if they change the API config
- property projects: List[RESTObject] | RESTObjectList¶
returns: All projects listed on the OpenCoDE platform
- get_project_by_id(_id: int) Project [source]¶
Get meta information about a project from its id
- Parameters:
_id (int) –
- Return type:
Project
- iter_projects(filter_func: ~typing.Callable[[~gitlab.base.RESTObject, ~git.repo.base.Repo], bool] = <function OpenCode.<lambda>>, _id: int | None = None, directory: ~pathlib.Path | None = None) Generator[Tuple[RESTObject, Repo], None, None] [source]¶
- Parameters:
filter_func (Callable[[RESTObject, Repo], bool]) – skip project if this functions maps it to True
_id (int | None) – optional, Gitlab id of the project specified via ‘directory’ parameter
directory (Path | None) – optional, local file system location of git root of project specified via ‘id’ parameter
- Returns:
Api objects and local repo objects for all projects on OpenCoDE. Optionally: Only generates a single tuple for the project specified by ‘id’ and ‘directory’ parameters.
- Return type:
Generator[Tuple[RESTObject, Repo], None, None]
- dashboard(*args, **kwargs) None [source]¶
Visualize the state of the platform as a table.
- Return type:
None
- _construct_check_filter(check: str | None = None) Callable[[Type[CheckInterface]], bool] [source]¶
- returns:
Function on checks that returns True IFF the check should be skipped. Default: skip no checks
- Parameters:
check (str | None) –
- Return type:
Callable[[Type[CheckInterface]], bool]
- _construct_repo_filter(repo_id: int | None = None) Callable[[RESTObject, Repo], bool] [source]¶
- returns:
Function on repository API instance and local instance that returns True IFF the repository should be skipped. Default: skip no repositories
- Parameters:
repo_id (int | None) –
- Return type:
Callable[[RESTObject, Repo], bool]
- check(*args, **kwargs) None [source]¶
Performs a set of checks on a set of repositories.
- Return type:
None
- __annotations__¶
- __dict__¶
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
src.opencode_git module¶
Module to interact with OpenCoDE platform via git command line tool
- class src.opencode_git.OpenCodeGit[source]¶
Bases:
object
Class to interact with OpenCoDE platform via git command line tool
- username: str¶
- apikey: str | None¶
- classmethod clone_project(http_url: str, local_path: Path) None [source]¶
- Parameters:
http_url (str) –
local_path (Path) –
- Return type:
None
- __annotations__¶
- __dict__¶
- __module__¶
- __weakref__¶
list of weak references to the object (if defined)
src.utils module¶
- src.utils.camel_to_snake(s: str) str [source]¶
Converts a string from CamelCase to snake_case. Does not handle many of the special cases.
- Parameters:
s (str) –
- Return type:
str
- src.utils.dir_list(repo: Repo, dir_predicate: Callable[[str], bool]) Iterable[Path] [source]¶
Searches the project for directories that match the dir_predicate. If a directory matches its subtree is not explored for more matching directories.
- Parameters:
repo (Repo) – The local checkout of the project.
dir_predicate (Callable[[str], bool]) – Function that receives the directory name and returns True iff the spanned subtree should be yielded.
- Return type:
Iterable[Path]
- src.utils.file_list(repo: ~git.repo.base.Repo, file_name_filter: ~typing.Callable[[str], bool] = <function <lambda>>, path_component_filter: ~typing.Callable[[str], bool] = <function <lambda>>, root: ~pathlib.Path | None = None, recursive: bool = True) Iterable[Path] [source]¶
Generates a list of all files in a project. Optionally, the yielded files can be filtered based on path components or file name. The function can also be restricted to a subtree.
- Parameters:
repo (Repo) – The local checkout of the project.
file_name_filter (Callable[[str], bool]) – Function that receives a file name and returns True iff the file should be skipped.
path_component_filter (Callable[[str], bool]) – Function that receives the name of a directory and returns True iff the whole directory should be skipped.
root (Path | None) – Optionally, search only the subtree rooted at root
recursive (bool) – Iterate through folders recursively
- Returns:
Iterator over all files in the project
- Return type:
Iterable[Path]