From b7c114ed7db9df90b7442c28ab9563930fc2f8f5 Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Sat, 16 Sep 2023 20:52:08 -0700 Subject: [PATCH] 1.11.1 hotfix (#1886) * Update CHANGELOG.md * Update TERMS_AND_CONDITIONS.md * Update TERMS_AND_CONDITIONS.md * Adding script to clear pro config * Fixed https://github.com/caprover/caprover/issues/1863 * Closes https://github.com/caprover/caprover-pro/issues/3 * Updated the changelog * Fixed https://github.com/caprover/caprover/discussions/1859 * updated the changelogs * Fixed https://github.com/caprover/caprover/issues/1871 * Upped version - ready for hotfix --- CHANGELOG.md | 7 +++++++ TERMS_AND_CONDITIONS.md | 2 +- dev-scripts/build_and_push_release.sh | 2 +- dev-scripts/clear-pro-config.js | 16 ++++++++++++++++ package.json | 1 + src/scripts/disable-otp.ts | 6 ++++++ src/user/Authenticator.ts | 2 ++ src/user/pro/ProManager.ts | 1 + src/utils/CaptainConstants.ts | 4 ++-- src/utils/GitHelper.ts | 2 +- tests/GitHelper.test.ts | 15 +++++++-------- 11 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 dev-scripts/clear-pro-config.js create mode 100644 src/scripts/disable-otp.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c5f6da..6a37500 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## [Next Version - available as `edge`] +- Fixed: Malformatted SSH issue [Issue-1863](https://github.com/caprover/caprover/issues/1863) +- Fixed: Cannot save due to undefined property [Issue-1871](https://github.com/caprover/caprover/issues/1871) +- New/Experimental: Added a helper script for disabling the OTP +- Improved: Locking the nginx version to avoid unstable deployments and upgrades + +## [1.11.1] - 2023-08-27 + - Improved: Pulling the new image before attempt to upgrade the CapRover engine to improve reliability of upgrades - Improved: Allowed custom git usernames [PR-1254](https://github.com/caprover/caprover/pull/1254) - Improved: Enabled gzip for the dashboard for a faster load diff --git a/TERMS_AND_CONDITIONS.md b/TERMS_AND_CONDITIONS.md index bd04a94..fcae152 100644 --- a/TERMS_AND_CONDITIONS.md +++ b/TERMS_AND_CONDITIONS.md @@ -21,7 +21,7 @@ CapRover developers will do their best to ensure that CapRover remains functiona ### Analytics -CapRover has built in anonymous usage analytics starting v1.11. CapRover **never** sends any private data, such as env vars, private images, etc. This anonymous information is only used to understand usage patterns of CapRover and optimize the experience for the users. For example, in the future, we will have the possibility to add download counts to one click apps. If you wish to disable anonymous analytics, you can do so by passing an env variable CAPROVER_DISABLE_ANALYTICS=true to CapRover service. In the future, we will use this information to find out which one click apps are popular, whether or not we should focus on supporting multiple nodes (percentage of single node vs multi node), whether or not we should invest in supporting multi CPU clusters, and etc. +CapRover has built in anonymous usage analytics starting v1.11. CapRover **never** sends any private data, such as env vars, private images, etc. This anonymous information is only used to understand usage patterns of CapRover and optimize the experience for the users. For example, in the future, we will have the possibility to add download counts to one click apps. If you wish to disable anonymous analytics, you can do so by passing an env variable CAPROVER_DISABLE_ANALYTICS=true to CapRover service. You can add this to the installation line, or use `docker service update --env-add CAPROVER_DISABLE_ANALYTICS=true captain-captain` for an existing service. In the future, we will use this information to find out which one click apps are popular, whether or not we should focus on supporting multiple nodes (percentage of single node vs multi node), whether or not we should invest in supporting multi CPU clusters, and etc. Here is [the link](https://github.com/caprover/caprover/blob/master/src/user/events/emitter/AnalyticsLogger.ts#L22-L25) to all analytics events that CapRover collects. ### Future changes diff --git a/dev-scripts/build_and_push_release.sh b/dev-scripts/build_and_push_release.sh index e91bdb6..d15ecd1 100755 --- a/dev-scripts/build_and_push_release.sh +++ b/dev-scripts/build_and_push_release.sh @@ -44,7 +44,7 @@ echo $IMAGE_NAME:$CAPROVER_VERSION echo "**************************************" echo "**************************************" -FRONTEND_COMMIT_HASH=36b569a0e9f9170ea10c80c989119ac880db807b +FRONTEND_COMMIT_HASH=d22029558a22b5f072d182965ad4495266bada67 ## Building frontend app ORIG_DIR=$(pwd) diff --git a/dev-scripts/clear-pro-config.js b/dev-scripts/clear-pro-config.js new file mode 100644 index 0000000..49c8bb1 --- /dev/null +++ b/dev-scripts/clear-pro-config.js @@ -0,0 +1,16 @@ +/*jshint esversion: 6 */ + +const fs = require('fs-extra') +const CONFIG_FILE_PATH = '/captain/data/config-captain.json' + +const fileContent = JSON.parse( + fs.readFileSync(CONFIG_FILE_PATH, { + encoding: 'utf-8', + }) +) + +fs.writeFileSync(CONFIG_FILE_PATH + '.backup', JSON.stringify(fileContent)) + +fileContent.pro = {} + +fs.writeFileSync(CONFIG_FILE_PATH, JSON.stringify(fileContent)) diff --git a/package.json b/package.json index 6502f4e..e3152bf 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { + "disable-otp": "node ./built/scripts/disable-otp.js", "dev": "npm run build && sudo ./dev-scripts/dev-reset-service.sh", "clean": "npm run build && sudo ./dev-scripts/dev-clean-run-as-dev.sh", "lint": "eslint -c .eslintrc.js --ext .ts ./src", diff --git a/src/scripts/disable-otp.ts b/src/scripts/disable-otp.ts new file mode 100644 index 0000000..1c94f90 --- /dev/null +++ b/src/scripts/disable-otp.ts @@ -0,0 +1,6 @@ +import DataStoreProvider from '../datastore/DataStoreProvider' + +DataStoreProvider.getDataStore('captain') + .getProDataStore() + .setOtpEnabled(false) + .catch((err) => console.log(err)) diff --git a/src/user/Authenticator.ts b/src/user/Authenticator.ts index 9a49948..f62f07b 100644 --- a/src/user/Authenticator.ts +++ b/src/user/Authenticator.ts @@ -329,6 +329,8 @@ class Authenticator { captainSalt, namespace ) + } else { + throw new Error('Salt is not set! Cannot create authenticator') } } diff --git a/src/user/pro/ProManager.ts b/src/user/pro/ProManager.ts index d1b32b4..5bfefaf 100644 --- a/src/user/pro/ProManager.ts +++ b/src/user/pro/ProManager.ts @@ -132,6 +132,7 @@ export default class ProManager { return { isSubscribed: !!apiKey, isFeatureFlagEnabled: + !!EnvVars.CAPTAIN_IS_DEBUG || // !!apiKey || // if API key is there, assume feature flag is enabled !!EnvVars.FORCE_ENABLE_PRO || // (flags && flags[FeatureFlags.IS_PRO_ENABLED]), diff --git a/src/utils/CaptainConstants.ts b/src/utils/CaptainConstants.ts index 249e8cb..ba3abeb 100644 --- a/src/utils/CaptainConstants.ts +++ b/src/utils/CaptainConstants.ts @@ -17,7 +17,7 @@ const CONSTANT_FILE_OVERRIDE_USER = const configs = { publishedNameOnDockerHub: 'caprover/caprover', - version: '1.11.0', + version: '1.11.1', defaultMaxLogSize: '512m', @@ -41,7 +41,7 @@ const configs = { appPlaceholderImageName: 'caprover/caprover-placeholder-app:latest', - nginxImageName: 'nginx:1', + nginxImageName: 'nginx:1.24', defaultEmail: 'runner@caprover.com', diff --git a/src/utils/GitHelper.ts b/src/utils/GitHelper.ts index d9c8938..24af504 100644 --- a/src/utils/GitHelper.ts +++ b/src/utils/GitHelper.ts @@ -18,7 +18,7 @@ export default class GitHelper { /(?[^\s\/\?#:]+)/, /(?::(?[0-9]{1,5}))?/, /(?:[\/:](?[^\s\/\?#:]+))?/, - /(?:[\/:](?(?:[^\s\/\?#:.]|\.(?!git\/?\s*$))+))/, + /(?:[\/:](?(?:[^\s\?#:.]|\.(?!git\/?\s*$))+))/, /(?:.git)?\/?\s*$/, ] .map((r) => r.source) diff --git a/tests/GitHelper.test.ts b/tests/GitHelper.test.ts index 48b734a..fd32f4a 100644 --- a/tests/GitHelper.test.ts +++ b/tests/GitHelper.test.ts @@ -24,6 +24,13 @@ test('Testing - sanitizeRepoPathSsh', () => { ).toBe('ssh://git@github.com:22/username/repository.git') }) +test('Testing - sanitizeRepoPathSsh', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' git@gitlab.com/test1/test2/test3.git') + .repoPath + ).toBe('ssh://git@gitlab.com:22/test1/test2/test3.git') +}) + test('Testing - sanitizeRepoPathSsh - port', () => { expect( GitHelper.sanitizeRepoPathSsh( @@ -118,14 +125,6 @@ test('Testing - sanitizeRepoPathSsh - no owner', () => { ).toBe('ssh://git@github.com:22/repository.git') }) -test('Testing - sanitizeRepoPathSsh - invalid url', () => { - expect(() => - GitHelper.sanitizeRepoPathSsh( - ' git:password@github.com/owner/repository.git/ ' - ) - ).toThrow(Error) -}) - test('Testing - getDomainFromSanitizedSshRepoPath - pure', () => { expect( GitHelper.getDomainFromSanitizedSshRepoPath(