pyscg-0034 is assumin implicit optional types against PEP484
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- documentation, security
Hướng nghiên cứu
Read the pyscg-0034 guideline section linked in the issue, especially its compliant and non-compliant examples, and compare the stated rule with the Optional type annotations and behavior described in the report. Decide whether the recommendation should be corrected or removed, then update the guideline so its rule and examples agree; done means the guidance addresses the reported type-checking and input-validation concerns.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The python guideline psycg-0034 is incorrect, or at least outdated, you shouldn't check that a typed signature is not None if it's not typed as optional, and this is the behaviour of most type checkers, like mypy after 0.991 release.
The compliant case has the same explotation as the non compliant one, if you input another param.
is_valid_name(1) will raise an exception on both compliant and not compliant. There is no difference between None and 1, and there is no null pointer dereference in any case. If you try to pass an incorrect type to a function you will get a type error. You should check for None, if the function can receive None. And check for everything if the function can return anything. In any case, if you don't trust the param, you can get RCE with any param, even checking:
""" Compliant Code Example """
from typing import Optional
def is_valid_name(s: Optional[str]) -> bool:
""" Check if the input is a name with 2 capitalised Strings """
if s is None:
return False
if isinstance(s, str):
names = s.split()
if len(names) != 2:
return False
return s.istitle()
#####################
# Attempting to exploit above code example
#####################
class Exploit(str):
def split(self):
print("you are hacked")
name = is_valid_name(Exploit())
I suggest delete that recommendation
- 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 7 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