Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Anything Llm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
Mintplex Labs
Anything Llm
Commits
18798c5b
Unverified
Commit
18798c5b
authored
1 year ago
by
Timothy Carambat
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
prevent deletion of documents not in hotdir via director traversal (#258)
resolves #257
parent
d5b1f84a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
collector/api.py
+2
-1
2 additions, 1 deletion
collector/api.py
with
2 additions
and
1 deletion
collector/api.py
+
2
−
1
View file @
18798c5b
import
os
from
flask
import
Flask
,
json
,
request
from
flask
import
Flask
,
json
,
request
from
scripts.watch.process_single
import
process_single
from
scripts.watch.process_single
import
process_single
from
scripts.watch.filetypes
import
ACCEPTED_MIMES
from
scripts.watch.filetypes
import
ACCEPTED_MIMES
...
@@ -7,7 +8,7 @@ WATCH_DIRECTORY = "hotdir"
...
@@ -7,7 +8,7 @@ WATCH_DIRECTORY = "hotdir"
@api.route
(
'
/process
'
,
methods
=
[
'
POST
'
])
@api.route
(
'
/process
'
,
methods
=
[
'
POST
'
])
def
process_file
():
def
process_file
():
content
=
request
.
json
content
=
request
.
json
target_filename
=
content
.
get
(
'
filename
'
)
target_filename
=
os
.
path
.
normpath
(
content
.
get
(
'
filename
'
)
).
lstrip
(
os
.
pardir
+
os
.
sep
)
print
(
f
"
Processing
{
target_filename
}
"
)
print
(
f
"
Processing
{
target_filename
}
"
)
success
,
reason
=
process_single
(
WATCH_DIRECTORY
,
target_filename
)
success
,
reason
=
process_single
(
WATCH_DIRECTORY
,
target_filename
)
return
json
.
dumps
({
'
filename
'
:
target_filename
,
'
success
'
:
success
,
'
reason
'
:
reason
})
return
json
.
dumps
({
'
filename
'
:
target_filename
,
'
success
'
:
success
,
'
reason
'
:
reason
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment