Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Passing arguments more securly via stdin #134

Merged
merged 1 commit into from
Mar 1, 2017
Merged

Conversation

jpricket
Copy link
Member

  • Works for CLC and TF.EXE
  • Fixed a related bug where the model was being refreshed too soon before everything was setup
  • Had to add code to put arguments on a single line in the ArgBuilder
  • Added tests to maintain code coverage
  • Also pre-cache the TF process in advance of using it. Current cache only supports one command line at a time.
    User Story #930304 and #930313

- Works for CLC and TF.EXE
- Fixed a related bug where the model was being refreshed too soon before everything was setup
- Had to add code to put arguments on a single line in the ArgBuilder
- Added tests to maintain code coverage
@msftclas
Copy link

@jpricketMSFT,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Contributor

@jeffyoung jeffyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions and comments.

}
}

public async Run(args: IArgumentProvider, options: any, isExe: boolean): Promise<IExecutionResult> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to have a comment about what's going on here. After decoding it and recalling what you mentioned IntelliJ does, it makes more sense. Something along the lines of "we're using the currently running instance to run the command but immediately start a new one so the next command can use it."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

// spawn a new instance of TF with these options
await this.startNewTfInstance(options);
}
return this._runningInstance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what's going on here, but it seems a bit odd to be returning a private member variable. Nothing to do here, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in IntelliJ we had a hash table based on working directory so this method made a bit more sense. But here the working directory is almost always the same, so I didn't try to create a map. Maybe we can discuss this when you are back in the office. No rush to get this in.

private async startNewTfInstance(options: any) {
// Start up a new instance of TF for later use
this._options = options;
this._runningInstance = await this.spawn(options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent, perhaps startNewTfInstance could return the process from this.spawn(...) and the above would return that value.

}

private optionsMatch(options1: any, options2: any): boolean {
return (!options1 && !options2) || (options1.cwd === options2.cwd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough to just look at 'cwd'? Is 'cwd' the folder that's open in VS Code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enough? for now yes, the only thing that makes the command line launched invalid for the current workspace is if the working directory changed for some reason. If a new folder is opened, the tfrunner is disposed and a new one created, so that should work fine.

Copy link
Member Author

@jpricket jpricket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responding to comments

// spawn a new instance of TF with these options
await this.startNewTfInstance(options);
}
return this._runningInstance;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in IntelliJ we had a hash table based on working directory so this method made a bit more sense. But here the working directory is almost always the same, so I didn't try to create a map. Maybe we can discuss this when you are back in the office. No rush to get this in.

}

private optionsMatch(options1: any, options2: any): boolean {
return (!options1 && !options2) || (options1.cwd === options2.cwd);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enough? for now yes, the only thing that makes the command line launched invalid for the current workspace is if the working directory changed for some reason. If a new folder is opened, the tfrunner is disposed and a new one created, so that should work fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants