Skip to content

Commit

Permalink
fix(codeQL): Patched code (#4)
Browse files Browse the repository at this point in the history
* fix(codeQL): Patched code

* Update codeql.yml

* Update codeql.yml

* Update codeql.yml

* Update codeql.yml

* Update codeql.yml

* change codeql

* uh codeql ig
  • Loading branch information
Kathund authored Dec 17, 2023
1 parent 5744a83 commit 1be595b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 83 deletions.
81 changes: 0 additions & 81 deletions .github/workflows/codeql.yml

This file was deleted.

8 changes: 6 additions & 2 deletions src/endpoints/file.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Application, Request, Response } from "express";
import { apiMessage, errorMessage } from "../logger";
import { existsSync } from "fs";
import { join } from "path";
import { resolve } from "path";

export default (app: Application) => {
app.get("/:name", async (req: Request, res: Response) => {
try {
const fileName = req.params.name;
apiMessage(req.path, `User is trying to get a file - ${fileName}`);
const filePath = join(__dirname, "../", "files", fileName);
const fileNamePattern = /^[a-zA-Z0-9_-]+$/;
if (!fileNamePattern.test(fileName)) {
return res.status(400).json({ error: "Invalid file name" });
}
const filePath = resolve(__dirname, "../", "files", fileName);
if (!existsSync(filePath)) {
errorMessage(`File ${fileName} not found`);
return res
Expand Down
4 changes: 4 additions & 0 deletions src/endpoints/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default (app: Application) => {
}

const fileName = req.params.name;
const fileNamePattern = /^[a-zA-Z0-9_-]+$/;
if (!fileNamePattern.test(fileName)) {
return res.status(400).json({ error: "Invalid file name" });
}
const filePath = join(__dirname, "../", "files", fileName);
if (existsSync(filePath)) {
errorMessage(`File ${fileName} already exists`);
Expand Down

0 comments on commit 1be595b

Please sign in to comment.