pySCG: Numbers related landing page to explain generic issues, such as array with ctypes and numpy
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
- 42/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- numpy, python
- Lĩnh vực
- documentation, security
Hướng nghiên cứu
Start by reviewing the repository’s existing CWE-191, CWE-1335, and CWE-197 pages and the linked material, then check how numeric issue pages are organized. Draft a shared landing page covering Python integers, array, numpy, ctypes, conversions, numeric bounds, and the bytes examples. Done when it explains these topics accurately and links to the related numeric issues.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Numbers landing page to explain generic issues around:
- Hardware limitations
- A Python int can be much bigger than what is known as 64 bit int and why NUM13 does not apply
- Python relation to primitive int numpy ctypes
- implicit conversion can come unexpected
- explicit conversion can have unexpected results.
- Upper boundaries
- Lower boundaries.
Content that is helpful for understanding numbers or above points and applicable for all numeric related issues such as
Avoid loss of precision when converting primitive integers to floating-point
Pythons array module is the closest thing to primitive types mentioned in the Java or C rules such as unsigned or signed int, float, long or char. The array module should be at least mentioned together with numpy and ctypes.
CWE-191: Detect or prevent integer overflow
"by classes and are protected against overflows. Primitive types such as numpy , time or ctype share issues known from C , or C++"
CWE-1335: Incorrect Bitwise Shift of Integer
"outcomes. Python's ctypes module allows integration of C based system libraries into Python and direct access to C-type variables that can have"
CWE-197: Control rounding when converting to less precise numbers
"Python has ctypes module allowing users to work with many different data types. "
Additional notes from previous conversations:
A build in type byte does not exist in Python 3, try byte(0) vs bytes(0).
The bytes and bytearray classes are both designed for binary data as a sequence of integers capped to byte size range of decimal 0 to 255. The use of bytes for memory optimization is unlikely of help as it requires the extra handling and storage for the sequence part; compare sys.getsizeof(bytes(10)) vs sys.getsizeof(int(10)).
String presentations such as decimal 10 displayed by the programming IDE as a newline \n character can be confusing.
Storing anything bigger than an decimal 255 in bytes requires to spread the number across a sequence of byte sized objects.
Designing with bytes and bytearray classes requires a good understanding of example01.py code. Python objects can be stored directly via the pickle and unpickle modules. Memory optimization is better addressed by understanding the difference between mutable and nonmutable objects in Python.
example01.py:
# byte object does not exist:
byte(10) {}# NameError: name 'byte' is not defined
# bytes(10) creates a sequence with 10 items
bytes(10) {}# b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
# string representation can be confusing
bytes([{}}}\{{{}10{}}}\{{{}]) {}# b'\n' ;IDE printing hex 0a as newline \n
bytes([{}}}\{{{}10{}}}\{{{}]).hex() {}# '0a'
b'10' == b'\x31\x30' # True ; decimal string 10 to hex string \x31\x30
# storing byte sized decimal in bytes compared to build in int:
print(sys.getsizeof(bytes([{}}}\{{{}10{}}}\{{{}]))) {}# 34
print(sys.getsizeof(10)) {}{ {# 28 }
}
# different platform store number invers to each other:
int(1).to_bytes(2, {}'little') {}# b'\x01\x00'
int(1).to_bytes(2, {}'big') {}# b'\x00\x01'
# bytes comes with Overflow protection
int(256).to_bytes(1, {}'big') {}# OverflowError: int too big to convert
- Ngôn ngữ chính
- Python
- Star
- 2
- Fork
- 2
- Merge trung bình
- 11 phút
- Pull request đã merge (30 ngày)
- 2
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 ossf/python-secure-coding-guide
-
pyscg-0051 should use a context managerCó thể đã có người làm @s19110 đã nhận 8 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ossf/python-secure-coding-guide#1 · 4 bình luận · 1 người được giao ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
ossf/python-secure-coding-guide#29 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Tất cả issue của ossf/python-secure-coding-guide
Issue tương tự
-
README Quick Start query command fails, and doctor points to a missing Prerequisites sectionĐang mởdocumentation type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
add entry to blockĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Có thể đã có người làm @0z5a đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xCó thể đã có người làm @Shizoqua đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/TokenEconomizer#221 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
plot_graph crashes when a mesh node has no m2m edgeCó thể đã có người làm @tygvi đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mllam/neural-lam#883 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày