Skip to content

Commit

Permalink
Use checkpoint signature for error reporting in sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Feb 14, 2020
1 parent 549b9fa commit b579286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
1 change: 1 addition & 0 deletions cli/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@prisma/get-platform": "workspace:*",
"archiver": "3.0.0",
"chalk": "^3.0.0",
"checkpoint-client": "^1.0.7",
"execa": "^3.4.0",
"flat-map-polyfill": "^0.3.8",
"globby": "^9.2.0",
Expand Down
27 changes: 3 additions & 24 deletions cli/sdk/src/sendPanic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getPlatform } from '@prisma/get-platform'
import archiver from 'archiver'
import crypto from 'crypto'
import Debug from 'debug'
import fs from 'fs'
import globby from 'globby'
Expand All @@ -9,6 +8,7 @@ import os from 'os'
import path from 'path'
import stripAnsi from 'strip-ansi'
import tmp from 'tmp'
import * as checkpoint from 'checkpoint-client'
import { maskSchema } from './utils/maskSchema'
import { RustPanic, ErrorArea } from './panic'
import { getProxyAgent } from '@prisma/fetch-engine'
Expand Down Expand Up @@ -64,7 +64,7 @@ export async function sendPanic(
platform: await getPlatform(),
liftRequest: JSON.stringify(error.request),
schemaFile: maskedSchema,
fingerprint: getFid() || undefined,
fingerprint: getFid(),
sqlDump,
})

Expand Down Expand Up @@ -212,27 +212,6 @@ async function request(query: string, variables: any): Promise<any> {
})
}

function getMac(): string | null {
const interfaces = os.networkInterfaces()
return Object.keys(interfaces).reduce<null | string>((acc, key) => {
if (acc) {
return acc
}
const i = interfaces[key]
const mac = i.find(a => a.mac !== '00:00:00:00:00:00')
return mac ? mac.mac : null
}, null)
}

export function getFid() {
const mac = getMac()
const fidSecret = 'AhTheeR7Pee0haebui1viemoe'
if (mac) {
return crypto
.createHmac('sha256', fidSecret)
.update(mac)
.digest('hex')
}

return null
return checkpoint.signature.sync()
}

0 comments on commit b579286

Please sign in to comment.