mirror of
https://github.com/Luzifer/ots.git
synced 2025-03-23 09:06:27 -04:00
Add server side check for maximum secret size
closes #138 Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9a530e1c66
commit
1623e09225
5
api.go
5
api.go
@ -70,6 +70,11 @@ func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cust.MaxSecretSize > 0 && len(secret) > int(cust.MaxSecretSize) {
|
||||||
|
a.errorResponse(res, http.StatusBadRequest, errors.New("secret size exceeds maximum"), "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
id, err := a.store.Create(secret, time.Duration(expiry)*time.Second)
|
id, err := a.store.Create(secret, time.Duration(expiry)*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.errorResponse(res, http.StatusInternalServerError, err, "creating secret")
|
a.errorResponse(res, http.StatusInternalServerError, err, "creating secret")
|
||||||
|
@ -29,6 +29,7 @@ type (
|
|||||||
DisableFileAttachment bool `json:"disableFileAttachment" yaml:"disableFileAttachment"`
|
DisableFileAttachment bool `json:"disableFileAttachment" yaml:"disableFileAttachment"`
|
||||||
MaxAttachmentSizeTotal int64 `json:"maxAttachmentSizeTotal" yaml:"maxAttachmentSizeTotal"`
|
MaxAttachmentSizeTotal int64 `json:"maxAttachmentSizeTotal" yaml:"maxAttachmentSizeTotal"`
|
||||||
|
|
||||||
|
MaxSecretSize int64 `json:"-" yaml:"maxSecretSize"`
|
||||||
OverlayFSPath string `json:"-" yaml:"overlayFSPath"`
|
OverlayFSPath string `json:"-" yaml:"overlayFSPath"`
|
||||||
UseFormalLanguage bool `json:"-" yaml:"useFormalLanguage"`
|
UseFormalLanguage bool `json:"-" yaml:"useFormalLanguage"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user