Conversation
-------------- .github/workflows/changelog.yml CHANGELOG.md data/database.db package-lock.json package.json
| router.get("/config", async (req, res) => { | ||
| const configPath = path.join(__dirname, "../../config/dockerConfig.json"); | ||
| try { | ||
| const rawData = fs.readFileSync(configPath); | ||
| const jsonData = JSON.parse(rawData.toString()); | ||
| res.status(200).json(jsonData); | ||
| } catch (error) { | ||
| logger.error("Error loading dockerConfig.json: " + error.message); | ||
| res.status(500).json({ error: "Failed to load Docker configuration" }); | ||
| } | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting
…ng mermaid diagrams and dependecy-cruiser
| const regex = /(\d+)([smh])/g; | ||
| let match; | ||
|
|
||
| while ((match = regex.exec(interval))) { |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data
| router.post("/enable", (req, res) => { | ||
| fs.readFile(passwordBool, "utf8", (err, data) => { | ||
| const password = req.query.password; | ||
| if (err) { | ||
| logger.error("Error reading the file:", err); | ||
| return; | ||
| } | ||
|
|
||
| const isAuthEnabled = data.trim() === "true"; | ||
| if (isAuthEnabled) { | ||
| logger.error( | ||
| "Passowrd Authentication is already enabled, please dactivate it first", | ||
| ); | ||
| return res.status(401).json({ | ||
| message: | ||
| "Passowrd Authentication is already enabled, please dactivate it first", | ||
| }); | ||
| } | ||
|
|
||
| if (!password) { | ||
| return res.status(400).json({ message: "Password is required" }); | ||
| } | ||
|
|
||
| bcrypt.genSalt(saltRounds, (err, salt) => { | ||
| if (err) { | ||
| logger.error("Error generating salt"); | ||
| return res.status(500).json({ message: "Error generating salt" }); | ||
| } | ||
|
|
||
| bcrypt.hash(password, salt, (err, hash) => { | ||
| if (err) { | ||
| logger.error("Error hashing password"); | ||
| return res.status(500).json({ message: "Error hashing password" }); | ||
| } | ||
|
|
||
| const passwordData = { hash, salt }; | ||
| fs.writeFile(passwordFile, JSON.stringify(passwordData), (err) => { | ||
| if (err) | ||
| return res.status(500).json({ message: "Error saving password" }); | ||
| setTrue(); | ||
| res.json({ message: "Authentication enabled" }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| router.post("/disable", (req, res) => { | ||
| const password = req.query.password; | ||
| if (!password) { | ||
| logger.error("Password is required!"); | ||
| return res.status(400).json({ message: "Password is required" }); | ||
| } | ||
|
|
||
| fs.readFile(passwordFile, "utf8", (err, data) => { | ||
| if (err) { | ||
| logger.error("Error reading password"); | ||
| return res.status(500).json({ message: "Error reading password" }); | ||
| } | ||
|
|
||
| const storedData = JSON.parse(data); | ||
| bcrypt.compare(password, storedData.hash, (err, result) => { | ||
| if (err) { | ||
| logger.error("Error validating password"); | ||
| return res.status(500).json({ message: "Error validating password" }); | ||
| } | ||
| if (!result) { | ||
| logger.error("Invalid password"); | ||
| return res.status(401).json({ message: "Invalid password" }); | ||
| } | ||
| setFalse(); | ||
| res.json({ message: "Authentication disabled" }); | ||
| }); | ||
| }); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| router.get("/latest", (req, res) => { | ||
| db.get( | ||
| "SELECT info FROM data ORDER BY timestamp DESC LIMIT 1", | ||
| (err, row) => { | ||
| if (err) { | ||
| logger.error("Error fetching latest data:", err.message); | ||
| return res.status(500).json({ error: "Internal server error" }); | ||
| } | ||
| res.json(JSON.parse(row.info)); | ||
| }, | ||
| ); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| router.get("/time/24h", (req, res) => { | ||
| const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(); | ||
| db.all( | ||
| "SELECT info FROM data WHERE timestamp >= ?", | ||
| [oneDayAgo], | ||
| (err, rows) => { | ||
| if (err) { | ||
| logger.error("Error fetching data from last 24 hours:", err.message); | ||
| return res.status(500).json({ error: "Internal server error" }); | ||
| } | ||
| res.json(formatRows(rows)); | ||
| }, | ||
| ); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| scheduleFetch(); | ||
|
|
||
| // Routes | ||
| app.use("/api", authMiddleware, api); |
Check failure
Code scanning / CodeQL
Missing rate limiting
|
|
||
| // Routes | ||
| app.use("/api", authMiddleware, api); | ||
| app.use("/conf", authMiddleware, conf); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| // Routes | ||
| app.use("/api", authMiddleware, api); | ||
| app.use("/conf", authMiddleware, conf); | ||
| app.use("/auth", authMiddleware, auth); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| app.use("/api", authMiddleware, api); | ||
| app.use("/conf", authMiddleware, conf); | ||
| app.use("/auth", authMiddleware, auth); | ||
| app.use("/data", authMiddleware, data); |
Check failure
Code scanning / CodeQL
Missing rate limiting
| app.use("/conf", authMiddleware, conf); | ||
| app.use("/auth", authMiddleware, auth); | ||
| app.use("/data", authMiddleware, data); | ||
| app.use("/frontend", authMiddleware, frontend); |
Check failure
Code scanning / CodeQL
Missing rate limiting
Rewrite the backend to optimize, well everything.
Documentation needs to be updated