Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
d158257f
Commit
d158257f
authored
2 years ago
by
Tigran Mkrtchyan
Browse files
Options
Downloads
Patches
Plain Diff
frontend-grpc: validate user request arguments
parent
4a941a95
Branches
v4.8.2-1
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend-grpc/FrontendGRpcSvc.cpp
+87
-1
87 additions, 1 deletion
frontend-grpc/FrontendGRpcSvc.cpp
with
87 additions
and
1 deletion
frontend-grpc/FrontendGRpcSvc.cpp
+
87
−
1
View file @
d158257f
...
...
@@ -37,14 +37,33 @@ Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::dcache::
sp
.
add
(
"request"
,
"archive"
);
const
std
::
string
storageClass
=
request
->
file
().
storageclass
();
if
(
storageClass
.
empty
())
{
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"Storage class is not set."
);
}
lc
.
log
(
cta
::
log
::
DEBUG
,
"Archive request for storageClass: "
+
storageClass
);
cta
::
common
::
dataStructures
::
RequesterIdentity
requester
;
requester
.
name
=
request
->
cli
().
user
().
username
();
requester
.
group
=
request
->
cli
().
user
().
groupname
();
auto
instance
=
request
->
instance
().
name
();
// check validate request args
if
(
request
->
instance
().
name
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA instance is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA instance is not set."
);
}
if
(
request
->
cli
().
user
().
username
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA username is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA username is not set."
);
}
if
(
request
->
cli
().
user
().
groupname
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA groupname is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA groupname is not set."
);
}
auto
instance
=
request
->
instance
().
name
();
sp
.
add
(
"instance"
,
instance
);
sp
.
add
(
"username"
,
request
->
cli
().
user
().
username
());
sp
.
add
(
"groupname"
,
request
->
cli
().
user
().
groupname
());
...
...
@@ -102,6 +121,27 @@ Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::dcache::r
lc
.
log
(
cta
::
log
::
DEBUG
,
"Delete request"
);
sp
.
add
(
"request"
,
"delete"
);
// check validate request args
if
(
request
->
instance
().
name
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA instance is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA instance is not set."
);
}
if
(
request
->
cli
().
user
().
username
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA username is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA username is not set."
);
}
if
(
request
->
cli
().
user
().
groupname
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA groupname is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA groupname is not set."
);
}
if
(
request
->
archiveid
()
==
0
)
{
lc
.
log
(
cta
::
log
::
WARNING
,
"Invalid archive file id"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"Invalid archive file id."
);
}
auto
instance
=
request
->
instance
().
name
();
// Unpack message
cta
::
common
::
dataStructures
::
DeleteArchiveRequest
deleteRequest
;
...
...
@@ -148,8 +188,33 @@ Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::dcache:
sp
.
add
(
"request"
,
"retrieve"
);
const
std
::
string
storageClass
=
request
->
file
().
storageclass
();
if
(
storageClass
.
empty
())
{
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"Storage class is not set."
);
}
lc
.
log
(
cta
::
log
::
DEBUG
,
"Retrieve request for storageClass: "
+
storageClass
);
// check validate request args
if
(
request
->
instance
().
name
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA instance is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA instance is not set."
);
}
if
(
request
->
cli
().
user
().
username
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA username is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA username is not set."
);
}
if
(
request
->
cli
().
user
().
groupname
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA groupname is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA groupname is not set."
);
}
if
(
request
->
archiveid
()
==
0
)
{
lc
.
log
(
cta
::
log
::
WARNING
,
"Invalid archive file id"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"Invalid archive file id."
);
}
auto
instance
=
request
->
instance
().
name
();
sp
.
add
(
"instance"
,
instance
);
...
...
@@ -205,6 +270,27 @@ Status CtaRpcImpl::CancelRetrieve(::grpc::ServerContext* context, const ::cta::d
lc
.
log
(
cta
::
log
::
DEBUG
,
"CancelRetrieve request"
);
sp
.
add
(
"request"
,
"cancel"
);
// check validate request args
if
(
request
->
instance
().
name
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA instance is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA instance is not set."
);
}
if
(
request
->
cli
().
user
().
username
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA username is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA username is not set."
);
}
if
(
request
->
cli
().
user
().
groupname
().
empty
())
{
lc
.
log
(
cta
::
log
::
WARNING
,
"CTA groupname is not set"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"CTA groupname is not set."
);
}
if
(
request
->
fid
()
==
0
)
{
lc
.
log
(
cta
::
log
::
WARNING
,
"Invalid archive file id"
);
return
::
grpc
::
Status
(
::
grpc
::
StatusCode
::
INVALID_ARGUMENT
,
"Invalid archive file id."
);
}
auto
instance
=
request
->
instance
().
name
();
// Unpack message
cta
::
common
::
dataStructures
::
CancelRetrieveRequest
cancelRequest
;
...
...
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