The os.path module for path manipulation. join() concatenates path components but does not resolve traversal sequences — path-traversal bug when joining a trusted base with a user-controlled path. Use os.path.commonpath + realpath containment checks to sanitize.
.realpath()Sanitizeros.path.realpath(path: str) -> str
Resolves all symlinks and . / .. components. Combine with commonpath for traversal defense.
return.commonpath()Sanitizeros.path.commonpath(paths: Sequence[str]) -> str
Returns the longest common path. Use to assert a user path stays inside a trusted base.
return| FQN | Field | |
|---|---|---|
| os.path | fqns[0] |
Wrong FQN → 0 findings. Verify with: change fqns to garbage → must produce 0 results.
from codepathfinder.go_rule import PyOSPath