Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
a7dad278
Commit
a7dad278
authored
7 years ago
by
Megan Henning
Committed by
Gunnar Schaefer
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move reaper upload, change uid upload logic
parent
7b2788c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/api.py
+4
-4
4 additions, 4 deletions
api/api.py
api/placer.py
+17
-2
17 additions, 2 deletions
api/placer.py
api/upload.py
+3
-0
3 additions, 0 deletions
api/upload.py
with
24 additions
and
6 deletions
api/api.py
+
4
−
4
View file @
a7dad278
...
...
@@ -84,10 +84,10 @@ endpoints = [
# General-purpose upload & download
route
(
'
/download
'
,
Download
,
h
=
'
download
'
,
m
=
[
'
GET
'
,
'
POST
'
]),
route
(
'
/upload/<strategy:label|uid|uid-match>
'
,
Upload
,
h
=
'
upload
'
,
m
=
[
'
POST
'
]),
route
(
'
/clean-packfiles
'
,
Upload
,
h
=
'
clean_packfile_tokens
'
,
m
=
[
'
POST
'
]),
route
(
'
/engine
'
,
Upload
,
h
=
'
engine
'
,
m
=
[
'
POST
'
]),
route
(
'
/download
'
,
Download
,
h
=
'
download
'
,
m
=
[
'
GET
'
,
'
POST
'
]),
route
(
'
/upload/<strategy:label|uid|uid-match
|reaper
>
'
,
Upload
,
h
=
'
upload
'
,
m
=
[
'
POST
'
]),
route
(
'
/clean-packfiles
'
,
Upload
,
h
=
'
clean_packfile_tokens
'
,
m
=
[
'
POST
'
]),
route
(
'
/engine
'
,
Upload
,
h
=
'
engine
'
,
m
=
[
'
POST
'
]),
# Top-level endpoints
...
...
This diff is collapsed.
Click to expand it.
api/placer.py
+
17
−
2
View file @
a7dad278
...
...
@@ -135,7 +135,8 @@ class UIDPlacer(Placer):
Sessions and acquisitions are identified by UID.
"""
metadata_schema
=
'
uidupload.json
'
create_hierarchy
=
staticmethod
(
hierarchy
.
upsert_bottom_up_hierarchy
)
create_hierarchy
=
staticmethod
(
hierarchy
.
upsert_top_down_hierarchy
)
match_type
=
'
uid
'
def
__init__
(
self
,
container_type
,
container
,
id_
,
metadata
,
timestamp
,
origin
,
context
):
super
(
UIDPlacer
,
self
).
__init__
(
container_type
,
container
,
id_
,
metadata
,
timestamp
,
origin
,
context
)
...
...
@@ -151,7 +152,7 @@ class UIDPlacer(Placer):
metadata_validator
(
self
.
metadata
,
'
POST
'
)
# If not a superuser request, pass uid of user making the upload request
targets
=
self
.
create_hierarchy
(
self
.
metadata
,
user
=
self
.
context
.
get
(
'
uid
'
),
site
=
self
.
context
.
get
(
'
site
'
))
targets
=
self
.
create_hierarchy
(
self
.
metadata
,
type_
=
self
.
match_type
,
user
=
self
.
context
.
get
(
'
uid
'
),
site
=
self
.
context
.
get
(
'
site
'
))
self
.
metadata_for_file
=
{}
...
...
@@ -201,6 +202,18 @@ class UIDPlacer(Placer):
self
.
recalc_session_compliance
()
return
self
.
saved
class
ReaperUIDPlacer
(
UIDPlacer
):
"""
A placer that creates or matches based on UID.
Ignores project and group information if it finds session with matching UID.
Allows users to move sessions during scans without causing new data to be
created in referenced project/group.
"""
metadata_schema
=
'
uidmatchupload.json
'
create_hierarchy
=
staticmethod
(
hierarchy
.
hierarchy
.
upsert_bottom_up_hierarchy
)
match_type
=
'
uid
'
class
LabelPlacer
(
UIDPlacer
):
"""
...
...
@@ -212,6 +225,7 @@ class LabelPlacer(UIDPlacer):
metadata_schema
=
'
labelupload.json
'
create_hierarchy
=
staticmethod
(
hierarchy
.
upsert_top_down_hierarchy
)
match_type
=
'
label
'
class
UIDMatchPlacer
(
UIDPlacer
):
...
...
@@ -221,6 +235,7 @@ class UIDMatchPlacer(UIDPlacer):
metadata_schema
=
'
uidmatchupload.json
'
create_hierarchy
=
staticmethod
(
hierarchy
.
find_existing_hierarchy
)
match_type
=
'
uid
'
class
EnginePlacer
(
Placer
):
...
...
This diff is collapsed.
Click to expand it.
api/upload.py
+
3
−
0
View file @
a7dad278
...
...
@@ -21,6 +21,7 @@ Strategy = util.Enum('Strategy', {
'
labelupload
'
:
pl
.
LabelPlacer
,
'
uidupload
'
:
pl
.
UIDPlacer
,
'
uidmatch
'
:
pl
.
UIDMatchPlacer
,
'
reaper
'
:
pl
.
UIDReaperPlacer
,
'
analysis
'
:
pl
.
AnalysisPlacer
,
# Upload N files to an analysis as input and output (no db updates)
'
analysis_job
'
:
pl
.
AnalysisJobPlacer
# Upload N files to an analysis as output from job results
})
...
...
@@ -165,6 +166,8 @@ class Upload(base.RequestHandler):
strategy
=
Strategy
.
uidupload
elif
strategy
==
'
uid-match
'
:
strategy
=
Strategy
.
uidmatch
elif
strategy
==
'
reaper
'
:
strategy
=
Strategy
.
reaper
else
:
self
.
abort
(
500
,
'
stragegy {} not implemented
'
.
format
(
strategy
))
return
process_upload
(
self
.
request
,
strategy
,
origin
=
self
.
origin
,
context
=
context
)
...
...
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