diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..58d7f2d68 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +client/node_modules +server/node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e224fc944 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:18.04 + +WORKDIR /app +ADD . /app + + +RUN cp -f sources.list /etc/apt/sources.list \ + && echo y | apt-get update \ + && echo y | apt-get install g++ make python-dev nodejs npm nodejs-dev node-gyp unixodbc-dev libsqliteodbc \ + && node -v \ + && npm install npm -g \ + && npm -v \ + && scripts/build.sh \ + && npm install -g serve + +#koa 端口 +EXPOSE 3000 + +CMD node server/server.js --dir /var/data/ --port 3000 --passphrase secret-encryption-phrase --save diff --git a/client/package-lock.json b/client/package-lock.json index cb691f39c..ad6185e99 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2782,8 +2782,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -2801,13 +2800,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2820,18 +2817,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -2934,8 +2928,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -2945,7 +2938,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2958,20 +2950,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2988,7 +2977,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3061,8 +3049,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3072,7 +3059,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3148,8 +3134,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -3179,7 +3164,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3197,7 +3181,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3236,13 +3219,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -7237,8 +7218,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -7256,13 +7236,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7275,18 +7253,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -7389,8 +7364,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -7400,7 +7374,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7413,20 +7386,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7443,7 +7413,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7516,8 +7485,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -7527,7 +7495,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7603,8 +7570,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -7634,7 +7600,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7652,7 +7617,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7691,13 +7655,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } } @@ -8002,6 +7964,11 @@ "topo": "3.x.x" } }, + "js-base64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz", + "integrity": "sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw==" + }, "js-levenshtein": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", diff --git a/client/package.json b/client/package.json index 5826c5dd9..304be3b75 100644 --- a/client/package.json +++ b/client/package.json @@ -7,6 +7,7 @@ "antd": "^3.16.5", "brace": "^0.11.1", "d3": "^5.9.2", + "js-base64": "^2.5.1", "keymaster": "^1.6.2", "lodash": "^4.17.11", "prop-types": "^15.7.2", diff --git a/client/src/stores/unistoreStore.js b/client/src/stores/unistoreStore.js index e347aede1..a0f18af06 100644 --- a/client/src/stores/unistoreStore.js +++ b/client/src/stores/unistoreStore.js @@ -5,6 +5,7 @@ import message from 'antd/lib/message'; import sqlFormatter from 'sql-formatter'; import fetchJson from '../utilities/fetch-json.js'; import updateCompletions from '../utilities/updateCompletions.js'; +import { Base64 } from 'js-base64'; const ONE_HOUR_MS = 1000 * 60 * 60; @@ -277,11 +278,13 @@ export const actions = store => ({ isRunning: true, runQueryStartTime: new Date() }); + let queryText = selectedText || query.queryText; const postData = { connectionId: selectedConnectionId, cacheKey, queryName: query.name, - queryText: selectedText || query.queryText + queryText: Base64.encode(queryText), + decodeType: 'base64' }; const { queryResult, error } = await fetchJson( 'POST', diff --git a/server/package-lock.json b/server/package-lock.json index 33407c356..fa6a14605 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1859,6 +1859,11 @@ "topo": "2.x.x" } }, + "js-base64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz", + "integrity": "sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw==" + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", diff --git a/server/package.json b/server/package.json index 30af8f623..18fcb0925 100644 --- a/server/package.json +++ b/server/package.json @@ -44,6 +44,7 @@ "hdb": "^0.15.4", "helmet": "^3.16.0", "joi": "^12.0.0", + "js-base64": "^2.5.1", "json2csv": "^3.11.5", "latest-version": "^3.1.0", "lodash": "^4.17.11", diff --git a/server/routes/query-result.js b/server/routes/query-result.js index 9956db4af..01895f0c8 100644 --- a/server/routes/query-result.js +++ b/server/routes/query-result.js @@ -8,6 +8,7 @@ const Query = require('../models/Query.js'); const mustBeAuthenticated = require('../middleware/must-be-authenticated.js'); const mustBeAuthenticatedOrChartLink = require('../middleware/must-be-authenticated-or-chart-link-noauth.js'); const sendError = require('../lib/sendError'); +const Base64 = require('js-base64').Base64; // This allows executing a query relying on the saved query text // Instead of relying on an open endpoint that executes arbitrary sql @@ -45,9 +46,12 @@ router.post('/api/query-result', mustBeAuthenticated, function(req, res) { connectionId: req.body.connectionId, queryName: req.body.queryName, queryText: req.body.queryText, + encodeType: req.body.encodeType, user: req.user }; + data.queryText = Base64.decode(data.queryText); + console.log('sql -> ' + data.queryText); return getQueryResult(data) .then(queryResult => res.send({ queryResult })) .catch(error => sendError(res, error)); diff --git a/sources.list b/sources.list new file mode 100644 index 000000000..8fbb4a902 --- /dev/null +++ b/sources.list @@ -0,0 +1,10 @@ +deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse +deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse +deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse \ No newline at end of file