Framework for Python

Git

git_security_audit()

Check that private data and secrets stay out of git.

Usage

git_security_audit(
    settings_file: str | Path | None = None,
    *,
    check_git_history: bool = True,
    history_depth: int | str = 'all',
    auto_fix: bool = False,
    verbose: bool = True,
    extensions: tuple[str, ...] | list[str] = (...),
) -> AuditResult

Arguments

Name Type Default Description
settings_file str | Path | None None

The project's settings file. Found from the current folder when omitted.

check_git_history bool True

Scan past commits for private data files.

history_depth int | str 'all'

"all", "shallow" (the last 100 commits), or a number of commits.

auto_fix bool False

Add private folders that are not ignored to .gitignore. Files git already tracks stay tracked: run git rm --cached.

verbose bool True

Print the report.

extensions tuple[str, ...] | list[str] ('csv', 'rds', 'tsv', 'txt', 'dat', 'xlsx', 'xls', 'sqlite', 'db', 'dta', 'sav', 'zsav', 'por', 'sas7bdat', 'sas7bcat', 'xpt', 'parquet', 'feather', 'arrow', 'json', 'xml', 'h5', 'hdf5')

File extensions that count as data files.

Value

An AuditResult. result.passed is False when a check failed. The result is also recorded in framework.db when it exists.