Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REPLAY_BACKEND_REV
Original file line number Diff line number Diff line change
@@ -1 +1 @@
867025c7c0fd74f655fb84d25492276026f8e5c1
0573bb4ca48f2b919b67a6bec3c7c289c8628956
39 changes: 2 additions & 37 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,7 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
return 0;
}

static void (*gRecordReplayAttach)(const char* dispatchAddress, const char* buildId);
static void (*gRecordReplaySetApiKey)(const char* apiKey);
static void (*gRecordReplayAttach)(const char* buildId);
static void (*gRecordReplayRecordCommandLineArguments)(int*, char***);
static void (*gRecordReplaySaveRecording)(const char* dir);
static void (*gRecordReplayRememberRecording)();
Expand Down Expand Up @@ -1129,44 +1128,14 @@ static void InitializeRecordReplay(int* pargc, char*** pargv) {
return;
}

const char* dispatchAddress = getenv("RECORD_REPLAY_SERVER");
if (!dispatchAddress) {
// 4/21/2021: For backwards compatibility we also check an older env
// var used to indicate the dispatch server.
dispatchAddress = getenv("RECORD_REPLAY_DISPATCH");
}

void* handle = OpenDriverHandle();

if (!handle) {
fprintf(stderr, "Loading Record Replay driver failed (%s).\n", dlerror());
return;
}

size_t keySize = 100;
std::vector<char> apiKeyData(keySize, '\0');
int ret = uv_os_getenv("RECORD_REPLAY_API_KEY", apiKeyData.data(), &keySize);

if (ret == UV_ENOBUFS) {
apiKeyData.resize(keySize, '\0');
ret = uv_os_getenv("RECORD_REPLAY_API_KEY", apiKeyData.data(), &keySize);
}

bool hasApiKey = false;
std::string apiKey;
if (ret >= 0) {
hasApiKey = true;
apiKey = std::string(apiKeyData.data(), keySize);
// Unsetting the env var will make the variable unavailable via
// uv_os_getenv and such, and also mutates the 'environ' global, so
// by the time gRecordReplayAttach runs, it will have no idea that
// this value existed and won't capture it in the recording itself,
// which is ideal for security.
CHECK(!uv_os_unsetenv("RECORD_REPLAY_API_KEY"));
}

RecordReplayLoadSymbol(handle, "RecordReplayAttach", gRecordReplayAttach);
RecordReplayLoadSymbol(handle, "RecordReplaySetApiKey", gRecordReplaySetApiKey);
RecordReplayLoadSymbol(handle, "RecordReplayRecordCommandLineArguments",
gRecordReplayRecordCommandLineArguments);
RecordReplayLoadSymbol(handle, "RecordReplaySaveRecording", gRecordReplaySaveRecording);
Expand All @@ -1183,12 +1152,8 @@ static void InitializeRecordReplay(int* pargc, char*** pargv) {
RecordReplayLoadSymbol(handle, "RecordReplayJSONToString", gJSONToString);
RecordReplayLoadSymbol(handle, "RecordReplayJSONFree", gJSONFree);

if (gRecordReplaySetApiKey && hasApiKey) {
gRecordReplaySetApiKey(apiKey.c_str());
}

if (gRecordReplayAttach && gRecordReplayFinishRecording) {
gRecordReplayAttach(dispatchAddress, gBuildId);
gRecordReplayAttach(gBuildId);
gRecordReplayRecordCommandLineArguments(pargc, pargv);
v8::recordreplay::SetRecordingOrReplaying(handle);

Expand Down
Loading