Skip to content

Commit 2785cb5

Browse files
authoredMar 18, 2025··
Merge pull request #6070 from Countly/master_from_24_05_28_merge_conflict
Master from 24_05_28
2 parents 4dd4c51 + 482d899 commit 2785cb5

File tree

9 files changed

+317
-7
lines changed

9 files changed

+317
-7
lines changed
 

‎CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
##Version 25.03.XX
1+
## Version 25.03.2
2+
Fixes:
3+
- [user-management] Prevent global admin from self-revoke and self-delete
4+
25
Enterprise fixes:
6+
- [cohorts] Fixed issue with combining multiple cohorts
37
- [drill] Fixed issue with column naming in export according to event
48
- [drill] Fixed an issue with incorrect date range in report manager
59

@@ -8,7 +12,7 @@ Fixes:
812
- [crashes] Remove memory addresses from stack trace grouping
913
- [script] Refined delete_custom_events.js to clean up faulty/dead events completely.
1014

11-
Enterprise fixes:
15+
Enterprise Fixes:
1216
- [ab-testing] Fixed bug with variant user filtering
1317
- [license] Fixed issue with handling invalid date periods
1418

‎bin/scripts/mongodb.install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,4 @@ elif [ "$1" == "configure" ]; then
380380
else
381381
mongodb_configure
382382
fi
383-
fi
383+
fi
+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/bin/bash
2+
3+
#we have to check since we cannot continue unless
4+
if [ -f /etc/redhat-release ]; then
5+
CENTOS_MAJOR="$(cat /etc/redhat-release |awk -F'[^0-9]+' '{ print $2 }')"
6+
7+
if [[ "$CENTOS_MAJOR" != "8" && "$CENTOS_MAJOR" != "9" ]]; then
8+
echo "Unsupported OS version, only support CentOS/RHEL 8 and 9."
9+
exit 1
10+
fi
11+
fi
12+
13+
if [ -f /etc/lsb-release ]; then
14+
UBUNTU_YEAR="$(lsb_release -sr | cut -d '.' -f 1)";
15+
UBUNTU_RELEASE="$(lsb_release -cs)"
16+
17+
if [[ "$UBUNTU_YEAR" != "20" && "$UBUNTU_YEAR" != "22" ]]; then
18+
echo "Unsupported OS version, only support Ubuntu 20 and 22."
19+
exit 1
20+
fi
21+
fi
22+
23+
#check if authentication is required
24+
isAuth=0
25+
if grep -Eq '^\s*authorization\s*:\s*enabled' /etc/mongod.conf; then
26+
isAuth=1
27+
fi
28+
29+
#check if we have previous upgrade needed
30+
FEATVER=$(mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ).featureCompatibilityVersion)" --quiet);
31+
VER=$(mongod -version | grep "db version" | cut -d ' ' -f 3 | cut -d 'v' -f 2)
32+
33+
if [ "$isAuth" -eq "1" ]; then
34+
echo "Since authentication is enabled, we cannot verify if you need to run this upgrade script"
35+
echo ""
36+
echo "Please run this command with authentication parameters:"
37+
echo ""
38+
echo "mongosh admin --eval \"db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 } )\""
39+
echo ""
40+
echo "and continue only if \"featureCompatibilityVersion\" is 6.0 "
41+
echo ""
42+
read -r -p "Is your \"featureCompatibilityVersion\" version is 6.0? [y/N] " response
43+
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
44+
then
45+
echo "Continue upgrading"
46+
else
47+
echo "Stopping script"
48+
exit 0;
49+
fi
50+
51+
fi
52+
53+
if [ -x "$(command -v mongosh)" ]; then
54+
if echo "$VER" | grep -q -i "7.0" ; then
55+
if echo "$FEATVER" | grep -q -i "6.0" ; then
56+
echo "run this command to upgrade to 7.0";
57+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"7.0\\\" } )\"";
58+
else
59+
echo "We already have version 7.0";
60+
fi
61+
exit 0;
62+
elif echo "$VER" | grep -q -i "6.0" ; then
63+
if echo "$FEATVER" | grep -q -i "5.0" ; then
64+
echo "run this command before upgrading to 7.0";
65+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"6.0\\\" } )\"";
66+
exit 0;
67+
else
68+
echo "Upgrading to MongoDB 7.0";
69+
fi
70+
else
71+
echo "Unsupported MongodB version $VER";
72+
echo "Upgrade to MongoDB 6.0 first and then run this script";
73+
exit 1;
74+
fi
75+
76+
if [ -f /etc/redhat-release ]; then
77+
#backup of systemd unit file and mongod.conf file
78+
\cp /usr/lib/systemd/system/mongod.service /usr/lib/systemd/system/mongod.service.bak
79+
\cp -f /etc/mongod.conf /etc/mongod.conf.bak
80+
#uninstall mognodb
81+
yum erase -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
82+
fi
83+
84+
if [ -f /etc/lsb-release ]; then
85+
#uninstall mognodb
86+
apt-get remove -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
87+
fi
88+
fi
89+
90+
if [ -f /etc/redhat-release ]; then
91+
#install latest mongodb
92+
#select source based on release
93+
echo "[mongodb-org-7.0]
94+
name=MongoDB Repository
95+
baseurl=https://repo.mongodb.org/yum/redhat/${CENTOS_MAJOR}/mongodb-org/7.0/x86_64/
96+
gpgcheck=1
97+
enabled=1
98+
gpgkey=https://www.mongodb.org/static/pgp/server-7.0.asc" > /etc/yum.repos.d/mongodb-org-7.0.repo
99+
100+
yum install -y mongodb-org
101+
\cp -f /etc/mongod.conf.bak /etc/mongod.conf
102+
fi
103+
104+
if [ -f /etc/lsb-release ]; then
105+
#install latest mongodb
106+
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
107+
108+
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu ${UBUNTU_RELEASE}/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list ;
109+
apt-get update
110+
#install mongodb
111+
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install -y mongodb-org --force-yes || (echo "Failed to install mongodb." ; exit)
112+
fi
113+
114+
if [ -f /etc/redhat-release ]; then
115+
#Restoring systemd unit file
116+
\cp -f /usr/lib/systemd/system/mongod.service.bak /usr/lib/systemd/system/mongod.service
117+
systemctl daemon-reload
118+
fi
119+
120+
# check and comment out journal: enabled: true in mongod.conf
121+
CONF_FILE="/etc/mongod.conf"
122+
if grep -qP '^\s*journal\s*:\s*$' "$CONF_FILE" && grep -qP '^\s*enabled\s*:\s*true\s*$' "$CONF_FILE"; then
123+
echo "Commenting out journal: enabled: true in $CONF_FILE"
124+
sed -i '/^\s*journal\s*:/ { N; s/\(.*\n\s*\)\(enabled\s*:\s*true\s*$\)/# \1# \2/ }' "$CONF_FILE"
125+
else
126+
echo "Could not find 'journal: enabled: true' in $CONF_FILE or it's already commented."
127+
fi
128+
129+
#mongodb might need to be started
130+
systemctl restart mongod || echo "mongodb systemctl job does not exist"
131+
132+
#nc not available on latest centos
133+
#until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done
134+
mongosh --nodb --eval 'var conn; print("Waiting for MongoDB connection on port 27017. Exit if incorrect port"); var cnt = 0; while(!conn && cnt <= 300){try{conn = new Mongo("localhost:27017");}catch(Error){}sleep(1000);cnt++;}'
135+
136+
if [ "$isAuth" -eq "1" ]; then
137+
echo "run this command with authentication to upgrade to 7.0"
138+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"7.0\\\" } )\""
139+
elif ! mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ))" ; then
140+
echo "Could not connect to MongodB, run this command when Mongo is up and running"
141+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"7.0\\\" } )\""
142+
else
143+
mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ))"
144+
mongosh admin --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"7.0\", confirm: true } )"
145+
echo "Finished upgrading script"
146+
fi
+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
3+
#we have to check since we cannot continue unless
4+
if [ -f /etc/redhat-release ]; then
5+
CENTOS_MAJOR="$(cat /etc/redhat-release |awk -F'[^0-9]+' '{ print $2 }')"
6+
7+
if [[ "$CENTOS_MAJOR" != "8" && "$CENTOS_MAJOR" != "9" ]]; then
8+
echo "Unsupported OS version, only support CentOS/RHEL 8 and 9."
9+
exit 1
10+
fi
11+
fi
12+
13+
if [ -f /etc/lsb-release ]; then
14+
UBUNTU_YEAR="$(lsb_release -sr | cut -d '.' -f 1)";
15+
UBUNTU_RELEASE="$(lsb_release -cs)"
16+
17+
if [[ "$UBUNTU_YEAR" != "20" && "$UBUNTU_YEAR" != "22" && "$UBUNTU_YEAR" != "24" ]]; then
18+
echo "Unsupported OS version, only support Ubuntu 20 and 22 and 24."
19+
exit 1
20+
fi
21+
fi
22+
23+
#check if authentication is required
24+
isAuth=0
25+
if grep -Eq '^\s*authorization\s*:\s*enabled' /etc/mongod.conf; then
26+
isAuth=1
27+
fi
28+
29+
#check if we have previous upgrade needed
30+
FEATVER=$(mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ).featureCompatibilityVersion)" --quiet);
31+
VER=$(mongod -version | grep "db version" | cut -d ' ' -f 3 | cut -d 'v' -f 2)
32+
33+
if [ "$isAuth" -eq "1" ]; then
34+
echo "Since authentication is enabled, we cannot verify if you need to run this upgrade script"
35+
echo ""
36+
echo "Please run this command with authentication parameters:"
37+
echo ""
38+
echo "mongosh admin --eval \"db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 } )\""
39+
echo ""
40+
echo "and continue only if \"featureCompatibilityVersion\" is 7.0 "
41+
echo ""
42+
read -r -p "Is your \"featureCompatibilityVersion\" version is 7.0? [y/N] " response
43+
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
44+
then
45+
echo "Continue upgrading"
46+
else
47+
echo "Stopping script"
48+
exit 0;
49+
fi
50+
51+
fi
52+
53+
if [ -x "$(command -v mongosh)" ]; then
54+
if echo "$VER" | grep -q -i "8.0" ; then
55+
if echo "$FEATVER" | grep -q -i "7.0" ; then
56+
echo "run this command to upgrade to 8.0";
57+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"8.0\\\", confirm: true } )\"";
58+
else
59+
echo "We already have version 8.0";
60+
fi
61+
exit 0;
62+
elif echo "$VER" | grep -q -i "7.0" ; then
63+
if echo "$FEATVER" | grep -q -i "6.0" ; then
64+
echo "run this command before upgrading to 8.0 and rerunning this script";
65+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"7.0\\\", confirm: true } )\"";
66+
exit 0;
67+
else
68+
echo "Upgrading to MongoDB 8.0";
69+
fi
70+
else
71+
echo "Unsupported MongodB version $VER";
72+
echo "Upgrade to MongoDB 7.0 first and then run this script";
73+
exit 1;
74+
fi
75+
76+
if [ -f /etc/redhat-release ]; then
77+
#backup of systemd unit file and mongod.conf file
78+
\cp /usr/lib/systemd/system/mongod.service /usr/lib/systemd/system/mongod.service.bak
79+
\cp -f /etc/mongod.conf /etc/mongod.conf.bak
80+
#uninstall mognodb
81+
yum erase -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
82+
fi
83+
84+
if [ -f /etc/lsb-release ]; then
85+
#uninstall mognodb
86+
apt-get remove -y mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
87+
fi
88+
fi
89+
90+
if [ -f /etc/redhat-release ]; then
91+
#install latest mongodb
92+
#select source based on release
93+
echo "[mongodb-org-8.0]
94+
name=MongoDB Repository
95+
baseurl=https://repo.mongodb.org/yum/redhat/${CENTOS_MAJOR}/mongodb-org/8.0/x86_64/
96+
gpgcheck=1
97+
enabled=1
98+
gpgkey=https://pgp.mongodb.com/server-8.0.asc" > /etc/yum.repos.d/mongodb-org-8.0.repo
99+
100+
yum install -y mongodb-org
101+
\cp -f /etc/mongod.conf.bak /etc/mongod.conf
102+
fi
103+
104+
if [ -f /etc/lsb-release ]; then
105+
#install latest mongodb
106+
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
107+
108+
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu ${UBUNTU_RELEASE}/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
109+
apt-get update
110+
#install mongodb
111+
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install -y mongodb-org --force-yes || (echo "Failed to install mongodb." ; exit)
112+
fi
113+
114+
if [ -f /etc/redhat-release ]; then
115+
#Restoring systemd unit file
116+
\cp -f /usr/lib/systemd/system/mongod.service.bak /usr/lib/systemd/system/mongod.service
117+
systemctl daemon-reload
118+
fi
119+
120+
#mongodb might need to be started
121+
systemctl restart mongod || echo "mongodb systemctl job does not exist"
122+
123+
#nc not available on latest centos
124+
#until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done
125+
mongosh --nodb --eval 'var conn; print("Waiting for MongoDB connection on port 27017. Exit if incorrect port"); var cnt = 0; while(!conn && cnt <= 300){try{conn = new Mongo("localhost:27017");}catch(Error){}sleep(1000);cnt++;}'
126+
127+
if [ "$isAuth" -eq "1" ]; then
128+
echo "run this command with authentication to upgrade to 8.0"
129+
# shellcheck disable=SC2028
130+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\8.0\\\", confirm: true } )\""
131+
elif ! mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ))" ; then
132+
echo "Could not connect to MongodB, run this command when Mongo is up and running"
133+
echo "mongosh admin --eval \"db.adminCommand( { setFeatureCompatibilityVersion: \\\"8.0\\\", confirm: true } )\""
134+
else
135+
mongosh admin --eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ))"
136+
mongosh admin --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"8.0\", confirm: true } )"
137+
echo "Finished upgrading script"
138+
fi

‎frontend/express/public/core/user-management/javascripts/countly.views.js

+19
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@
122122
switch (command) {
123123
case "delete-user":
124124
var self = this;
125+
126+
// Check if user is trying to delete themselves
127+
if (index === countlyGlobal.member._id) {
128+
CountlyHelpers.notify({
129+
type: 'error',
130+
message: CV.i18n('management-users.cannot-delete-own-account')
131+
});
132+
return;
133+
}
134+
125135
CountlyHelpers.confirm(CV.i18n('management-users.this-will-delete-user'), "red", function(result) {
126136
if (!result) {
127137
CountlyHelpers.notify({
@@ -712,6 +722,15 @@
712722
// drawer event handlers
713723
onClose: function() {},
714724
onSubmit: function(submitted, done) {
725+
if (submitted._id === countlyGlobal.member._id && countlyGlobal.member.global_admin && !submitted.global_admin) {
726+
CountlyHelpers.notify({
727+
message: CV.i18n('management-users.cannot-revoke-own-admin'),
728+
type: 'error'
729+
});
730+
done(CV.i18n('management-users.cannot-revoke-own-admin'));
731+
return;
732+
}
733+
715734
var atLeastOneAppSelected = false;
716735

717736
for (var i = 0; i < submitted.permission._.u.length; i++) {

‎frontend/express/public/javascripts/countly/vue/components/vis.js

+1
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@
956956
},
957957
animation: false
958958
},
959+
symbol: 'none'
959960
},
960961
mergedNotes: [],
961962
};

‎frontend/express/public/javascripts/countly/vue/templates/drawer.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ <h3>{{title}}</h3>
8989
<div class="cly-vue-drawer__buttons is-multi-step is-single-step bu-is-justify-content-flex-end bu-is-flex" v-if="isMultiStep">
9090
<el-button :data-test-id="testId + '-cancel-button'" type="secondary" @click="doClose" size="small" v-if="currentStepIndex === 0 && hasCancelButton" :disabled="isSubmitPending">{{cancelButtonLabel}}</el-button>
9191
<el-button :data-test-id="testId + '-previous-step-button'" type="secondary" @click="prevStep" size="small" v-if="currentStepIndex > 0" :disabled="isSubmitPending">{{i18n('common.drawer.previous-step')}}</el-button>
92-
<el-button :data-test-id="testId + '-next-step-button'" type="success" @click="nextStep" size="small" v-if="!isLastStep" :class="{'is-disabled':!isCurrentStepValid}" :disabled="isSubmitPending">{{i18n('common.drawer.next-step')}}</el-button>
93-
<el-button :data-test-id="testId + '-save-button'" type="success" @click="submit" :loading="isSubmitPending" size="small" v-if="isLastStep" :class="{'is-disabled':!isSubmissionAllowed}" :disabled="isSubmitPending">{{saveButtonLabel}}</el-button>
92+
<el-button :data-test-id="testId + '-next-step-button'" type="success" :key="isLastStep" @click="nextStep" size="small" v-if="!isLastStep" :class="{'is-disabled':!isCurrentStepValid}" :disabled="isSubmitPending">{{i18n('common.drawer.next-step')}}</el-button>
93+
<el-button :data-test-id="testId + '-save-button'" type="success" :key="isLastStep" @click="submit" :loading="isSubmitPending" size="small" v-if="isLastStep" :class="{'is-disabled':!isSubmissionAllowed}" :disabled="isSubmitPending">{{saveButtonLabel}}</el-button>
9494
</div>
9595
<div class="cly-vue-drawer__buttons is-single-step is-single-step bu-is-justify-content-flex-end bu-is-flex" v-if="!isMultiStep">
9696
<el-button :data-test-id="testId + '-cancel-button'" type="secondary" @click="doClose" size="small" v-if="hasCancelButton" :disabled="isSubmitPending">{{cancelButtonLabel}}</el-button>

‎frontend/express/public/localization/dashboard/dashboard.properties

+2
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,8 @@ management-users.search-placeholder = Search in Features
956956
management-users.reset-failed-logins = Reset failed logins
957957
management-users.reset-failed-logins-success = Failed logins reset successfully\!
958958
management-users.reset-failed-logins-failed = Failed to reset logins\!
959+
management-users.cannot-delete-own-account = You can not delete your own account
960+
management-users.cannot-revoke-own-admin = You can not revoke your own global admin privileges
959961

960962
#date-preset
961963
management.preset = Date presets

‎plugins/star-rating/frontend/public/templates/star-consent-link.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="bu-py-1 bu-px-4 cly-vue-drawer-step__section-group--filled">
22
<div class="cly-vue-drawer-step__section">
3-
<div class="text-small text-heading bu-pb-1" data-test-id="ratings-drawer-settings-add-user-consent-text-label">{{i18n('rating.drawer.consent.text')}}</div>
4-
<validation-provider name="value.consent" rules="required|max:93" v-slot="v">
3+
<div class="text-small text-heading bu-pb-1">{{i18n('rating.drawer.consent.text')}}</div>
4+
<validation-provider name="value.consent" rules="required|max:94" v-slot="v">
55
<el-input
66
test-id="ratings-drawer-settings-add-user-consent-text-input"
77
:class="{'is-error': v.errors.length > 0}"

0 commit comments

Comments
 (0)
Please sign in to comment.