| Crates.io | magma-code |
| lib.rs | magma-code |
| version | 0.1.3 |
| created_at | 2025-06-26 09:07:06.624623+00 |
| updated_at | 2025-06-26 14:57:59.341298+00 |
| description | A CLI tool for ingesting code files into Magma scanner with smart file filtering and Git integration |
| homepage | https://github.com/bluemagma-compliance/magma-ingest |
| repository | https://github.com/bluemagma-compliance/magma-ingest |
| max_upload_size | |
| id | 1727060 |
| size | 126,163 |
A Rust-based CLI tool for ingesting code files into the Magma scanner system. This tool automatically collects source code files from your repository, respects ignore patterns, and packages them for analysis.
.magmaignore files to exclude unwanted filescargo install magma-code
# Download and install
curl -L -o magma-ingest https://github.com/bluemagma-compliance/magma-ingest/releases/latest/download/magma-ingest-linux-x86_64
chmod +x magma-ingest
sudo mv magma-ingest /usr/local/bin/
# Verify installation
magma-ingest --version
# Download and install
curl -L -o magma-ingest https://github.com/bluemagma-compliance/magma-ingest/releases/latest/download/magma-ingest-macos-x86_64
chmod +x magma-ingest
sudo mv magma-ingest /usr/local/bin/
# Verify installation
magma-ingest --version
# Download and install
curl -L -o magma-ingest https://github.com/bluemagma-compliance/magma-ingest/releases/latest/download/magma-ingest-macos-aarch64
chmod +x magma-ingest
sudo mv magma-ingest /usr/local/bin/
# Verify installation
magma-ingest --version
# Download and setup (run PowerShell as Administrator)
cd $env:USERPROFILE\Downloads
Invoke-WebRequest -Uri "https://github.com/bluemagma-compliance/magma-ingest/releases/latest/download/magma-ingest-windows-x86_64.exe" -OutFile "magma-ingest.exe"
# Create tools directory and move binary
mkdir C:\tools -Force
Move-Item "magma-ingest.exe" "C:\tools\magma-ingest.exe"
# Add to system PATH permanently
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "Machine")
if ($currentPath -notlike "*C:\tools*") {
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;C:\tools", "Machine")
Write-Host "✅ Added C:\tools to system PATH"
}
# Add to current session
$env:PATH += ";C:\tools"
# Verify installation
magma-ingest --version
# Download
cd ~/Downloads
curl -L -o magma-ingest.exe https://github.com/bluemagma-compliance/magma-ingest/releases/latest/download/magma-ingest-windows-x86_64.exe
# Setup directory (run in PowerShell as Administrator)
# powershell -Command "mkdir C:\tools -Force; Move-Item '$env:USERPROFILE\Downloads\magma-ingest.exe' 'C:\tools\magma-ingest.exe'; \$env:PATH += ';C:\tools'"
# Add to Git Bash PATH permanently
echo 'export PATH="$PATH:/c/tools"' >> ~/.bashrc
source ~/.bashrc
# Verify installation (restart Git Bash first)
magma-ingest --version
magma-ingest --version
Check if binary exists:
# Linux/macOS
ls -la /usr/local/bin/magma-ingest
ls -la ~/.local/bin/magma-ingest
# Windows
dir C:\tools\magma-ingest.exe
Check current PATH:
# Linux/macOS/Git Bash
echo $PATH
# Windows PowerShell
$env:PATH -split ';'
Manually run binary:
# Linux/macOS
/usr/local/bin/magma-ingest --version
~/.local/bin/magma-ingest --version
# Windows
C:\tools\magma-ingest.exe --version
Restart terminal/shell:
# Make sure binary is executable
chmod +x /usr/local/bin/magma-ingest
# or
chmod +x ~/.local/bin/magma-ingest
# Check if C:\tools is in PATH
$env:PATH -split ';' | Select-String "tools"
# Manually add for current session
$env:PATH += ";C:\tools"
# Restart PowerShell and try again
magma-ingest --org <organization-id> --key <api-key> --repo-name <repository-name>
magma-ingest \
--org my-org-123 \
--key sk-1234567890abcdef \
--repo-name my-awesome-project \
--root-path backend \
--ignore-file custom-ignore.txt \
--verbose
--org (required): Organization ID for the Magma scanner--key (required): API key for authentication--repo-name (required): Repository name for identification--root-path (optional): Root path to scan - use '/' for current directory or specify subdirectory--ignore-file (optional): Custom ignore file path (defaults to .magmaignore)--verbose (optional): Enable verbose loggingThe API base URL is configured in config.yaml (embedded in the binary) and defaults to http://localhost. The tool automatically:
The tool uses a .magmaignore file to specify which files and directories to exclude from scanning. The syntax is similar to .gitignore files and supports glob patterns.
The tool automatically ignores common files and directories:
.git, .svn, .hg)node_modules, target, build, __pycache__).vscode, .idea)*.exe, *.dll, *.so)*.zip, *.tar.gz)*.jpg, *.png, *.mp4)*.log)Create a .magmaignore file in your repository root to specify additional patterns:
# Custom ignores
config/secrets.json
*.env
temp/**
# Large data files
data/**
*.csv
# Documentation
docs/**
*.md
The tool performs the following actions:
--keep-zip to retain)The tool sends a multipart/form-data POST request to {api-base-url}/ingest/ingest/ with:
org_id: Organization identifierrepo_name: Repository namecommit_hash: Git commit hashbranch_name: Git branch nameroot_path: Repository root pathfile: Zip file containing source code and metadata{
"version": "1.0",
"timestamp": "2024-01-15T10:30:00Z",
"git": {
"branch": "main",
"commit_hash": "abc123...",
"commit_message": "Add new feature",
"author_name": "John Doe",
"author_email": "john@example.com"
},
"scan_info": {
"file_count": 150,
"tool_version": "0.1.0",
"tool_name": "magma-ingest"
}
}
name: Code Analysis
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install magma-ingest
run: cargo install --git <repository-url>
- name: Run Magma Ingest
run: magma-ingest --org ${{ secrets.MAGMA_ORG_ID }} --key ${{ secrets.MAGMA_API_KEY }}
stages:
- scan
magma_scan:
stage: scan
image: rust:latest
script:
- cargo install --git <repository-url>
- magma-ingest --org $MAGMA_ORG_ID --key $MAGMA_API_KEY
variables:
MAGMA_ORG_ID: $MAGMA_ORG_ID
MAGMA_API_KEY: $MAGMA_API_KEY
The tool provides clear error messages for common issues:
.magmaignore file syntaxUse the --verbose flag to enable detailed logging:
magma-ingest --org my-org --key my-key --verbose
This will show:
Magma-yeeter/
├── src/
│ ├── main.rs # Main application entry point
│ ├── cli.rs # Command-line argument parsing
│ ├── git.rs # Git repository integration
│ ├── ignore.rs # File ignore pattern management
│ ├── zipper.rs # File compression and packaging
│ └── error.rs # Error handling and types
├── examples/
│ ├── github-actions.yml # GitHub Actions workflow example
│ └── gitlab-ci.yml # GitLab CI configuration example
├── .magmaignore # Default ignore patterns
├── Cargo.toml # Rust project configuration
└── README.md # This file
# Debug build
cargo build
# Release build
cargo build --release
cargo test
# Development
cargo run -- --org test-org --key test-key
# Release binary
./target/release/magma-ingest --org test-org --key test-key
MIT License - see LICENSE file for details.