diff --git a/README.md b/README.md index c78bcb0..0e0a9ad 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ const dotenv = require('dotenv') const provider = new ethers.providers.JsonRpcProvider(bscProvider) const evmPrivateKey = process.env.EVM_PRIVATE_KEY - console.log(evmPrivateKey) const signer = new ethers.Wallet(evmPrivateKey, provider) const bnbAddress = await signer.getAddress() diff --git a/src/__tests__/SecretLogging.test.ts b/src/__tests__/SecretLogging.test.ts new file mode 100644 index 0000000..ea4f0ba --- /dev/null +++ b/src/__tests__/SecretLogging.test.ts @@ -0,0 +1,18 @@ +import fs from 'fs' +import path from 'path' + +describe('secret handling examples', () => { + it('does not print EVM private keys in tests or documentation', () => { + const repoRoot = path.resolve(__dirname, '..', '..') + const filesToCheck = [ + 'README.md', + path.join('src', '__tests__', 'WBGL.test.ts') + ] + + for (const file of filesToCheck) { + const source = fs.readFileSync(path.join(repoRoot, file), 'utf8') + expect(source).not.toMatch(/console\.log\([^)]*EVM_PRIVATE_KEY/i) + expect(source).not.toMatch(/console\.log\([^)]*evmPrivateKey/i) + } + }) +}) diff --git a/src/__tests__/WBGL.test.ts b/src/__tests__/WBGL.test.ts index f07346d..8a20102 100644 --- a/src/__tests__/WBGL.test.ts +++ b/src/__tests__/WBGL.test.ts @@ -10,8 +10,6 @@ import WBGLBridgeSDK, { import { WBGLBGLExchangePair } from '../bridge/WBGL' expect.extend(matchers) - -console.log(process.env.evmPrivateKey) describe('WBGL class tests on Ethereum', () => { let WBGLSDKInstance: WBGLBridgeSDK