Environment Variables
Hedis uses a.env file for configuration, automatically loaded via godotenv/autoload (see pkg/database/main.go:16).
Creating the Configuration File
Create a.env file in go/hermes-decompiler/:
Required Variables
MONGO_CONNECTION_STRING
Purpose: MongoDB connection URI for storing fingerprints and package metadata. Format: Standard MongoDB connection string. Examples:OS_HERMES
Purpose: Specifies the Hermes compiler binary platform for the pipeline. Values:osx-bin— macOS (Intel or Apple Silicon)linux64-bin— Linux x64
osx-bin (if not set)
How it’s used (from pkg/cmd/maintainDatabase.go:44):
- Running on a Linux server:
OS_HERMES=linux64-bin - Running on macOS:
OS_HERMES=osx-bin(default)
Optional Variables
MONGO_DB_NAME
Purpose: MongoDB database name for storing Hedis collections. Default:hedis
When to customize:
- Running multiple environments (dev, staging, prod)
- Separating vulnerable package data from general packages
GITHUB_TOKEN
Purpose: GitHub Personal Access Token for querying the Security Advisory API. Required for:maintain-database -s and maintain-database -g commands.
How to create:
Generate a PAT
Go to GitHub → Settings → Developer settings → Personal access tokens → Generate new token (classic)
Select scopes
Required scope:
public_repo(for accessing public security advisories)
read:org(if querying private organization advisories)
pkg/pipeline/security.go):
MongoDB Setup
Local Installation
- macOS
- Linux
- Docker
MongoDB Atlas (Cloud)
For production or remote access:Create a cluster
Sign up at mongodb.com/cloud/atlas and create a free M0 cluster.
Create database user
Database Access → Add New Database User
- Username:
hedis_user - Password: (generate strong password)
- Role:
Read and write to any database
Database Collections
Hedis uses these MongoDB collections (from README:23):| Collection | Purpose | Index Recommendations |
|---|---|---|
packages | npm package metadata (name, version, author, repository) | package_unique_id (unique) |
hashes | Function fingerprints per package per RN version | package_id, react_native_version, hash.structural_hash |
hashes_ghsa | Fingerprints for vulnerable packages only | Same as hashes |
baselines_v3 | Empty RN app fingerprints (framework functions) | react_native_version (unique) |
Creating Indexes
Optimize query performance:Verifying Configuration
Test MongoDB Connection
Test Hedis Connection
Troubleshooting
MONGO_CONNECTION_STRING is not set
MONGO_CONNECTION_STRING is not set
Cause: Missing
.env file or variable not defined.Solution:- Create
.envingo/hermes-decompiler/ - Add
MONGO_CONNECTION_STRING=... - Verify file location:
ls -la go/hermes-decompiler/.env
Failed to connect to MongoDB
Failed to connect to MongoDB
Cause: MongoDB not running or incorrect connection string.Solutions:
- Check MongoDB is running:
mongosh mongodb://localhost:27017 - Verify connection string format
- For Atlas: check IP whitelist and credentials
- Check network/firewall:
telnet localhost 27017
Error: Hermes compiler not found
Error: Hermes compiler not found
Cause: Verify compiler exists:
OS_HERMES points to wrong platform.Solution:GitHub API rate limit exceeded
GitHub API rate limit exceeded
Cause: Querying GitHub without authentication (60 requests/hour limit).Solution:
Add
GITHUB_TOKEN to .env (increases limit to 5000 requests/hour):Database queries are slow
Database queries are slow
Cause: Missing indexes on large collections.Solution:
Create indexes (see Creating Indexes above) and check query performance: