Multiple issues in array data setter
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với bản tái hiện poc_idl_array.py được liên kết và so sánh việc gán phần tử mảng với hành vi của các kiểu tích hợp được mô tả trong issue. Theo dõi các lớp message Python được tạo cho các mảng cố định, sau đó bổ sung coverage cho việc từ chối giá trị ngoài phạm vi và sai kiểu trong các mảng số, bool, byte và string; hoàn thành khi các phép gán không hợp lệ luôn thất bại một cách nhất quán trong khi các giá trị hợp lệ vẫn thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- Binary installation via
apt
- Binary installation via
- Version or commit hash:
- foxy
- DDS implementation:
- Fast-RTPS
- Client library (if applicable):
- N/A
Steps to reproduce issue
- Clone and build messages
$ mkdir -p ~/idltest_ws/src
$ cd ~/idltest_ws/src
$ git clone [email protected]:squizz617/idltest_msgs.git
$ cd ~/idltest_ws
$ colcon build --symlink-install
- Source workspaces (replace zsh with bash if using Bash)
$ source /opt/ros/foxy/setup.zsh
$ source ~/idltest_ws/install/setup.zsh
- Download and run PoC
$ wget https://gist.githubusercontent.com/squizz617/13631a18d25a1b7836414cce0c579227/raw/3e5113c78f2b1b7fe3296a2b29298afad6d8349e/poc_idl_array.py
$ chmod a+x poc_idl_array.py
$ ./poc_idl_array.py
Expected behavior
The PoC is self-explanatory. On the fixed arrays of built-in types, it tests the following three properties: (1) setting legitimate values should succeed, (2) setting out-of-valid-range values should fail, and (3) setting values of mismatching types should fail.
Actual behavior
The issues can be broadly categorized into three types.
- Missing range checks for numeric type (integer and float) arrays
uint8 array allows out of range integers to be assigned:
from idltest_msgs.msg import UInt8FixedArray
ui8fa = UInt8FixedArray()
ui8fa.data[0] = -1 # should fail but doesn't
print(ui8fa.data[0]) # value becomes 255
ui8fa.data[1] = 256 # should fail but doesn't
print(ui8fa.data[1]) # value becomes 0
int8 array also allows out of range integers to be assigned:
from idltest_msgs.msg import Int8FixedArray
i8fa = Int8FixedArray()
ui8fa.data[0] = -129 # should fail but doesn't
print(ui8fa.data[0]) # value becomes 127
ui8fa.data[1] = 128 # should fail but doesn't
print(ui8fa.data[1]) # value becomes -128
float32 array allows double to be assigned:
from idltest_msgs.msg import Float32FixedArray
f32fa = Float32FixedArray()
f32fa.data[0] = 1.0e+365 # should fail but doesn't
print(f32fa.data[0]) # value becomes inf
- Auto casting of data of wrong types
Integer arrays accept floats and casts them to int, dropping precision:
i8fa = Int8FixedArray()
i8fa.data[2] = 3.141592 # should fail but doesn't
print(i8fa.data[2]) # value becomes 3
i8fa.data[3] = 314.1592 # should fail but doesn't
print(i8fa.data[3]) # value becomes 58
For the types that cannot be casted to int, the assignment fails but the exception is raised not by the IDL:
i8fa.data[4] = "string" # fails (int() casting failure, not idl type check failure)
i8fa.data[5] = \x00 # fails (int() casting failure, not idl type check failure)
- Missing type checks for bool, byte, and string arrays
Any data of any type can be assigned to bool, byte or string arrays:
boolfa = BoolFixedArray()
bytefa = ByteFixedArray()
sfa = StringFixedArray()
# nothing fails
boolfa.data[0] = 32
boolfa.data[1] = 3.141592
boolfa.data[2] = 1.0e+365
boolfa.data[3] = 3.141592
boolfa.data[4] = "string"
boolfa.data[5] = [1, 2, 3]
boolfa.data[6] = {1: 2}
print(boolfa) # the illegitimate values are assigned as is
bytefa.data[0] = 32
bytefa.data[1] = 3.141592
bytefa.data[2] = 1.0e+365
bytefa.data[3] = 3.141592
bytefa.data[4] = "string"
bytefa.data[5] = [1, 2, 3]
bytefa.data[6] = {1: 2}
print(bytefa) # the illegitimate values are assigned as is
sfa.data[0] = 32
sfa.data[1] = 3.141592
sfa.data[2] = 1.0e+365
sfa.data[3] = 3.141592
sfa.data[4] = [1, 2, 3]
sfa.data[5] = {1: 2}
print(sfa) # the illegitimate values are assigned as is
In a nutshell, array elements are not properly checked at the time of assignment, unlike what's done for the built-in types (e.g., we cannot assign 256 or 3.14 to a uint8 variable, we cannot assign 3.14 to a string variable, ...).
- Ngôn ngữ chính
- EmberScript
- Star
- 26
- Fork
- 68
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ros2/rosidl_python
-
Eliminate array resetting loop in _msg_support.c.emCó thể đã có người làm @Lidang-Jiang đã nhận 168 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ros2/rosidl_python#255 · 1 reaction ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
ros2/rosidl_python#264 · 2 bình luận ·
-
Message named pkg/Duration with field builtin_interfaces/Duration is invalidCó thể đã có người làm @Lidang-Jiang đã nhận 167 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
ros2/rosidl_python#257 · 8 bình luận ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ros2/rosidl_python#242 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 32/100
ros2/rosidl_python#219 · 2 bình luận ·
Tất cả issue của ros2/rosidl_python
Issue tương tự
-
effort: low prio: low ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
digitalfabrik/integreat-cms#4616 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
refactor topic-map
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add an EPUB parserĐang mởarea: core good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
openapi/gknowledge#21 ·
-
get() for StrEnumCó thể đã có người làm @FeJo5952 đã nhận hôm nay. Đang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
collective/icalendar#1921 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ETQ admin, le select de condition d'une annotation répétable liste les champs publics deux foisĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
demarche-numerique/demarche.numerique.gouv.fr#14301 ·
Maintainer thường phản hồi trong vòng 1 ngày