SAFE - Security Analysis For Elixir
A Mix task that brings SAFE security vulnerability scanning to Elixir/Mix projects. ó
Installation
Add the plugin to your mix.exs dependencies:
defp deps do
[
{:mix_safe, "~> 1.0", only: [:dev, :test], runtime: false}
]
endThen fetch dependencies:
mix deps.getUsage
mix safe <subcommand> [options]Subcommands
| Subcommand | Description |
|---|---|
fingerprint | Run the SAFE fingerprint phase |
analyse | Run the SAFE analysis phase |
download | Download the SAFE binary without running a scan |
version | Print the plugin version and the SAFE binary version |
help | Print usage information |
Typical workflow
1. Fingerprint your project
$ mix safe fingerprint
* checking your project's structure
* Discovered 1 app(s): [:my_app]
{
"output": ["stdio", "file"],
"version": "1.1",
"project": {
"name": "my_app",
"apps": [{"name": "my_app", "app_file": "mix.exs", "additional_includes": []}],
"paths": ["_build/dev/lib/my_app/ebin"]
}
}
Would you like to proceed with this configuration? [y/N]: y
* running SAFE fingerprint
* SAFE fingerprint complete2. Analyse for vulnerabilities
$ mix safe analyse
* Using config from .safe/config.json
* running SAFE analysis
* SAFE analysis complete - no vulnerabilities foundBinary management
The SAFE binary is downloaded automatically on first use and stored at:
<project_root>/_build/safe/safe
The resolved version is pinned in safe.lock at the project root (commit this file to version control). On later runs the binary is not re-downloaded as long as the file is present.
Skipping the download
mix safe downloadUseful in CI pipelines where you want to cache the binary separately from the scan step.
Configuration file
mix safe fingerprint generates .safe/config.json in the project root.
{
"output": ["stdio", "file"],
"version": "1.1",
"project": {
"name": "my_app",
"apps": [
{
"name": "my_app",
"app_file": "mix.exs",
"additional_includes": []
}
],
"paths": ["_build/dev/lib/my_app/ebin"]
}
}
You can edit this file before re-running. If it exists when mix safe fingerprint is called, the plugin will ask whether to reuse it.
Umbrella projects
Umbrella projects are supported. Each child app under apps/ contributes one entry to the apps list, and paths is set to the longest common prefix of all child ebin directories.
Exit codes
| Code | Meaning |
|---|---|
0 | Success / no vulnerabilities found |
1 | Error (download failure, bad config, unsupported platform, …) |
2 | Vulnerabilities found |