Created
December 21, 2023 20:37
-
-
Save sandalsoft/5eba1eddbc38c1fa61d646ebfe512dbd to your computer and use it in GitHub Desktop.
Simple check for passwords in db connection strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs' | |
import YAML from 'yaml' | |
const PasswordPresentRe = /(password=.+)&/; | |
const HasuraRootPath = `../standard-cloud-demo/metadata`; | |
const metdataString = fs.readFileSync(`${HasuraRootPath}/databases/databases.yaml`, 'utf8') | |
const metadata = YAML.parse(metdataString) | |
console.log() | |
console.log(`🔍 Checking Hasura Metadata for passwords in connection strings...\n`) | |
metadata.map((db: any) => { | |
const connString = db?.configuration?.value?.jdbc_url | |
const m = connString.match(PasswordPresentRe); | |
m | |
? console.warn(`\t❌ ${db.kind}/${db.name} - FAIL Password present in db config... Use Env Vars instead`) | |
: console.log(`\t✅ ${db.kind}/${db.name} - PASS`) | |
}); | |
console.log(`\nCheck complete. Metadata wi]l not be promoted if all checks do not pass...`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment