-
Notifications
You must be signed in to change notification settings - Fork 51
fix: refuse to start if working dir is root dir #381
fix: refuse to start if working dir is root dir #381
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit and PR should include 'Fixes:' metadata.
src/agent/debuglet.ts
Outdated
that.emit( | ||
'initError', | ||
new Error( | ||
`Cannot start the agent when the working directory is a root directory`)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/agent/debuglet.ts
Outdated
// Don't continue if the working directory is a root directory | ||
if (path.join(workingDir, '..') === workingDir) { | ||
that.logger.error( | ||
`Refusing to start with \`workingDirectory\` set to a root directory: '${ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-debuglet.ts
Outdated
@@ -377,6 +377,32 @@ describe('Debuglet', () => { | |||
assert.deepEqual(mergedConfig, compareConfig); | |||
}); | |||
|
|||
it('should not start when workingDirectory is the a directory', (done) => { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-debuglet.ts
Outdated
@@ -377,6 +377,32 @@ describe('Debuglet', () => { | |||
assert.deepEqual(mergedConfig, compareConfig); | |||
}); | |||
|
|||
it('should not start when workingDirectory is the a directory', (done) => { | |||
const debug = new Debug({}, packageInfo); | |||
const config = extend({}, defaultConfig, {workingDirectory: path.sep}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-debuglet.ts
Outdated
}; | ||
|
||
debuglet.on('initError', (err: Error) => { | ||
assert.ok(err); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/agent/debuglet.ts
Outdated
if (!that.config.allowRootAsWorkingDirectory && | ||
path.join(workingDir, '..') === workingDir) { | ||
const message = | ||
`Refusing to start the cloud debugger with \`workingDirectory\` set to a root ` + |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ nit if the CI is happy.
fixes: #377