mirror of
https://github.com/nspcc-dev/neofs-contract.git
synced 2026-03-01 04:28:59 +00:00
Responsive panic about invalid user input during contract execution #138
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U1
U2
U3
U4
alphabet
audit
balance
blocked
bug
config
container
discussion
documentation
enhancement
feature
go
good first issue
help wanted
neofs
neofsid
netmap
nns
nns
performance
proxy
question
reputation
security
task
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neofs-contract#138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cthulhu-rider on GitHub (Apr 10, 2023).
Context
Calling https://pkg.go.dev/github.com/nspcc-dev/neofs-contract/container#SetEACL threw following exception:
This behavior occurs similar to
index out of rangepanic in the general Go view. While in general panic has the right to exist (developer's mistakes), code MUST NOT panic about user input.Solution
Explore all methods which are sensitive to user input and
@roman-khimov commented on GitHub (Apr 10, 2023):
For a contract it's OK to panic.
You're assuming that contracts can return
(any, error), but they can't. The VM only supports one return value from public methods and either it becomes astruct{}with two fields, but this complicates the interfaces substantially and can't be handled in a generic way, or contract just panics which is an exception that in most cases leads to FAULT.Documenting assumptions on inputs is OK, it's useful anyway.
@cthulhu-rider commented on GitHub (Apr 10, 2023):
@roman-khimov by
I meant responsive exceptions (in Go code -
panicarg). IMO it's clearer to receivemissing X fieldfault exception thaninvalid offset.