Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 267a4bd

Browse files
authored
feat: improve debuggee ids (#1097)
Firebase debuggee ids are now of the form: d-********
1 parent 98c7433 commit 267a4bd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/agent/firebase-controller.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ export class FirebaseController implements Controller {
133133

134134
// Calculate the debuggee id as the hash of the object.
135135
// This MUST be consistent across all debuggee instances.
136-
this.debuggeeId = crypto
137-
.createHash('md5')
136+
// TODO: JSON.stringify may provide different strings if labels are added
137+
// in different orders.
138+
const debuggeeHash = crypto
139+
.createHash('sha1')
138140
.update(JSON.stringify(debuggee))
139141
.digest('hex');
142+
this.debuggeeId = `d-${debuggeeHash.substring(0, 8)}`;
140143
debuggee.id = this.debuggeeId;
141144

142145
const debuggeeRef = this.db.ref(`cdbg/debuggees/${this.debuggeeId}`);

test/test-firebase-controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ describe('Firebase Controller', () => {
150150
describe('register', () => {
151151
it('should get a debuggeeId', done => {
152152
const db = new MockDatabase();
153-
// Debuggee Id is the md5 hash of the json representation of the debuggee.
154-
const debuggeeId = 'e1662bd77f69383284621966af8eb5e9';
153+
// Debuggee Id is based on the sha1 hash of the json representation of
154+
// the debuggee.
155+
const debuggeeId = 'd-b9dbb5e7';
155156
const controller = new FirebaseController(
156157
db as {} as firebase.database.Database
157158
);

0 commit comments

Comments
 (0)