Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci secrets security fix #353

Merged
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
node-version: 16
architecture: ${{ matrix.arch }}
cache: 'npm'
- run: echo '${{ secrets.CONFIG_JSON }}' > ${{ github.workspace }}/src/config.json
- uses: ilammy/setup-nasm@v1
- name: windows-specific
shell: pwsh
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ dist
node_modules
*.vsix
build/
src/config.json
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-couchbase",
"displayName": "Couchbase",
"description": "",
"version": "1.2.0",
"version": "1.2.1",
"engines": {
"vscode": "^1.63.1"
},
Expand Down Expand Up @@ -30,8 +30,8 @@
"build:v3": "cd ../couchbase-cloud/cmd/cp-ui-v3; npm run build",
"postbuild:v3": "cp -r ../couchbase-cloud/cmd/cp-ui-v3/dist/styles.css ./src/reactViews/app/styles.css && cp -r ../couchbase-cloud/cmd/cp-ui-v3/dist/types ./src/reactViews/app/",
"compile-capella-v3": "npm run build:v3 && npm run postbuild:v3 && node scripts/fix_sharedComponent.js && npm-run-all compile:*",
"compile": "npm-run-all compile:*",
"watch": "npm-run-all -p watch:*",
"compile": "node scripts/copy_secrets.js && npm-run-all compile:*",
"watch": "node scripts/copy_secrets.js && npm-run-all -p watch:*",
"compile:extension": "tsc -p ./",
"compile:views": "webpack --mode development",
"watch:extension": "tsc -watch -p ./",
Expand Down
14 changes: 14 additions & 0 deletions scripts/copy_secrets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fsp = require('fs').promises;

async function main() {
try {
// Copy binding file to local directory so it's included in VSCE package
console.log('Copying secrets to dist');
await fsp.copyFile('./src/config.json', './dist/config.json');
} catch (err) {
console.log(err);
}
}

main();

3 changes: 2 additions & 1 deletion src/commands/iq/iqRestApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { feedbackLambdaMessageType, iqChatResult } from "./chat/types";


export class iqRestApiService {
private static readonly CAPELLA_URL_DOMAIN = "https://api.dev.nonprod-project-avengers.com"; // TODO: change here before prod release
// Capella Prod domain
private static readonly CAPELLA_URL_DOMAIN = "https://api.cloud.couchbase.com";
private static readonly SESSIONS_API_URL = `${this.CAPELLA_URL_DOMAIN}/sessions`;
private static readonly FETCH_ORGANIZATIONS_URL = `${this.CAPELLA_URL_DOMAIN}/v2/organizations`;

Expand Down
1 change: 1 addition & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
28 changes: 15 additions & 13 deletions src/reactViews/iq/pages/chatscreen/IqChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,22 @@ const IqChat = ({ org, setIsLoading }) => {
);
};

const handlePaste = (event) => {
// Prevent the original paste action
event.preventDefault();
const text = event.clipboardData.getData("text/plain");
const selection = window.getSelection();

if (selection.rangeCount) {
selection.deleteFromDocument();
selection.getRangeAt(0).insertNode(document.createTextNode(text));
}

AayushTyagi1 marked this conversation as resolved.
Show resolved Hide resolved
const inputEvent = new Event("input", { bubbles: true });
event.target.dispatchEvent(inputEvent);
};
// Keeping the handle paste function here if some paste issue arises later
// const handlePaste = (event) => {
// // Prevent the original paste action
// event.preventDefault();
// const text = event.clipboardData.getData("text/plain");
// const selection = window.getSelection();

// if (selection.rangeCount) {
// selection.deleteFromDocument();
// selection.getRangeAt(0).insertNode(document.createTextNode(text));
// }

// const inputEvent = new Event("input", { bubbles: true });
// event.target.dispatchEvent(inputEvent);
// };

const openNewChat = () => {
setMessages({
Expand Down
9 changes: 6 additions & 3 deletions src/util/secretUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ExtensionContext } from "vscode";

// Before Building, Please update secrets else IQ Feedback service will not work
import * as fs from 'fs';
import * as path from 'path';

export const secretUpdater = (context: ExtensionContext) => {
context.globalState.update("feedbackLambdaSecret", "c0uchbase_is_aw3some");
context.globalState.update("feedbackLambdaUrl", "https://nms548yy5b.execute-api.us-west-1.amazonaws.com/Prod/");
const config = JSON.parse(fs.readFileSync(path.join(__filename,"..", "config.json")).toString());
context.globalState.update("feedbackLambdaSecret", config.FEEDBACK_LAMBDA_SECRET);
context.globalState.update("feedbackLambdaUrl", config.FEEDBACK_LAMBDA_URL);
};
Loading