Skip to content

Commit

Permalink
chore: security hardening (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
633kh4ck authored Jan 24, 2024
1 parent 8e91cce commit af8ce4f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.github/ @ExodusMovement/auditors
/.github/*.md
/.github/SECURITY.md @ExodusMovement/auditors
4 changes: 4 additions & 0 deletions .github/workflows/asana.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Asana

on:
issues:
types: [opened, closed, edited]
pull_request:
types: [opened, closed, edited]

permissions: {}

jobs:
link:
name: Link
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
branches:
- master # Keeps the action's cache up-to-date to be shared with PRs

permissions:
contents: read

env:
DISABLE_NX_CACHE: ${{ contains(github.event.pull_request.labels.*.name, 'disable-nx-cache') && 'yes' || 'no' }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { solana: asset } = connectAssetsList(solanaAssets)

const keychain = keychainDefinition.factory({
logger: console,
legacyPrivToPub: {},
legacyPrivToPub: Object.create(null),
})

keychain.unlock({ seed })
Expand All @@ -43,7 +43,7 @@ const BOB_KEY = new KeyIdentifier({
test('unlock', async () => {
const keychain = keychainDefinition.factory({
logger: console,
legacyPrivToPub: {},
legacyPrivToPub: Object.create(null),
})

await expect(keychain.exportKey(solanaKeyId)).rejects.toThrow()
Expand All @@ -56,7 +56,7 @@ test('unlock', async () => {
test('lock', async () => {
const keychain = keychainDefinition.factory({
logger: console,
legacyPrivToPub: {},
legacyPrivToPub: Object.create(null),
})

keychain.unlock({ seed })
Expand Down
2 changes: 1 addition & 1 deletion features/keychain/module/__tests__/key-identifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('KeyIdentifier', () => {
const failures = [
null,
undefined,
{},
Object.create(null),
// Missing parameters

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe.each([
keyType: 'secp256k1',
}),
]
const unsignedTx = {}
const unsignedTx = Object.create(null)

await keychain.signTx(
keyIds,
Expand Down
6 changes: 3 additions & 3 deletions features/keychain/module/keychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Keychain extends ExodusModule {
#legacyPrivToPub = null

// TODO: remove default param. Use it temporarily for backward compatibility.
constructor({ legacyPrivToPub = {}, logger }) {
constructor({ legacyPrivToPub = Object.create(null), logger }) {
super({ name: MODULE_ID, logger })

throwIfInvalidLegacyPrivToPub(legacyPrivToPub)
Expand Down Expand Up @@ -62,7 +62,7 @@ export class Keychain extends ExodusModule {
return this.#masters[derivationAlgorithm].derive(derivationPath)
}

async exportKey(keyId, { exportPrivate } = {}) {
async exportKey(keyId, { exportPrivate } = Object.create(null)) {
const hdkey = this.#getPrivateHDKey(keyId)
const privateKey = hdkey.privateKey
let publicKey = hdkey.publicKey
Expand Down Expand Up @@ -128,7 +128,7 @@ export class Keychain extends ExodusModule {
}
}

const createKeychain = (args = {}) => new Keychain({ ...args })
const createKeychain = (args = Object.create(null)) => new Keychain({ ...args })

// eslint-disable-next-line @exodus/export-default/named
export default {
Expand Down
4 changes: 2 additions & 2 deletions features/keychain/module/memoized-keychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const getPublicKeyData = ({ xpub, publicKey }) => ({ xpub, publicKey })

class MemoizedKeychain extends Keychain {
#storage
#publicKeys = {}
#publicKeys = Object.create(null)
#cloneOpts
constructor({ storage, logger }) {
super({ id: MODULE_ID, logger })

this.#storage = storage
this.#storage.get(CACHE_KEY).then((data) => {
this.#publicKeys = data ? BJSON.parse(data) : {}
this.#publicKeys = data ? BJSON.parse(data) : Object.create(null)
})

this.#cloneOpts = { storage, logger }
Expand Down

0 comments on commit af8ce4f

Please sign in to comment.