fix: refuse to start if working dir is root dir#381
fix: refuse to start if working dir is root dir#381DominicKramer merged 9 commits intogoogleapis:masterfrom
Conversation
ofrobots
left a comment
There was a problem hiding this comment.
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
| 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
|
|
||
| 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.
ofrobots
left a comment
There was a problem hiding this comment.
LGTM w/ nit if the CI is happy.
fixes: #377