Skip to content

MayR-Labs/secureflow-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” SecureFlow CLI

SecureFlow is a lightweight, cross-platform CLI tool for securely encrypting and decrypting sensitive files using AES-256 encryption. Built with Go, it provides a simple, reliable way to manage secrets in your projects and CI/CD pipelines.

Perfect for: Environment variables, keystores, SSL certificates, service credentials, API keys, database passwords, and any sensitive configuration files.


✨ Why SecureFlow?

  • πŸ”’ Strong Security: AES-256-CBC encryption with PBKDF2 key derivation (OpenSSL-compatible)
  • πŸš€ Fast & Lightweight: Single binary, no dependencies, instant startup
  • 🌍 Cross-Platform: Works on Linux, macOS, and Windows
  • πŸ€– CI/CD Ready: Non-interactive mode designed for automation
  • πŸ“ Configuration-Based: Simple YAML config for managing multiple files
  • πŸ§ͺ Safe Testing: Test decryption without overwriting existing files
  • πŸ“Š Detailed Reports: Track what's encrypted, when, and metadata
  • πŸ’ͺ Production-Ready: Battle-tested, reliable error handling

πŸ“‹ Table of Contents


πŸš€ Quick Start

# 1. Install SecureFlow (Linux/macOS)
curl -sSL https://raw.githubusercontent.com/MayR-Labs/secureflow-go/main/install.sh | bash

# 2. Initialize configuration
cd your-project
secureflow init

# 3. Edit secureflow.yaml to list your sensitive files
vim secureflow.yaml

# 4. Encrypt your files
secureflow encrypt

# 5. Commit encrypted files to git
git add enc_keys/ secureflow.yaml
git commit -m "Add encrypted secrets"

# 6. Add originals to .gitignore
echo ".env.prod" >> .gitignore

That's it! Your secrets are now encrypted and safe to commit. Your team can decrypt them with:

secureflow decrypt

πŸ”§ Installation

Quick Install (Linux/macOS)

The easiest way to install SecureFlow:

curl -sSL https://raw.githubusercontent.com/MayR-Labs/secureflow-go/main/install.sh | bash

Or with wget:

wget -qO- https://raw.githubusercontent.com/MayR-Labs/secureflow-go/main/install.sh | bash

Manual Installation

Download Pre-built Binary

Download the appropriate binary for your OS from the Releases page.

Linux (AMD64):

wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-linux-amd64
chmod +x secureflow-linux-amd64
sudo mv secureflow-linux-amd64 /usr/local/bin/secureflow

macOS (Intel):

wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-darwin-amd64
chmod +x secureflow-darwin-amd64
sudo mv secureflow-darwin-amd64 /usr/local/bin/secureflow

macOS (Apple Silicon):

wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-darwin-arm64
chmod +x secureflow-darwin-arm64
sudo mv secureflow-darwin-arm64 /usr/local/bin/secureflow

Windows: Download secureflow-windows-amd64.exe from the Releases page and add it to your PATH.

Build from Source

git clone https://github.com/MayR-Labs/secureflow-go.git
cd secureflow-go
go build -o secureflow
sudo mv secureflow /usr/local/bin/

Local Installation for CI/CD

SecureFlow provides a convenient install-local command that sets up a portable installation without requiring system-wide installation. This is perfect for CI/CD pipelines where you can't or don't want to install binaries globally.

# Run this once to set up local installation
secureflow install-local

This command will:

  • Download platform-specific executables (Linux, macOS, Windows) to .secureflow/ directory
  • Create a secureflow.sh launcher script in the current directory
  • The launcher automatically detects your platform and runs the correct executable

Usage in CI/CD:

# In your CI/CD pipeline
./secureflow.sh decrypt --password "$SECUREFLOW_PASSWORD" --non-interactive
./secureflow.sh encrypt --password "$SECUREFLOW_PASSWORD" --non-interactive

Benefits:

  • βœ… No system installation required
  • βœ… Works across different platforms automatically
  • βœ… Portable - commit .secureflow/ and secureflow.sh to your repo
  • βœ… Perfect for CI/CD environments with restricted permissions

Example: Using in GitHub Actions

Option A: Install during CI/CD run

steps:
  - uses: actions/checkout@v3
  
  - name: Setup SecureFlow locally
    run: |
      wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-linux-amd64
      chmod +x secureflow-linux-amd64
      ./secureflow-linux-amd64 install-local
  
  - name: Decrypt secrets
    run: ./secureflow.sh decrypt --password "${{ secrets.SECUREFLOW_PASSWORD }}" --non-interactive

Option B: Commit installation to repo (no CI/CD setup needed)

# Run locally once
secureflow install-local
git add .secureflow/ secureflow.sh
git commit -m "Add portable SecureFlow"

Then your CI/CD workflow is simply:

steps:
  - uses: actions/checkout@v3
  
  - name: Decrypt secrets
    run: ./secureflow.sh decrypt --password "${{ secrets.SECUREFLOW_PASSWORD }}" --non-interactive

Verify Installation

secureflow --version

πŸ’» Usage

Initialize Configuration

Create a default secureflow.yaml configuration file:

secureflow init

Use a project template for quick setup:

# Interactive template selection
secureflow init

# Or specify a template directly
secureflow init --template flutter
secureflow init --template reactnative
secureflow init --template web
secureflow init --template docker
secureflow init --template k8s
secureflow init --template microservices

Available templates:

  • default - React Native/Mobile app with Android/iOS files
  • reactnative - React Native specific configuration
  • flutter - Flutter mobile app configuration
  • web - Web application with multiple environments
  • docker - Docker deployment configuration
  • k8s - Kubernetes secrets configuration
  • microservices - Microservices architecture with multiple services

All templates include copy_to: .env for .env.prod files to automatically create .env after decryption.

This generates a configuration file like:

# secureflow.yaml (Flutter template example)
output_dir: enc_keys
test_output_dir: test_dec_keys

files:
  - input: .env.prod
    output: .env.prod.encrypted
    copy_to: .env
  - input: android/app/keystore.jks
    output: keystore.jks.encrypted

Edit this file to match your project's sensitive files.

Encrypt Files

Interactive mode (prompts for password and optional hint):

secureflow encrypt

Non-interactive mode (for scripts and CI/CD):

secureflow encrypt --password "your_password" --non-interactive

Custom config file:

secureflow encrypt --config ./path/to/custom-config.yaml

All encrypted files are saved to enc_keys/ (or your configured output_dir).

Decrypt Files

Interactive mode:

secureflow decrypt

Non-interactive mode (for CI/CD):

secureflow decrypt --password "$ENCRYPTION_PASSWORD" --non-interactive

Custom config file:

secureflow decrypt --config ./custom-config.yaml

Test Decryption

Test decryption without overwriting existing files (decrypts to test_dec_keys/):

secureflow test

Or non-interactively:

secureflow test --password "your_password" --non-interactive

View Help

secureflow --help
secureflow init --help
secureflow encrypt --help
secureflow decrypt --help
secureflow test --help
secureflow install-local --help

πŸ“ Configuration

SecureFlow uses a YAML configuration file (secureflow.yaml) to define which files to encrypt/decrypt.

Basic Configuration

output_dir: enc_keys           # Where encrypted files are stored
test_output_dir: test_dec_keys # Where test decryption outputs go

files:
  - input: .env.production       # Source file (relative to project root)
    output: .env.production.encrypted  # Encrypted filename
    copy_to: .env                # (Optional) Copy decrypted file to this path

  - input: config/database.yml
    output: database.yml.encrypted
    
  - input: ssl/private.key
    output: ssl-private.key.encrypted

Configuration Options

  • output_dir: Directory for encrypted files (committed to git)
  • test_output_dir: Directory for test decryption (added to .gitignore)
  • files: Array of file entries
    • input: Path to source file (relative to project root)
    • output: Encrypted filename (just filename, not path)
    • copy_to: (Optional) Copy decrypted file to this path - useful when apps expect .env but you store .env.prod

The copy_to Feature

When decrypting files, SecureFlow can automatically copy the decrypted file to another location. This is particularly useful for environment files where your application expects .env but you store .env.prod or .env.production:

files:
  - input: .env.prod
    output: .env.prod.encrypted
    copy_to: .env  # Automatically creates .env from .env.prod after decryption

After decryption, both .env.prod and .env will exist with identical content.

Example Configurations

See the Configuration Guide for detailed examples including:

  • Mobile apps (Flutter, React Native)
  • Web applications
  • Microservices
  • Docker deployments
  • Kubernetes secrets
  • Multi-environment setups

Quick example configs:


πŸ€– CI/CD Integration

SecureFlow is designed to work seamlessly in CI/CD pipelines with its non-interactive mode.

Method 1: Local Installation (Recommended)

The easiest approach for CI/CD is to use install-local which creates a portable installation.

Approach A: Download and install during each CI/CD run

name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      # Download and setup SecureFlow (no sudo required)
      - name: Setup SecureFlow
        run: |
          wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-linux-amd64
          chmod +x secureflow-linux-amd64
          ./secureflow-linux-amd64 install-local
      
      # Use the launcher script
      - name: Decrypt secrets
        run: |
          ./secureflow.sh decrypt --password "${{ secrets.SECUREFLOW_PASSWORD }}" --non-interactive
      
      # Build and deploy
      - name: Build & Deploy
        run: |
          npm run build
          ./deploy.sh

Approach B: Commit the local installation to your repo (Recommended for simplicity)

Run secureflow install-local once locally, then commit the files:

# Run locally (one-time setup)
secureflow install-local
git add .secureflow/ secureflow.sh
git commit -m "Add portable SecureFlow installation"
git push

Your CI/CD workflow becomes very simple (no installation step needed):

name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      # No installation needed - files are already in the repo!
      - name: Decrypt secrets
        run: |
          ./secureflow.sh decrypt --password "${{ secrets.SECUREFLOW_PASSWORD }}" --non-interactive
      
      # Build and deploy
      - name: Build & Deploy
        run: |
          npm run build
          ./deploy.sh

Method 2: Global Installation

name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      # Install SecureFlow globally
      - name: Install SecureFlow
        run: |
          wget https://github.com/MayR-Labs/secureflow-go/releases/latest/download/secureflow-linux-amd64
          chmod +x secureflow-linux-amd64
          sudo mv secureflow-linux-amd64 /usr/local/bin/secureflow
      
      # Decrypt secrets
      - name: Decrypt secrets
        run: |
          secureflow decrypt --password "${{ secrets.SECUREFLOW_PASSWORD }}" --non-interactive
      
      # Build and deploy
      - name: Build & Deploy
        run: |
          npm run build
          ./deploy.sh

Supported Platforms

SecureFlow works with all major CI/CD platforms:

  • GitHub Actions βœ…
  • GitLab CI βœ…
  • Bitbucket Pipelines βœ…
  • Jenkins βœ…
  • CircleCI βœ…
  • Azure Pipelines βœ…
  • Travis CI βœ…
  • Any CI/CD platform that can run shell commands βœ…

Complete CI/CD Guide

See our comprehensive CI/CD Usage Guide for:

  • Platform-specific setup instructions
  • Best practices for secrets management
  • Multi-environment configurations
  • Caching strategies
  • Security considerations
  • Troubleshooting CI/CD issues

πŸ“š Documentation

Comprehensive documentation is available in the docs/ directory:

Core Documentation

  • Configuration Guide - Detailed configuration options, examples, and best practices
  • CI/CD Usage Guide - Complete guide for integrating SecureFlow into your CI/CD pipelines
  • Security Guide - Security best practices, encryption details, and compliance considerations
  • Troubleshooting - Common issues, solutions, and debugging tips

Additional Resources


πŸ” Security

Encryption Details

  • Algorithm: AES-256-CBC (Advanced Encryption Standard, 256-bit)
  • Key Derivation: PBKDF2 with SHA-256
  • Format: OpenSSL-compatible (Salted__ header + 8-byte salt + encrypted data)
  • Compatibility: Files can be encrypted/decrypted with OpenSSL

Security Model

  • Passwords are never stored or logged
  • Strong encryption (AES-256-CBC) with proper key derivation (PBKDF2)
  • OpenSSL compatible - industry-standard format
  • Non-interactive mode for secure CI/CD integration
  • Clean password handling - passwords cleared from memory after use

Best Practices

βœ… DO:

  • Use strong passwords (16+ characters, mixed case, numbers, symbols)
  • Store passwords in password managers
  • Rotate passwords periodically (every 3-6 months)
  • Use different passwords for different environments
  • Keep plaintext secrets in .gitignore
  • Commit only encrypted files to version control

❌ DON'T:

  • Commit plaintext secrets to git
  • Share passwords via email or Slack
  • Reuse passwords across projects
  • Log or print passwords
  • Store passwords in code or config files

For comprehensive security guidance, see our Security Guide.


πŸ“Š Encryption Reports

Each encryption run generates a report.txt in your output directory with detailed metadata:

Encryption Report
=================
Note: Encrypted secrets for CI/CD
Password Hint: For the wise only
Created at: 2025-10-24
=================

File:           .env.prod
Encrypted As:   .env.prod.encrypted
Size (bytes):   348
Lines:          17
Last Modified:  2025-10-22 11:24:09
----------------------------------------

This helps you track:

  • What files are encrypted
  • When they were encrypted
  • Password hints for team reference
  • File sizes and metadata

🎯 Common Use Cases

Local Development

Decrypt secrets when setting up a new project:

# Clone project
git clone https://github.com/yourorg/your-project.git
cd your-project

# Install SecureFlow
curl -sSL https://raw.githubusercontent.com/MayR-Labs/secureflow-go/main/install.sh | bash

# Decrypt secrets (get password from team)
secureflow decrypt

CI/CD Deployment

Option 1: Using install-local (recommended)

# One-time setup
secureflow install-local

# In your CI/CD pipeline
./secureflow.sh decrypt --password ${{ secrets.SECUREFLOW_PASSWORD }} --non-interactive

Option 2: Global installation

- name: Decrypt secrets
  run: secureflow decrypt --password ${{ secrets.SECUREFLOW_PASSWORD }} --non-interactive

Portable CI/CD Setup

For teams that want a fully portable solution, commit the local installation to your repo:

# One-time setup in your repository
secureflow install-local
git add .secureflow/ secureflow.sh
git commit -m "Add portable SecureFlow installation"

# Your CI/CD config becomes very simple:
# - name: Decrypt secrets
#   run: ./secureflow.sh decrypt --password "$PASSWORD" --non-interactive

This approach:

  • βœ… No installation step needed in CI/CD
  • βœ… Works across all platforms automatically
  • βœ… Consistent versions across all environments
  • βœ… Faster CI/CD runs (no download/install time)

Team Onboarding

New team member joining:

  1. Install SecureFlow
  2. Clone repository
  3. Get decryption password from team lead (via secure channel)
  4. Run secureflow decrypt
  5. Start working!

Environment Management

Manage secrets across multiple environments:

# Production
secureflow encrypt --config secureflow.prod.yaml --password "$PROD_PASS"

# Staging
secureflow encrypt --config secureflow.staging.yaml --password "$STAGING_PASS"

# Development
secureflow encrypt --config secureflow.dev.yaml --password "$DEV_PASS"

🧩 Project Structure

secureflow-go/
β”‚
β”œβ”€β”€ cmd/                    # CLI commands (Cobra)
β”‚   β”œβ”€β”€ root.go            # Root command and global flags
β”‚   β”œβ”€β”€ encrypt.go         # Encryption command
β”‚   β”œβ”€β”€ decrypt.go         # Decryption command
β”‚   β”œβ”€β”€ test.go            # Test decryption command
β”‚   β”œβ”€β”€ init.go            # Initialize config command
β”‚   β”œβ”€β”€ install_local.go   # Local installation command
β”‚   └── secureflow.sh      # Launcher script template
β”‚
β”œβ”€β”€ internal/              # Internal packages
β”‚   β”œβ”€β”€ crypto/           # Encryption/decryption logic
β”‚   β”œβ”€β”€ config/           # Configuration handling
β”‚   └── utils/            # Utilities (file ops, logging)
β”‚
β”œβ”€β”€ docs/                 # Comprehensive documentation
β”‚   β”œβ”€β”€ configuration.md  # Configuration guide
β”‚   β”œβ”€β”€ cicd-usage.md    # CI/CD integration guide
β”‚   β”œβ”€β”€ security.md      # Security best practices
β”‚   └── troubleshooting.md # Troubleshooting guide
β”‚
β”œβ”€β”€ examples/             # Usage examples
β”‚   β”œβ”€β”€ README.md        # Practical examples
β”‚   └── configs.md       # Sample configurations
β”‚
β”œβ”€β”€ main.go              # Application entry point
β”œβ”€β”€ install.sh           # Installation script
β”œβ”€β”€ go.mod               # Go module definition
β”œβ”€β”€ LICENSE              # MIT License
└── README.md            # This file

🧱 Error Handling

SecureFlow provides clear, actionable error messages:

  • Missing files β†’ Warns and skips, continues with other files
  • Wrong password β†’ Clear error message with exit code 1
  • Invalid YAML β†’ Shows line number and syntax error
  • Missing directories β†’ Automatically creates them
  • Interrupts (Ctrl+C) β†’ Graceful exit with cleanup notice

πŸ§ͺ Development

Run Locally

go run main.go encrypt
go run main.go decrypt
go run main.go test
go run main.go init

Run Tests

go test ./...

With verbose output:

go test ./... -v

Build Binary

go build -o secureflow

Cross-compile for different platforms:

# Linux AMD64
GOOS=linux GOARCH=amd64 go build -o secureflow-linux-amd64

# macOS Intel
GOOS=darwin GOARCH=amd64 go build -o secureflow-darwin-amd64

# macOS Apple Silicon
GOOS=darwin GOARCH=arm64 go build -o secureflow-darwin-arm64

# Windows
GOOS=windows GOARCH=amd64 go build -o secureflow-windows-amd64.exe

🧭 Roadmap

Future enhancements we're considering:

  • Support for .env key filtering (only encrypt certain variables)
  • Optional GPG-based encryption backend
  • Progress bars for large files
  • Batch re-encryption command
  • Integration with Flutter build runners
  • Support for multiple encryption backends
  • Vault/secret manager integration
  • Shell completion scripts

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/AmazingFeature
  3. Make your changes
  4. Run tests: go test ./...
  5. Commit your changes: git commit -m 'Add some AmazingFeature'
  6. Push to the branch: git push origin feature/AmazingFeature
  7. Open a Pull Request

Development Guidelines

  • Follow Go best practices and conventions
  • Add tests for new features
  • Update documentation as needed
  • Keep commits focused and descriptive
  • Ensure all tests pass before submitting PR

πŸ“„ License

SecureFlow is licensed under the MIT License.

Copyright (c) 2025 MayR Labs


πŸ”— Links


πŸ™ Acknowledgments

SecureFlow is built with these excellent libraries:

  • Cobra - CLI framework
  • yaml.v3 - YAML parsing
  • Go standard library - Crypto, file I/O, and more

Special thanks to all contributors and users who help make SecureFlow better!


⭐ Star Us!

If you find SecureFlow useful, please consider giving us a star on GitHub! It helps others discover the project.

GitHub stars


Made with ❀️ by MayR Labs

About

A CLI app for encrypting flutter private assets to be decrypted on CI/CD actions

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •