Introduce sandbox folder
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
|
# Random files to check for function
|
||||||
|
sandbox/*
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
14
index.js
14
index.js
@@ -34,13 +34,16 @@ const DIR=settings.dirname;
|
|||||||
app.use(bodyParser.urlencoded({extended:false}))
|
app.use(bodyParser.urlencoded({extended:false}))
|
||||||
app.use(bodyParser.json())
|
app.use(bodyParser.json())
|
||||||
|
|
||||||
|
// Check if a given directory is within the main defined directory or not
|
||||||
let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirmain).startsWith('..')
|
let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirmain).startsWith('..')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Get folder details
|
//Get folder details
|
||||||
|
|
||||||
app.post('/files/ls',(req,res,next)=>{
|
app.post('/files/ls',(req,res,next)=>{
|
||||||
const location = processing.mergedir(req.body.loc,settings)
|
const location = processing.mergedir(req.body.loc,settings)
|
||||||
//console.log(path.relative( path.normalize(settings.dirname) ,location))
|
|
||||||
|
|
||||||
//Make sure not escaping the given path; insecure
|
//Make sure not escaping the given path; insecure
|
||||||
if(inDir(settings.dirname,location)){
|
if(inDir(settings.dirname,location)){
|
||||||
@@ -64,6 +67,11 @@ app.post('/files/ls',(req,res,next)=>{
|
|||||||
//next()
|
//next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.post('/files/ls',(res,rep,next)=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
//Attempt to upload a file - Placeholder
|
//Attempt to upload a file - Placeholder
|
||||||
app.put('/files/upload',(req,res)=>{
|
app.put('/files/upload',(req,res)=>{
|
||||||
console.log("Upload attempted")
|
console.log("Upload attempted")
|
||||||
@@ -87,4 +95,8 @@ app.listen(port,()=>{
|
|||||||
console.log(`Listening : ${port}`)
|
console.log(`Listening : ${port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.use((err,req,res,next)=>{
|
||||||
|
res.status(500).json({error:`${err}`})
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"dirname":"./",
|
"dirname":"./sandbox/",
|
||||||
"sqlFileName":"test.db",
|
"sqlFileName":"test.db",
|
||||||
"showHidden":false,
|
"showHidden":false,
|
||||||
"authToUpload":false
|
"authToUpload":false
|
||||||
|
Reference in New Issue
Block a user