Skip to content

Security

invoke_tasklib.security

Security scanning task (security.audit).

The audit is read-only: it exports the lock file to a temporary file and never changes the environment or a tracked file.

invoke_tasklib.security.NAMESPACE module-attribute

NAMESPACE = 'security'

The name of the namespace of the tasks of this module.

invoke_tasklib.security.audit

audit(c: Context, *, args: str | None = None) -> None

Audit the locked dependencies for known vulnerabilities.

The dependencies of uv.lock, with all the optional dependencies (extras) and all the dependency groups, are exported to a temporary requirements file, which is audited with pip-audit (run with uvx, so it does not have to be a dependency of the project, in the range _PIP_AUDIT_REQUIREMENT). Unlike uv run pip-audit, this does not sync or modify the environment, and the result does not depend on what was installed last.

Parameters:

Name Type Description Default
c Context

The invoke context.

required
args str | None

Extra arguments passed to pip-audit, e.g. "--ignore-vuln PYSEC-2024-1".

None

Raises:

Type Description
UnexpectedExit

If the lock file is out of date, or if a vulnerability is found.