Compare commits

...

19 Commits

Author SHA1 Message Date
Louis Lam
e797abd108 Update to 1.23.12 2024-04-19 01:17:13 +08:00
Louis Lam
7a9e2f5de6 Merge pull request from GHSA-23q2-5gf8-gjpp 2024-04-19 01:08:31 +08:00
Louis Lam
7b5d2a71ff Update dependencies 2024-04-18 20:48:07 +08:00
Nelson Chan
893278bd3d Feat: Use keylog event to obtain TLS certificate for better reliability [1.23.X] (#4630)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2024-04-06 18:43:08 +08:00
Adam Stachowicz
0e30ea830d fix: Update nodemailer to fix GHSA-9h6g-pr28-7cqp [1.23.X] (#4653) 2024-04-05 17:38:24 +02:00
Louis Lam
c67a2070b8 Update deps 2024-04-05 12:12:36 +08:00
Adam Stachowicz
9863a10321 fix: Update axios, @actions/github and dompurify [1.23.X] (#4652) 2024-04-05 11:47:46 +08:00
Nelson Chan
ee7f8680c1 Fix: Add missing FK for monitor-tls-info table [1.23.X] (#4631) 2024-03-31 12:05:38 +08:00
Nelson Chan
c1301804d4 Fix: Fix CI on Windows Runner [1.23.X] (#4633) 2024-03-31 10:33:59 +08:00
Frank Elsinga
b385e81608 Improved helptext of how to send mail via the systems mail subsystem (#4477) 2024-03-05 19:40:45 +01:00
Frank Elsinga
f37f55e06c Fixed lining issues introduced by code reivew 2024-02-11 22:44:57 +01:00
Frank Elsinga
87d7a780e3 changed the helptext a bit to make it more usefull for novice users 2024-02-11 22:40:47 +01:00
apio-sys
0fc372f558 #2793 2024-02-11 20:20:52 +01:00
Joris Le Blansch
67a13e1259 #2793 2024-02-11 20:03:17 +01:00
Nelson Chan
2b8f55194f Fix: [JSON-Query] Prevent parsing string-only JSON (#4425) 2024-01-28 03:18:24 +08:00
Nelson Chan
288cab6dd7 Fix: Make sure browser is connected before returning (#4417) 2024-01-25 07:59:42 +08:00
AnnAngela
b4e45c7ce8 fix(notification-dingding): throw error when failed (#3598) 2024-01-20 03:29:13 +08:00
Frank Elsinga
7635ab54a0 made sure that the i18n does use navigator.languages instead of navigator.language for automatic language detection (#4244) 2024-01-07 23:55:10 +08:00
Adam Stachowicz
458cdf9f9b Fix encodeBase64 for empty password or user in HTTP Basic Authentication (#4326) 2024-01-07 02:06:06 +08:00
14 changed files with 2526 additions and 1930 deletions

View File

@@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest, ARM64]
node: [ 14, 20 ]
node: [ 16, 20.5 ]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
@@ -33,8 +33,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm install npm@9 -g
- run: npm install
- run: npm ci
- run: npm run build
- run: npm test
env:
@@ -50,7 +49,7 @@ jobs:
strategy:
matrix:
os: [ ARMv7 ]
node: [ 14, 20 ]
node: [ 16, 20.5 ]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
@@ -61,7 +60,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm install npm@9 -g
- run: npm ci --production
check-linters:
@@ -71,11 +69,11 @@ jobs:
- run: git config --global core.autocrlf false # Mainly for Windows
- uses: actions/checkout@v4
- name: Use Node.js 14
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 14
- run: npm install
node-version: 20.5
- run: npm ci
- run: npm run lint:prod
e2e-tests:
@@ -85,11 +83,11 @@ jobs:
- run: git config --global core.autocrlf false # Mainly for Windows
- uses: actions/checkout@v4
- name: Use Node.js 14
- name: Use Node.js 16
uses: actions/setup-node@v4
with:
node-version: 14
- run: npm install
node-version: 16
- run: npm ci
- run: npm run build
- run: npm run cy:test
@@ -100,10 +98,10 @@ jobs:
- run: git config --global core.autocrlf false # Mainly for Windows
- uses: actions/checkout@v4
- name: Use Node.js 14
- name: Use Node.js 16
uses: actions/setup-node@v4
with:
node-version: 14
- run: npm install
node-version: 16
- run: npm ci
- run: npm run build
- run: npm run cy:run:unit

View File

@@ -0,0 +1,18 @@
BEGIN TRANSACTION;
PRAGMA writable_schema = TRUE;
UPDATE
SQLITE_MASTER
SET
sql = replace(sql,
'monitor_id INTEGER NOT NULL',
'monitor_id INTEGER NOT NULL REFERENCES [monitor] ([id]) ON DELETE CASCADE ON UPDATE CASCADE'
)
WHERE
name = 'monitor_tls_info'
AND type = 'table';
PRAGMA writable_schema = RESET;
COMMIT;

4261
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "uptime-kuma",
"version": "1.23.11",
"version": "1.23.12",
"license": "MIT",
"repository": {
"type": "git",
@@ -42,7 +42,7 @@
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
"build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
"setup": "git checkout 1.23.11 && npm ci --production && npm run download-dist",
"setup": "git checkout 1.23.12 && npm ci --production && npm run download-dist",
"download-dist": "node extra/download-dist.js",
"mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js",
@@ -82,7 +82,7 @@
"@louislam/ping": "~0.4.4-mod.1",
"@louislam/sqlite3": "15.1.6",
"args-parser": "~1.3.0",
"axios": "~0.27.0",
"axios": "~0.28.1",
"axios-ntlm": "1.3.0",
"badge-maker": "~3.3.1",
"bcryptjs": "~2.4.3",
@@ -97,7 +97,7 @@
"croner": "~6.0.5",
"dayjs": "~1.11.5",
"dotenv": "~16.0.3",
"express": "~4.17.3",
"express": "~4.19.2",
"express-basic-auth": "~1.2.1",
"express-static-gzip": "~2.1.7",
"form-data": "~4.0.0",
@@ -118,11 +118,11 @@
"mongodb": "~4.17.1",
"mqtt": "~4.3.7",
"mssql": "~8.1.4",
"mysql2": "~3.6.2",
"mysql2": "~3.9.6",
"nanoid": "~3.3.4",
"node-cloudflared-tunnel": "~1.0.9",
"node-radius-client": "~1.0.0",
"nodemailer": "~6.6.5",
"nodemailer": "~6.9.13",
"nostr-tools": "^1.13.1",
"notp": "~2.0.3",
"openid-client": "^5.4.2",
@@ -141,13 +141,13 @@
"socket.io": "~4.6.1",
"socket.io-client": "~4.6.1",
"socks-proxy-agent": "6.1.1",
"tar": "~6.1.11",
"tar": "~6.2.1",
"tcp-ping": "~0.1.1",
"thirty-two": "~1.0.2",
"ws": "^8.13.0"
},
"devDependencies": {
"@actions/github": "~5.0.1",
"@actions/github": "~5.1.1",
"@babel/eslint-parser": "^7.22.7",
"@babel/preset-env": "^7.15.8",
"@fortawesome/fontawesome-svg-core": "~1.2.36",
@@ -171,7 +171,7 @@
"cypress": "^13.2.0",
"delay": "^5.0.0",
"dns2": "~2.0.1",
"dompurify": "~2.4.3",
"dompurify": "~3.0.11",
"eslint": "~8.14.0",
"eslint-plugin-vue": "~8.7.1",
"favico.js": "~0.3.10",
@@ -191,7 +191,7 @@
"timezones-list": "~3.0.1",
"typescript": "~4.4.4",
"v-pagination-3": "~0.1.7",
"vite": "~4.4.1",
"vite": "~5.2.8",
"vite-plugin-compression": "^0.5.1",
"vue": "~3.3.4",
"vue-chartjs": "~5.2.0",

View File

@@ -84,6 +84,7 @@ class Database {
"patch-notification-config.sql": true,
"patch-fix-kafka-producer-booleans.sql": true,
"patch-timeout.sql": true,
"patch-monitor-tls-info-add-fk.sql": true,
};
/**

View File

@@ -230,10 +230,12 @@ class Monitor extends BeanModel {
/**
* Encode user and password to Base64 encoding
* for HTTP "basic" auth, as per RFC-7617
* @param {string|null} user - The username (nullable if not changed by a user)
* @param {string|null} pass - The password (nullable if not changed by a user)
* @returns {string}
*/
encodeBase64(user, pass) {
return Buffer.from(user + ":" + pass).toString("base64");
return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64");
}
/**
@@ -510,6 +512,12 @@ class Monitor extends BeanModel {
}
}
let tlsInfo;
// Store tlsInfo when key material is received
options.httpsAgent.on("keylog", (line, tlsSocket) => {
tlsInfo = checkCertificate(tlsSocket);
});
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
log.debug("monitor", `[${this.name}] Axios Request`);
@@ -519,29 +527,20 @@ class Monitor extends BeanModel {
bean.msg = `${res.status} - ${res.statusText}`;
bean.ping = dayjs().valueOf() - startTime;
// Check certificate if https is used
let certInfoStartTime = dayjs().valueOf();
// Store certificate and check for expiry if https is used
if (this.getUrl()?.protocol === "https:") {
log.debug("monitor", `[${this.name}] Check cert`);
try {
let tlsInfoObject = checkCertificate(res);
tlsInfo = await this.updateTlsInfo(tlsInfoObject);
// No way to listen for the `secureConnection` event, so we do it here
const tlssocket = res.request.res.socket;
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
await this.checkCertExpiryNotifications(tlsInfoObject);
}
} catch (e) {
if (e.message !== "No TLS certificate in response") {
log.error("monitor", "Caught error");
log.error("monitor", e.message);
}
if (tlssocket) {
tlsInfo.valid = tlssocket.authorized || false;
}
}
if (process.env.TIMELOGGER === "1") {
log.debug("monitor", "Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
await this.updateTlsInfo(tlsInfo);
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
await this.checkCertExpiryNotifications(tlsInfo);
}
}
if (process.env.UPTIME_KUMA_LOG_RESPONSE_BODY_MONITOR_ID === this.id) {
@@ -576,8 +575,12 @@ class Monitor extends BeanModel {
let data = res.data;
// convert data to object
if (typeof data === "string") {
data = JSON.parse(data);
if (typeof data === "string" && res.headers["content-type"] !== "application/json") {
try {
data = JSON.parse(data);
} catch (_) {
// Failed to parse as JSON, just process it as a string
}
}
let expression = jsonata(this.jsonPath);

View File

@@ -9,6 +9,10 @@ const Database = require("../database");
const jwt = require("jsonwebtoken");
const config = require("../config");
/**
* Cached instance of a browser
* @type {import ("playwright-core").Browser}
*/
let browser = null;
let allowedList = [];
@@ -62,8 +66,15 @@ async function isAllowedChromeExecutable(executablePath) {
return allowedList.includes(executablePath);
}
/**
* Get the current instance of the browser. If there isn't one, create
* it.
* @returns {Promise<import ("playwright-core").Browser>} The browser
*/
async function getBrowser() {
if (!browser) {
if (browser && browser.isConnected()) {
return browser;
} else {
let executablePath = await Settings.get("chromeExecutable");
executablePath = await prepareChromeExecutable(executablePath);
@@ -72,8 +83,9 @@ async function getBrowser() {
//headless: false,
executablePath,
});
return browser;
}
return browser;
}
async function prepareChromeExecutable(executablePath) {

View File

@@ -18,7 +18,7 @@ class DingDing extends NotificationProvider {
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
}
};
if (this.sendToDingDing(notification, params)) {
if (await this.sendToDingDing(notification, params)) {
return okMsg;
}
} else {
@@ -28,7 +28,7 @@ class DingDing extends NotificationProvider {
content: msg
}
};
if (this.sendToDingDing(notification, params)) {
if (await this.sendToDingDing(notification, params)) {
return okMsg;
}
}
@@ -59,7 +59,7 @@ class DingDing extends NotificationProvider {
if (result.data.errmsg === "ok") {
return true;
}
return false;
throw new Error(result.data.errmsg);
}
/**

View File

@@ -1205,6 +1205,12 @@ let needSetup = false;
await doubleCheckPassword(socket, currentPassword);
}
// Log out all clients if enabling auth
// GHSA-23q2-5gf8-gjpp
if (currentDisabledAuth && !data.disableAuth) {
server.disconnectAllSocketClients(socket.userID, socket.id);
}
const previousChromeExecutable = await Settings.get("chromeExecutable");
const previousNSCDStatus = await Settings.get("nscd");

View File

@@ -716,20 +716,27 @@ const parseCertificateInfo = function (info) {
/**
* Check if certificate is valid
* @param {Object} res Response object from axios
* @param {tls.TLSSocket} socket TLSSocket, which may or may not be connected
* @returns {Object} Object containing certificate information
*/
exports.checkCertificate = function (res) {
if (!res.request.res.socket) {
throw new Error("No socket found");
exports.checkCertificate = function (socket) {
let certInfoStartTime = dayjs().valueOf();
// Return null if there is no socket
if (socket === undefined || socket == null) {
return null;
}
const info = res.request.res.socket.getPeerCertificate(true);
const valid = res.request.res.socket.authorized || false;
const info = socket.getPeerCertificate(true);
const valid = socket.authorized || false;
log.debug("cert", "Parsing Certificate Info");
const parsedInfo = parseCertificateInfo(info);
if (process.env.TIMELOGGER === "1") {
log.debug("monitor", "Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
}
return {
valid: valid,
certInfo: parsedInfo

View File

@@ -5,6 +5,14 @@
<input id="hostname" v-model="$parent.notification.smtpHost" type="text" class="form-control" required>
</div>
<i18n-t tag="div" keypath="Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent" class="form-text">
<template #localhost>
<code>localhost</code>
</template>
<template #local_mta>
<a href="https://wikipedia.org/wiki/Mail_Transfer_Agent" target="_blank">{{ $t("locally configured mail transfer agent") }}</a>
</template>
</i18n-t>
<div class="mb-3">
<label for="port" class="form-label">{{ $t("Port") }}</label>
<input id="port" v-model="$parent.notification.smtpPort" type="number" class="form-control" required min="0" max="65535" step="1">

View File

@@ -57,10 +57,16 @@ for (let lang in languageList) {
const rtlLangs = [ "fa", "ar-SY", "ur" ];
export const currentLocale = () => localStorage.locale
|| languageList[navigator.language] && navigator.language
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|| "en";
/**
* Find the best matching locale to display
* If no locale can be matched, the default is "en"
* @returns {string} the locale that should be displayed
*/
export function currentLocale() {
const potentialLocales = [ localStorage.locale, navigator.language, navigator.language.substring(0, 2), ...navigator.languages ];
const availableLocales = potentialLocales.filter(l => languageList[l]);
return availableLocales[0] || "en";
}
export const localeDirection = () => {
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";

View File

@@ -57,6 +57,8 @@
"Friendly Name": "Friendly Name",
"URL": "URL",
"Hostname": "Hostname",
"locally configured mail transfer agent": "locally configured mail transfer agent",
"Either enter the hostname of the server you want to connect to or localhost if you intend to use a locally configured mail transfer agent": "Either enter the hostname of the server you want to connect to or {localhost} if you intend to use a {local_mta}",
"Port": "Port",
"Heartbeat Interval": "Heartbeat Interval",
"Request Timeout": "Request Timeout",

View File

@@ -4,9 +4,13 @@ describe("Test i18n.js", () => {
it("currentLocale()", () => {
const setLanguage = (language) => {
Object.defineProperty(window.navigator, 'language', {
value: language,
writable: true
Object.defineProperty(window.navigator, 'language', {
value: language,
writable: true
});
Object.defineProperty(window.navigator, 'languages', {
value: [language],
writable: true
});
}
setLanguage('en-EN');
@@ -41,4 +45,4 @@ describe("Test i18n.js", () => {
expect(currentLocale()).equal("zh-HK");
});
});
});