Awesome
<div align="center"> <img src="https://user-images.githubusercontent.com/11348/75812982-32921e80-5d5d-11ea-9c3b-ad46fd6005f9.png" width="500" /> <br /><br /> <code>MixAudit</code> provides a <code>mix deps.audit</code> task to scan Mix dependencies for security vulnerabilities. <br /> It draw its inspiration from tools like <a href="https://docs.npmjs.com/cli/audit"><code>npm audit</code></a> and <a href="https://github.com/rubysec/bundler-audit"><code>bundler-audit</code></a>. <br /><br /> <a href="https://github.com/mirego/mix_audit/actions?query=workflow%3ACI+branch%3Amain"><img src="https://github.com/mirego/mix_audit/workflows/CI/badge.svg?branch=main" /></a> <a href="https://hex.pm/packages/mix_audit"><img src="https://img.shields.io/hexpm/v/mix_audit.svg" /></a> </div>Installation
Project dependency
Add mix_audit
to the deps
function in your project’s mix.exs
file:
defp deps do
[
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}
]
end
Then run mix do deps.get, deps.compile
inside your project’s directory.
Local escript
If you do not wish to include mix_audit
in your project dependencies, you can install it as global escript
:
$ mix escript.install hex mix_audit
…
* creating …/.mix/escripts/mix_audit
The only difference is that instead of using the mix deps.audit
task, you will have to use the created executable.
Requirements
Usage
To generate a security report, you can use the deps.audit
Mix task:
$ mix deps.audit
Options
Option | Type | Default | Description |
---|---|---|---|
--path | String | Current directory | The root path of the project to audit |
--format | String | "human" | The format of the report to generate ("json" or "human" ) |
--ignore-advisory-ids | String | "" | Comma-separated list of advisory IDs to ignore |
--ignore-package-names | String | "" | Comma-separated list of package names to ignore |
--ignore-file | String | "" | Path of the ignore file |
Example
<img src="https://user-images.githubusercontent.com/11348/76112291-ea1e6f00-5faf-11ea-8337-6656d765b7fc.png">How does it work?
MixAudit builds two lists when it’s executed in a project:
- A list of security advisories fetched from the GitHub-sourced
elixir-security-advisories
repository - A list of Mix dependencies from the various
mix.lock
files in the project
Then, it loops through each project dependency and tries to find security advisories that apply to it (through its package name) and that match its version specification (through the advisory vulnerable version ranges).
If one is found, a vulnerability (the combination of a security advisory and a project dependency) is then added to the report.
The task will exit with a 0
status only if the report passes (ie. it reports no vulnerabilities). Otherwise, it will exit with a 1
status.
mix deps.audit
vs. mix hex.audit
Mix provides a mix hex.audit
task. According to its documentation, mix hex.audit
shows all dependencies that have been marked as retired.
MixAudit provides a mix deps.audit
task (similar to npm audit
and bundler-audit
) that scans dependencies for reported security vulnerabilities.
Both tasks are useful but they just don’t share the same purpose.
License
MixAudit
is © 2020 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md
file.
The detective hat logo is based on this lovely icon by Vectors Point, from The Noun Project. Used under a Creative Commons BY 3.0 license.
About Mirego
Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.
We also love open-source software and we try to give back to the community as much as we can.