Comparing version
#!/usr/bin/env node | ||
import { join, resolve } from 'path' | ||
@@ -6,5 +7,5 @@ import yargs from 'yargs' | ||
import { decryptWithEnv } from '../lib/decrypt-with-env.js' | ||
import { decryptWithFile } from '../lib/decrypt-with-file.js' | ||
import { encryptWithEnv } from '../lib/encrypt-with-env.js' | ||
import { encryptWithFile } from '../lib/encrypt-with-file.js' | ||
import { decryptWithFile } from '../lib/decrypt-with-file.js' | ||
import { printEncryptInfo } from '../lib/print-info.js' | ||
@@ -43,8 +44,4 @@ import { verifyEnviroment } from '../lib/verify-environment.js' | ||
const destPath = join(resolve(process.cwd(), argv?.destFolder), '.env') | ||
console.info({ | ||
srcPath, | ||
destPath | ||
}) | ||
if (status.agePrivateKey) { | ||
console.log('decryptWithEnv') | ||
decryptWithEnv(srcPath, destPath) | ||
@@ -51,0 +48,0 @@ } else if (status.sopsAgeKeyFile) { |
import { execSync } from "child_process"; | ||
import { readFileSync } from "fs"; | ||
export const decryptWithEnv = async (srcPath, destPath, SOPS_COMMAND = "sops") => { | ||
try { | ||
console.info(`export SOPS_AGE_KEY="${process?.env?.AGE_PRIVATE_KEY}" && unset SOPS_AGE_KEY_FILE && ${SOPS_COMMAND} --decrypt ${srcPath} > ${destPath}`) | ||
execSync(`export SOPS_AGE_KEY="${process?.env?.AGE_PRIVATE_KEY}" && unset SOPS_AGE_KEY_FILE && ${SOPS_COMMAND} --decrypt ${srcPath} > ${destPath}`); | ||
console.log(`Decrypted file: ${destPath}`, readFileSync(destPath, { encoding: 'utf-8' })); | ||
return true; | ||
@@ -10,0 +7,0 @@ } catch (error) { |
{ | ||
"name": "env-sops", | ||
"version": "0.0.0-20240306065803", | ||
"version": "0.0.0-20240306070710", | ||
"description": "Package to help encrypt/decrypt ENV files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10
-16.67%23055
-1.71%180
-4.26%