Skip to content

Commit

Permalink
fix(core.gbapp): Security enhancements and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jan 9, 2020
1 parent 5bf7a0a commit c51ff7a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var now = () => {
try {

var run = () => {
console.log(`[GB Runtime] Now starting General Bots Server...`);
console.log(`[GB Runtime] Initializing General Bots Server...`);
const GBServer = require("./dist/src/app").GBServer
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
process.env.PWD = __dirname;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"@types/winston": "2.4.4",
"ban-sensitive-files": "1.9.2",
"commitizen": "^4.0.3",
"coveralls": "^3.0.9",
"cz-conventional-changelog": "^3.0.2",
"dependency-check": "^4.1.0",
"git-issues": "1.3.1",
Expand Down
32 changes: 21 additions & 11 deletions packages/azuredeployer.gbapp/services/AzureDeployerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,21 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const storageClient = new SqlManagementClient(credentials, subscriptionId);

const ip = await publicIp.v4();
const params = {
let params = {
startIpAddress: ip,
endIpAddress: ip
};

await storageClient.firewallRules.createOrUpdate(groupName, serverName, 'gb', params);

// AllowAllWindowsAzureIps must be created that way, so the Azure Search can
// access SQL Database to index its contents.

params = {
startIpAddress: '0.0.0.0',
endIpAddress: '0.0.0.0'
};
await storageClient.firewallRules.createOrUpdate(groupName, serverName, 'AllowAllWindowsAzureIps', params);

}

public async deployFarm(
Expand All @@ -358,6 +367,15 @@ export class AzureDeployerService implements IGBInstallationDeployer {
GBLog.info(`Deploying Deploy Group (It may take a few minutes)...`);
await this.createDeployGroup(name, instance.cloudLocation);

GBLog.info(`Deploying NLP...`);
const nlp = await this.createNLP(name, `${name}-nlp`, instance.cloudLocation);
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey);

instance.nlpEndpoint = urlJoin(nlp.endpoint, 'apps');
instance.nlpKey = keys.key1;
instance.nlpAppId = nlpAppId;

GBLog.info(`Deploying Bot Server...`);
const serverFarm = await this.createHostingPlan(name, `${name}-server-plan`, instance.cloudLocation);
const serverName = `${name}-server`;
Expand Down Expand Up @@ -406,17 +424,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {

instance.textAnalyticsEndpoint = textAnalytics.endpoint.replace(`/text/analytics/v2.0`, '');
instance.textAnalyticsKey = keys.key1;
if (false) {

GBLog.info(`Deploying NLP...`);
const nlp = await this.createNLP(name, `${name}-nlp`, instance.cloudLocation);
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey);
// NLP

instance.nlpEndpoint = nlp.endpoint; // TODO: Add this final URL /apps/a149dae1-5134-4624-96b5-885e9e674c9e
instance.nlpKey = keys.key1;
instance.nlpAppId = nlpAppId;
}
GBLog.info(`Deploying Bot...`);
instance.botEndpoint = this.defaultEndPoint;

Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class GBMinService {
instanceId: instance.instanceId,
botId: botId,
theme: theme,
secret: instance.webchatKey,
webchatToken: webchatToken,
speechToken: speechToken,
conversationId: webchatToken.conversationId,
authenticatorTenant: instance.authenticatorTenant,
Expand Down
2 changes: 1 addition & 1 deletion packages/default.gbui/src/GBUIApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class GBUIApp extends React.Component {
window['botchatDebug'] = true;

const line = new DirectLine({
secret: this.state.instanceClient.secret
token: this.state.instanceClient.token
});

line.connectionStatus$.subscribe(connectionStatus => {
Expand Down

0 comments on commit c51ff7a

Please sign in to comment.