fixed sonarqube findings
Sonarqube Scanner / Prepare environment (push) Successful in 7s
Sonarqube Scanner / Build and test (push) Failing after 22s
Sonarqube Scanner / SonarQube analysis (push) Skipped
Sonarqube Scanner / Deploy to Server (push) Successful in 5s

This commit is contained in:
Florian Zumpe
2026-10-18 17:48:46 +02:00
parent 0e4cdfbd54
commit ae798034c5
11 changed files with 181 additions and 46 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import crypto from 'node:crypto';
import { isLoopbackAddress } from './route-write-access.js';
import { guardPoint, clearPointLocks, hasPointLocks } from './point-locks.js';
import fs from 'node:fs';
import path from 'node:path';
@@ -163,7 +164,7 @@ export function listGroups(db, req) {
}
function failureKey(req) {
const localProxy = ['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(req.socket?.remoteAddress);
const localProxy = isLoopbackAddress(req.socket?.remoteAddress);
return hash(String(localProxy && req.headers['x-real-ip'] || req.socket?.remoteAddress || 'unknown'));
}
+8 -2
View File
@@ -25,7 +25,10 @@ function read(routeId, poiId) {
}
return lock;
}
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
catch (error) {
if (error.code === 'ENOENT') return null;
throw error;
}
}
function write(routeId, poiId, lock) {
const target = filename(routeId, poiId);
@@ -86,7 +89,10 @@ export function hasPointLocks(routeId) {
const directory = path.join(routeDirectory(routeId), 'locks');
let entries;
try { entries = fs.readdirSync(directory, { withFileTypes: true }); }
catch (error) { if (error.code === 'ENOENT') return false; throw error; }
catch (error) {
if (error.code === 'ENOENT') return false;
throw error;
}
let locked = false;
for (const entry of entries) {
if (entry.isFile() && /^\d+\.json$/.test(entry.name) && read(routeId, Number(entry.name.slice(0, -5)))) locked = true;
+1 -1
View File
@@ -13,7 +13,7 @@ function hasForwardingHeader(req, name) {
return value != null && String(value).trim().length > 0;
}
function isLoopbackAddress(address) {
export function isLoopbackAddress(address) {
if (typeof address !== 'string' || address.length === 0) return false;
if (address === '::1') return true;