Account for pathlib chmod setting insecure permissions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 836
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
The current implementation of B103: set_bad_file_permissions works well for uses of the chmod functions from the os module directly.
It fails to report insecure permissions when the equivalent functions from the pathlib module are being used instead.
As a simple example, consider:
import pathlib
p = pathlib.Path("dummy_file")
p.chmod(0o666)
This should trigger an equivalent warning just as os.chmod("dummy_file", 0o666) currently does.
The code should be generalized to support the pathlib version of the chmod functions as well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of Bandit's B103: set_bad_file_permissions check and compare its handling of os.chmod with the pathlib.Path.chmod example in this issue. Done means insecure permissions set through pathlib are reported with an equivalent warning to direct os.chmod usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100