Skip to content

Commit

Permalink
Merge branch 'master' into remotebrowsers
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhancock authored Oct 18, 2023
2 parents f7e8f48 + bbaba29 commit dfec5ad
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "CodeQL"

on:
push:
branches: [ "master", "1.23.X"]
pull_request:
branches: [ "master", "1.23.X"]
schedule:
- cron: '16 22 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
timeout-minutes: 360

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go', 'javascript-typescript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
22 changes: 20 additions & 2 deletions server/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,40 @@ const mysql = require("mysql2/promise");
*/
class Database {

/**
* Boostrap database for SQLite
* @type {string}
*/
static templatePath = "./db/kuma.db";

/**
* Data Dir (Default: ./data)
* @type {string}
*/
static dataDir;

/**
* User Upload Dir (Default: ./data/upload)
* @type {string}
*/
static uploadDir;

/**
* Chrome Screenshot Dir (Default: ./data/screenshots)
* @type {string}
*/
static screenshotDir;

/**
* SQLite file path (Default: ./data/kuma.db)
* @type {string}
*/
static sqlitePath;

/**
* For storing Docker TLS certs (Default: ./data/docker-tls)
* @type {string}
*/
static dockerTLSDir;

/**
Expand Down Expand Up @@ -84,8 +102,8 @@ class Database {
"patch-add-certificate-expiry-status-page.sql": true,
"patch-monitor-oauth-cc.sql": true,
"patch-add-timeout-monitor.sql": true,
"patch-add-gamedig-given-port.sql": true, // The last file so far converted to a knex migration file
"patch-notification-config.sql": true,
"patch-add-gamedig-given-port.sql": true,
"patch-notification-config.sql": true, // The last file so far converted to a knex migration file
};

/**
Expand Down
1 change: 0 additions & 1 deletion server/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class DockerHost {
url: "/containers/json?all=true",
headers: {
"Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version
},
};

Expand Down
3 changes: 0 additions & 3 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ class Monitor extends BeanModel {
timeout: this.timeout * 1000,
headers: {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"User-Agent": "Uptime-Kuma/" + version,
...(contentType ? { "Content-Type": contentType } : {}),
...(basicAuthHeader),
...(oauth2AuthHeader),
Expand Down Expand Up @@ -628,7 +627,6 @@ class Monitor extends BeanModel {
timeout: this.timeout * 1000,
headers: {
"Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version,
},
httpsAgent: CacheableDnsHttpAgent.getHttpsAgent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
Expand Down Expand Up @@ -682,7 +680,6 @@ class Monitor extends BeanModel {
timeout: this.interval * 1000 * 0.8,
headers: {
"Accept": "*/*",
"User-Agent": "Uptime-Kuma/" + version,
},
httpsAgent: CacheableDnsHttpAgent.getHttpsAgent({
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
Expand Down
8 changes: 8 additions & 0 deletions server/uptime-kuma-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { Settings } = require("./settings");
const dayjs = require("dayjs");
const childProcess = require("child_process");
const path = require("path");
const axios = require("axios");
// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead.

/**
Expand Down Expand Up @@ -83,6 +84,9 @@ class UptimeKumaServer {
const sslCert = args["ssl-cert"] || process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || undefined;
const sslKeyPassphrase = args["ssl-key-passphrase"] || process.env.UPTIME_KUMA_SSL_KEY_PASSPHRASE || process.env.SSL_KEY_PASSPHRASE || undefined;

// Set axios default user-agent to Uptime-Kuma/version
axios.defaults.headers.common["User-Agent"] = this.getUserAgent();

log.debug("server", "Creating express and socket.io instance");
this.app = express();
if (sslKey && sslCert) {
Expand Down Expand Up @@ -411,6 +415,10 @@ class UptimeKumaServer {
}
}
}

getUserAgent() {

Check failure on line 419 in server/uptime-kuma-server.js

View workflow job for this annotation

GitHub Actions / check-linters

Missing JSDoc comment
return "Uptime-Kuma/" + require("../package.json").version

Check failure on line 420 in server/uptime-kuma-server.js

View workflow job for this annotation

GitHub Actions / check-linters

Missing semicolon
}
}

module.exports = {
Expand Down

0 comments on commit dfec5ad

Please sign in to comment.