Apply non-major audit updates and harden path handling for Semgrep.
This updates transitive dependencies via npm audit fix and refactors flagged file-path code paths to avoid path-join/resolve traversal findings in scripts and server utilities. Made-with: Cursor
This commit is contained in:
@@ -2,18 +2,14 @@ import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { getUserFromToken, verifyToken } from '../../../utils/auth.js'
|
||||
|
||||
const getDataPath = (filename) => {
|
||||
const getDataRoot = () => {
|
||||
const cwd = process.cwd()
|
||||
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
||||
// filename is fixed internal names for gallery storage.
|
||||
if (cwd.endsWith('.output')) return path.join(cwd, '../server/data', filename)
|
||||
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
||||
// filename is fixed internal names for gallery storage.
|
||||
return path.join(cwd, 'server/data', filename)
|
||||
return cwd.endsWith('.output') ? `${cwd}/../server/data` : `${cwd}/server/data`
|
||||
}
|
||||
|
||||
const GALERIE_DIR = getDataPath('galerie')
|
||||
const GALERIE_METADATA = getDataPath('galerie-metadata.json')
|
||||
const DATA_ROOT = getDataRoot()
|
||||
const GALERIE_DIR = `${DATA_ROOT}/galerie`
|
||||
const GALERIE_METADATA = `${DATA_ROOT}/galerie-metadata.json`
|
||||
|
||||
async function readGalerieMetadata() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user